Fix station income instantly accumulating roundstart (#36572)
Fix station money accumulating roundstart
This commit is contained in:
@@ -55,13 +55,13 @@ public sealed partial class CargoSystem
|
||||
!TryComp<StationCargoBountyDatabaseComponent>(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<StationCargoBountyDatabaseComponent>(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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -78,7 +78,7 @@ namespace Content.Server.Cargo.Systems
|
||||
var stationQuery = EntityQueryEnumerator<StationBankAccountComponent>();
|
||||
while (stationQuery.MoveNext(out var uid, out var bank))
|
||||
{
|
||||
if (_timing.CurTime < bank.NextIncomeTime)
|
||||
if (Timing.CurTime < bank.NextIncomeTime)
|
||||
continue;
|
||||
bank.NextIncomeTime += bank.IncomeDelay;
|
||||
|
||||
|
||||
@@ -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!;
|
||||
|
||||
@@ -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<StationBankAccountComponent, MapInitEvent>(OnMapInit);
|
||||
}
|
||||
|
||||
private void OnMapInit(Entity<StationBankAccountComponent> ent, ref MapInitEvent args)
|
||||
{
|
||||
ent.Comp.NextIncomeTime = Timing.CurTime + ent.Comp.IncomeDelay;
|
||||
Dirty(ent);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// For a given station, retrieves the balance in a specific account.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user