Make advertise system survive no map inits (#26553)
* Make advertise system survive no map inits * Add comment to try prevent future bugs
This commit is contained in:
@@ -23,7 +23,7 @@ public sealed class AdvertiseSystem : EntitySystem
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The next time the game will check if advertisements should be displayed
|
/// The next time the game will check if advertisements should be displayed
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private TimeSpan _nextCheckTime = TimeSpan.MaxValue;
|
private TimeSpan _nextCheckTime = TimeSpan.MinValue;
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
@@ -33,8 +33,8 @@ public sealed class AdvertiseSystem : EntitySystem
|
|||||||
SubscribeLocalEvent<ApcPowerReceiverComponent, AdvertiseEnableChangeAttemptEvent>(OnPowerReceiverEnableChangeAttempt);
|
SubscribeLocalEvent<ApcPowerReceiverComponent, AdvertiseEnableChangeAttemptEvent>(OnPowerReceiverEnableChangeAttempt);
|
||||||
SubscribeLocalEvent<VendingMachineComponent, AdvertiseEnableChangeAttemptEvent>(OnVendingEnableChangeAttempt);
|
SubscribeLocalEvent<VendingMachineComponent, AdvertiseEnableChangeAttemptEvent>(OnVendingEnableChangeAttempt);
|
||||||
|
|
||||||
// The component inits will lower this.
|
// Force it to check on the next update.
|
||||||
_nextCheckTime = TimeSpan.MaxValue;
|
_nextCheckTime = TimeSpan.MinValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnMapInit(EntityUid uid, AdvertiseComponent advertise, MapInitEvent args)
|
private void OnMapInit(EntityUid uid, AdvertiseComponent advertise, MapInitEvent args)
|
||||||
@@ -110,6 +110,8 @@ public sealed class AdvertiseSystem : EntitySystem
|
|||||||
if (_nextCheckTime > curTime)
|
if (_nextCheckTime > curTime)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// Note that as _nextCheckTime currently starts at TimeSpan.MinValue, so this has to SET the value, not just
|
||||||
|
// increment it.
|
||||||
_nextCheckTime = curTime + _maximumNextCheckDuration;
|
_nextCheckTime = curTime + _maximumNextCheckDuration;
|
||||||
|
|
||||||
var query = EntityQueryEnumerator<AdvertiseComponent>();
|
var query = EntityQueryEnumerator<AdvertiseComponent>();
|
||||||
|
|||||||
Reference in New Issue
Block a user