* Implement Cargo Console Add to CargoConsoleComponent GalacticBank information for syncing Bank Account Balance. Implement CargoOrderDatabase on the server side and a list of orders in the CargoOrderDatabaseComponent on the client side. This makes it easier to change data on the server side but also utilize the state syncing between components. Implement GalacticMarketComponent. Only productIds get sent. Both client and server create their lists from YAML. Implement basic spawning of items from approved orders in CargoOrderDatabase. * Finish Cargo Console Add validation to make sure Order Amount is one or more. Implement approve and cancel buttons to CargoConsoleMenu orders list row. Add price to CargoConsoleMenu product list row. Implement CargoOrderDataManager to consolidate CargoOrder lists. Refactor CargoOrderDatabaseComponent to use CargoOrderDataManager instead of storing duplicate lists. Implement canceling orders. Implement approving orders. Fix sprite links. Implement Cargo Request Console.
57 lines
1.6 KiB
C#
57 lines
1.6 KiB
C#
using Content.Shared.GameObjects.Components.Cargo;
|
|
using Content.Shared.Prototypes.Cargo;
|
|
using Robust.Shared.GameObjects;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace Content.Client.GameObjects.Components.Cargo
|
|
{
|
|
[RegisterComponent]
|
|
public class CargoOrderDatabaseComponent : SharedCargoOrderDatabaseComponent
|
|
{
|
|
private List<CargoOrderData> _orders = new List<CargoOrderData>();
|
|
|
|
public IReadOnlyList<CargoOrderData> Orders => _orders;
|
|
/// <summary>
|
|
/// Event called when the database is updated.
|
|
/// </summary>
|
|
public event Action OnDatabaseUpdated;
|
|
|
|
// TODO add account selector menu
|
|
|
|
/// <summary>
|
|
/// Removes all orders from the database.
|
|
/// </summary>
|
|
public virtual void Clear()
|
|
{
|
|
_orders.Clear();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Adds an order to the database.
|
|
/// </summary>
|
|
/// <param name="order">The order to be added.</param>
|
|
public virtual void AddOrder(CargoOrderData order)
|
|
{
|
|
if (!_orders.Contains(order))
|
|
_orders.Add(order);
|
|
}
|
|
|
|
public override void HandleComponentState(ComponentState curState, ComponentState nextState)
|
|
{
|
|
base.HandleComponentState(curState, nextState);
|
|
if (!(curState is CargoOrderDatabaseState state))
|
|
return;
|
|
Clear();
|
|
if (state.Orders == null)
|
|
return;
|
|
foreach (var order in state.Orders)
|
|
{
|
|
AddOrder(order);
|
|
}
|
|
|
|
OnDatabaseUpdated?.Invoke();
|
|
}
|
|
}
|
|
}
|