diff --git a/Content.Server/Cargo/Systems/CargoSystem.Bounty.cs b/Content.Server/Cargo/Systems/CargoSystem.Bounty.cs index 9a6acbc6ef..10e8b40e53 100644 --- a/Content.Server/Cargo/Systems/CargoSystem.Bounty.cs +++ b/Content.Server/Cargo/Systems/CargoSystem.Bounty.cs @@ -55,13 +55,13 @@ public sealed partial class CargoSystem !TryComp(station, out var bountyDb)) return; - var untilNextSkip = bountyDb.NextSkipTime - _timing.CurTime; + var untilNextSkip = bountyDb.NextSkipTime - Timing.CurTime; _uiSystem.SetUiState(uid, CargoConsoleUiKey.Bounty, new CargoBountyConsoleState(bountyDb.Bounties, bountyDb.History, untilNextSkip)); } private void OnPrintLabelMessage(EntityUid uid, CargoBountyConsoleComponent component, BountyPrintLabelMessage args) { - if (_timing.CurTime < component.NextPrintTime) + if (Timing.CurTime < component.NextPrintTime) return; if (_station.GetOwningStation(uid) is not { } station) @@ -71,7 +71,7 @@ public sealed partial class CargoSystem return; var label = Spawn(component.BountyLabelId, Transform(uid).Coordinates); - component.NextPrintTime = _timing.CurTime + component.PrintDelay; + component.NextPrintTime = Timing.CurTime + component.PrintDelay; SetupBountyLabel(label, station, bounty.Value); _audio.PlayPvs(component.PrintSound, uid); } @@ -81,7 +81,7 @@ public sealed partial class CargoSystem if (_station.GetOwningStation(uid) is not { } station || !TryComp(station, out var db)) return; - if (_timing.CurTime < db.NextSkipTime) + if (Timing.CurTime < db.NextSkipTime) return; if (!TryGetBountyFromId(station, args.BountyId, out var bounty)) @@ -101,8 +101,8 @@ public sealed partial class CargoSystem return; FillBountyDatabase(station); - db.NextSkipTime = _timing.CurTime + db.SkipDelay; - var untilNextSkip = db.NextSkipTime - _timing.CurTime; + db.NextSkipTime = Timing.CurTime + db.SkipDelay; + var untilNextSkip = db.NextSkipTime - Timing.CurTime; _uiSystem.SetUiState(uid, CargoConsoleUiKey.Bounty, new CargoBountyConsoleState(db.Bounties, db.History, untilNextSkip)); _audio.PlayPvs(component.SkipSound, uid); } @@ -471,7 +471,7 @@ public sealed partial class CargoSystem skipped ? CargoBountyHistoryData.BountyResult.Skipped : CargoBountyHistoryData.BountyResult.Completed, - _timing.CurTime, + Timing.CurTime, actorName)); ent.Comp.Bounties.RemoveAt(i); return true; @@ -513,7 +513,7 @@ public sealed partial class CargoSystem continue; } - var untilNextSkip = db.NextSkipTime - _timing.CurTime; + var untilNextSkip = db.NextSkipTime - Timing.CurTime; _uiSystem.SetUiState((uid, ui), CargoConsoleUiKey.Bounty, new CargoBountyConsoleState(db.Bounties, db.History, untilNextSkip)); } } diff --git a/Content.Server/Cargo/Systems/CargoSystem.Funds.cs b/Content.Server/Cargo/Systems/CargoSystem.Funds.cs index f167697e72..7990fbce1c 100644 --- a/Content.Server/Cargo/Systems/CargoSystem.Funds.cs +++ b/Content.Server/Cargo/Systems/CargoSystem.Funds.cs @@ -28,7 +28,7 @@ public sealed partial class CargoSystem args.Amount > GetBalanceFromAccount((station, bank), ent.Comp.Account) * ent.Comp.TransferLimit) return; - if (_timing.CurTime < ent.Comp.NextAccountActionTime) + if (Timing.CurTime < ent.Comp.NextAccountActionTime) return; if (!_accessReaderSystem.IsAllowed(args.Actor, ent)) @@ -38,7 +38,7 @@ public sealed partial class CargoSystem return; } - ent.Comp.NextAccountActionTime = _timing.CurTime + ent.Comp.AccountActionDelay; + ent.Comp.NextAccountActionTime = Timing.CurTime + ent.Comp.AccountActionDelay; Dirty(ent); UpdateBankAccount((station, bank), -args.Amount, CreateAccountDistribution(ent.Comp.Account, bank)); _audio.PlayPvs(ApproveSound, ent); diff --git a/Content.Server/Cargo/Systems/CargoSystem.Orders.cs b/Content.Server/Cargo/Systems/CargoSystem.Orders.cs index 39b3f144ff..ef9a601a89 100644 --- a/Content.Server/Cargo/Systems/CargoSystem.Orders.cs +++ b/Content.Server/Cargo/Systems/CargoSystem.Orders.cs @@ -78,7 +78,7 @@ namespace Content.Server.Cargo.Systems var stationQuery = EntityQueryEnumerator(); while (stationQuery.MoveNext(out var uid, out var bank)) { - if (_timing.CurTime < bank.NextIncomeTime) + if (Timing.CurTime < bank.NextIncomeTime) continue; bank.NextIncomeTime += bank.IncomeDelay; diff --git a/Content.Server/Cargo/Systems/CargoSystem.cs b/Content.Server/Cargo/Systems/CargoSystem.cs index 450f292c9d..646625d5d8 100644 --- a/Content.Server/Cargo/Systems/CargoSystem.cs +++ b/Content.Server/Cargo/Systems/CargoSystem.cs @@ -17,14 +17,12 @@ using JetBrains.Annotations; using Robust.Server.GameObjects; using Robust.Shared.Audio.Systems; using Robust.Shared.Prototypes; -using Robust.Shared.Timing; using Robust.Shared.Random; namespace Content.Server.Cargo.Systems; public sealed partial class CargoSystem : SharedCargoSystem { - [Dependency] private readonly IGameTiming _timing = default!; [Dependency] private readonly IPrototypeManager _protoMan = default!; [Dependency] private readonly IRobustRandom _random = default!; [Dependency] private readonly ISharedAdminLogManager _adminLogger = default!; diff --git a/Content.Shared/Cargo/SharedCargoSystem.cs b/Content.Shared/Cargo/SharedCargoSystem.cs index e2ef234860..8f76f77888 100644 --- a/Content.Shared/Cargo/SharedCargoSystem.cs +++ b/Content.Shared/Cargo/SharedCargoSystem.cs @@ -3,11 +3,27 @@ using Content.Shared.Cargo.Components; using Content.Shared.Cargo.Prototypes; using Robust.Shared.Prototypes; using Robust.Shared.Serialization; +using Robust.Shared.Timing; 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. ///