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))
|
!TryComp<StationCargoBountyDatabaseComponent>(station, out var bountyDb))
|
||||||
return;
|
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));
|
_uiSystem.SetUiState(uid, CargoConsoleUiKey.Bounty, new CargoBountyConsoleState(bountyDb.Bounties, bountyDb.History, untilNextSkip));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnPrintLabelMessage(EntityUid uid, CargoBountyConsoleComponent component, BountyPrintLabelMessage args)
|
private void OnPrintLabelMessage(EntityUid uid, CargoBountyConsoleComponent component, BountyPrintLabelMessage args)
|
||||||
{
|
{
|
||||||
if (_timing.CurTime < component.NextPrintTime)
|
if (Timing.CurTime < component.NextPrintTime)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (_station.GetOwningStation(uid) is not { } station)
|
if (_station.GetOwningStation(uid) is not { } station)
|
||||||
@@ -71,7 +71,7 @@ public sealed partial class CargoSystem
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
var label = Spawn(component.BountyLabelId, Transform(uid).Coordinates);
|
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);
|
SetupBountyLabel(label, station, bounty.Value);
|
||||||
_audio.PlayPvs(component.PrintSound, uid);
|
_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))
|
if (_station.GetOwningStation(uid) is not { } station || !TryComp<StationCargoBountyDatabaseComponent>(station, out var db))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (_timing.CurTime < db.NextSkipTime)
|
if (Timing.CurTime < db.NextSkipTime)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!TryGetBountyFromId(station, args.BountyId, out var bounty))
|
if (!TryGetBountyFromId(station, args.BountyId, out var bounty))
|
||||||
@@ -101,8 +101,8 @@ public sealed partial class CargoSystem
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
FillBountyDatabase(station);
|
FillBountyDatabase(station);
|
||||||
db.NextSkipTime = _timing.CurTime + db.SkipDelay;
|
db.NextSkipTime = Timing.CurTime + db.SkipDelay;
|
||||||
var untilNextSkip = db.NextSkipTime - _timing.CurTime;
|
var untilNextSkip = db.NextSkipTime - Timing.CurTime;
|
||||||
_uiSystem.SetUiState(uid, CargoConsoleUiKey.Bounty, new CargoBountyConsoleState(db.Bounties, db.History, untilNextSkip));
|
_uiSystem.SetUiState(uid, CargoConsoleUiKey.Bounty, new CargoBountyConsoleState(db.Bounties, db.History, untilNextSkip));
|
||||||
_audio.PlayPvs(component.SkipSound, uid);
|
_audio.PlayPvs(component.SkipSound, uid);
|
||||||
}
|
}
|
||||||
@@ -471,7 +471,7 @@ public sealed partial class CargoSystem
|
|||||||
skipped
|
skipped
|
||||||
? CargoBountyHistoryData.BountyResult.Skipped
|
? CargoBountyHistoryData.BountyResult.Skipped
|
||||||
: CargoBountyHistoryData.BountyResult.Completed,
|
: CargoBountyHistoryData.BountyResult.Completed,
|
||||||
_timing.CurTime,
|
Timing.CurTime,
|
||||||
actorName));
|
actorName));
|
||||||
ent.Comp.Bounties.RemoveAt(i);
|
ent.Comp.Bounties.RemoveAt(i);
|
||||||
return true;
|
return true;
|
||||||
@@ -513,7 +513,7 @@ public sealed partial class CargoSystem
|
|||||||
continue;
|
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));
|
_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)
|
args.Amount > GetBalanceFromAccount((station, bank), ent.Comp.Account) * ent.Comp.TransferLimit)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (_timing.CurTime < ent.Comp.NextAccountActionTime)
|
if (Timing.CurTime < ent.Comp.NextAccountActionTime)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!_accessReaderSystem.IsAllowed(args.Actor, ent))
|
if (!_accessReaderSystem.IsAllowed(args.Actor, ent))
|
||||||
@@ -38,7 +38,7 @@ public sealed partial class CargoSystem
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ent.Comp.NextAccountActionTime = _timing.CurTime + ent.Comp.AccountActionDelay;
|
ent.Comp.NextAccountActionTime = Timing.CurTime + ent.Comp.AccountActionDelay;
|
||||||
Dirty(ent);
|
Dirty(ent);
|
||||||
UpdateBankAccount((station, bank), -args.Amount, CreateAccountDistribution(ent.Comp.Account, bank));
|
UpdateBankAccount((station, bank), -args.Amount, CreateAccountDistribution(ent.Comp.Account, bank));
|
||||||
_audio.PlayPvs(ApproveSound, ent);
|
_audio.PlayPvs(ApproveSound, ent);
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ namespace Content.Server.Cargo.Systems
|
|||||||
var stationQuery = EntityQueryEnumerator<StationBankAccountComponent>();
|
var stationQuery = EntityQueryEnumerator<StationBankAccountComponent>();
|
||||||
while (stationQuery.MoveNext(out var uid, out var bank))
|
while (stationQuery.MoveNext(out var uid, out var bank))
|
||||||
{
|
{
|
||||||
if (_timing.CurTime < bank.NextIncomeTime)
|
if (Timing.CurTime < bank.NextIncomeTime)
|
||||||
continue;
|
continue;
|
||||||
bank.NextIncomeTime += bank.IncomeDelay;
|
bank.NextIncomeTime += bank.IncomeDelay;
|
||||||
|
|
||||||
|
|||||||
@@ -17,14 +17,12 @@ using JetBrains.Annotations;
|
|||||||
using Robust.Server.GameObjects;
|
using Robust.Server.GameObjects;
|
||||||
using Robust.Shared.Audio.Systems;
|
using Robust.Shared.Audio.Systems;
|
||||||
using Robust.Shared.Prototypes;
|
using Robust.Shared.Prototypes;
|
||||||
using Robust.Shared.Timing;
|
|
||||||
using Robust.Shared.Random;
|
using Robust.Shared.Random;
|
||||||
|
|
||||||
namespace Content.Server.Cargo.Systems;
|
namespace Content.Server.Cargo.Systems;
|
||||||
|
|
||||||
public sealed partial class CargoSystem : SharedCargoSystem
|
public sealed partial class CargoSystem : SharedCargoSystem
|
||||||
{
|
{
|
||||||
[Dependency] private readonly IGameTiming _timing = default!;
|
|
||||||
[Dependency] private readonly IPrototypeManager _protoMan = default!;
|
[Dependency] private readonly IPrototypeManager _protoMan = default!;
|
||||||
[Dependency] private readonly IRobustRandom _random = default!;
|
[Dependency] private readonly IRobustRandom _random = default!;
|
||||||
[Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;
|
[Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;
|
||||||
|
|||||||
@@ -3,11 +3,27 @@ using Content.Shared.Cargo.Components;
|
|||||||
using Content.Shared.Cargo.Prototypes;
|
using Content.Shared.Cargo.Prototypes;
|
||||||
using Robust.Shared.Prototypes;
|
using Robust.Shared.Prototypes;
|
||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
|
using Robust.Shared.Timing;
|
||||||
|
|
||||||
namespace Content.Shared.Cargo;
|
namespace Content.Shared.Cargo;
|
||||||
|
|
||||||
public abstract class SharedCargoSystem : EntitySystem
|
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>
|
/// <summary>
|
||||||
/// For a given station, retrieves the balance in a specific account.
|
/// For a given station, retrieves the balance in a specific account.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user