using Content.Shared.Cargo.Components; using Content.Shared.Cargo.Prototypes; using Robust.Shared.Prototypes; using Robust.Shared.Serialization; using Robust.Shared.Timing; using Robust.Shared.Utility; namespace Content.Shared.Cargo; public abstract class SharedCargoSystem : EntitySystem { [Dependency] protected readonly IGameTiming Timing = default!; public override void Initialize() { base.Initialize(); SubscribeLocalEvent(OnMapInit); } private void OnMapInit(Entity ent, ref MapInitEvent args) { ent.Comp.NextIncomeTime = Timing.CurTime + ent.Comp.IncomeDelay; Dirty(ent); } /// /// For a given station, retrieves the balance in a specific account. /// public int GetBalanceFromAccount(Entity station, ProtoId account) { if (!Resolve(station, ref station.Comp)) return 0; return station.Comp.Accounts.GetValueOrDefault(account); } /// /// For a station, creates a distribution between one the bank's account and the other accounts. /// The primary account receives the majority percentage listed on the bank account, with the remaining /// funds distributed to all accounts based on /// public Dictionary, double> CreateAccountDistribution(Entity stationBank) { var distribution = new Dictionary, double> { { stationBank.Comp.PrimaryAccount, stationBank.Comp.PrimaryCut } }; var remaining = 1.0 - stationBank.Comp.PrimaryCut; foreach (var (account, percentage) in stationBank.Comp.RevenueDistribution) { var existing = distribution.GetOrNew(account); distribution[account] = existing + remaining * percentage; } return distribution; } } [NetSerializable, Serializable] public enum CargoConsoleUiKey : byte { Orders, Bounty, Shuttle, Telepad } [NetSerializable, Serializable] public enum CargoPalletConsoleUiKey : byte { Sale } [Serializable, NetSerializable] public enum CargoTelepadState : byte { Unpowered, Idle, Teleporting, }; [Serializable, NetSerializable] public enum CargoTelepadVisuals : byte { State, };