Files
OldThink/Content.Server/Cargo/Systems/CargoSystem.cs

65 lines
1.8 KiB
C#
Raw Normal View History

2022-06-23 14:36:47 +10:00
using Content.Server.Cargo.Components;
using Content.Server.Station.Systems;
using Content.Shared.Cargo;
using Content.Shared.Containers.ItemSlots;
2023-03-10 16:41:22 +11:00
using JetBrains.Annotations;
using Robust.Shared.Prototypes;
namespace Content.Server.Cargo.Systems;
public sealed partial class CargoSystem : SharedCargoSystem
{
[Dependency] private readonly IPrototypeManager _protoMan = default!;
[Dependency] private readonly ItemSlotsSystem _slots = default!;
2023-01-10 04:55:59 -05:00
[Dependency] private readonly SharedAudioSystem _audio = default!;
2022-06-23 14:36:47 +10:00
private ISawmill _sawmill = default!;
public override void Initialize()
{
base.Initialize();
2022-06-23 14:36:47 +10:00
_sawmill = Logger.GetSawmill("cargo");
InitializeConsole();
2022-06-23 14:36:47 +10:00
InitializeShuttle();
InitializeTelepad();
2022-06-23 14:36:47 +10:00
SubscribeLocalEvent<StationInitializedEvent>(OnStationInit);
}
public override void Shutdown()
{
base.Shutdown();
ShutdownShuttle();
CleanupShuttle();
2022-06-23 14:36:47 +10:00
}
private void OnStationInit(StationInitializedEvent ev)
{
EnsureComp<StationBankAccountComponent>(ev.Station);
EnsureComp<StationCargoOrderDatabaseComponent>(ev.Station);
}
public override void Update(float frameTime)
{
base.Update(frameTime);
UpdateConsole(frameTime);
UpdateTelepad(frameTime);
}
2023-03-10 16:41:22 +11:00
[PublicAPI]
2023-01-10 04:55:59 -05:00
public void UpdateBankAccount(StationBankAccountComponent component, int balanceAdded)
{
2023-01-10 04:55:59 -05:00
component.Balance += balanceAdded;
2023-03-10 16:41:22 +11:00
// TODO: Code bad
foreach (var comp in EntityQuery<CargoOrderConsoleComponent>())
{
if (!_uiSystem.IsUiOpen(comp.Owner, CargoConsoleUiKey.Orders)) continue;
var station = _station.GetOwningStation(comp.Owner);
if (station != component.Owner)
continue;
UpdateOrderState(comp, station);
}
}
}