diff --git a/Content.Server/Singularity/EntitySystems/EventHorizonSystem.cs b/Content.Server/Singularity/EntitySystems/EventHorizonSystem.cs index 312ac5739d..cca68ccc5e 100644 --- a/Content.Server/Singularity/EntitySystems/EventHorizonSystem.cs +++ b/Content.Server/Singularity/EntitySystems/EventHorizonSystem.cs @@ -40,6 +40,8 @@ public sealed class EventHorizonSystem : SharedEventHorizonSystem SubscribeLocalEvent(PreventConsume); SubscribeLocalEvent(PreventConsume); SubscribeLocalEvent(PreventConsume); + SubscribeLocalEvent(OnHorizonMapInit); + SubscribeLocalEvent(OnHorizonUnpaused); SubscribeLocalEvent(OnStartCollide); SubscribeLocalEvent(OnEventHorizonContained); SubscribeLocalEvent(OnEventHorizonContained); @@ -51,6 +53,16 @@ public sealed class EventHorizonSystem : SharedEventHorizonSystem vvHandle.AddPath(nameof(EventHorizonComponent.TargetConsumePeriod), (_, comp) => comp.TargetConsumePeriod, SetConsumePeriod); } + private void OnHorizonMapInit(EntityUid uid, EventHorizonComponent component, MapInitEvent args) + { + component.NextConsumeWaveTime = _timing.CurTime; + } + + private void OnHorizonUnpaused(EntityUid uid, EventHorizonComponent component, ref EntityUnpausedEvent args) + { + component.NextConsumeWaveTime += args.PausedTime; + } + public override void Shutdown() { var vvHandle = Vvm.GetTypeHandler(); @@ -82,10 +94,10 @@ public sealed class EventHorizonSystem : SharedEventHorizonSystem if (!Resolve(uid, ref eventHorizon)) return; - eventHorizon.LastConsumeWaveTime = _timing.CurTime; - eventHorizon.NextConsumeWaveTime = eventHorizon.LastConsumeWaveTime + eventHorizon.TargetConsumePeriod; + eventHorizon.NextConsumeWaveTime += eventHorizon.TargetConsumePeriod; if (eventHorizon.BeingConsumedByAnotherEventHorizon) return; + if (!Resolve(uid, ref xform)) return; @@ -331,8 +343,9 @@ public sealed class EventHorizonSystem : SharedEventHorizonSystem if (MathHelper.CloseTo(eventHorizon.TargetConsumePeriod.TotalSeconds, value.TotalSeconds)) return; + var diff = (value - eventHorizon.TargetConsumePeriod); eventHorizon.TargetConsumePeriod = value; - eventHorizon.NextConsumeWaveTime = eventHorizon.LastConsumeWaveTime + eventHorizon.TargetConsumePeriod; + eventHorizon.NextConsumeWaveTime += diff; var curTime = _timing.CurTime; if (eventHorizon.NextConsumeWaveTime < curTime) diff --git a/Content.Shared/Singularity/Components/EventHorizonComponent.cs b/Content.Shared/Singularity/Components/EventHorizonComponent.cs index ce4f263077..d0febda789 100644 --- a/Content.Shared/Singularity/Components/EventHorizonComponent.cs +++ b/Content.Shared/Singularity/Components/EventHorizonComponent.cs @@ -1,5 +1,6 @@ using Robust.Shared.GameStates; using Content.Shared.Singularity.EntitySystems; +using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom; namespace Content.Shared.Singularity.Components; @@ -59,19 +60,13 @@ public sealed class EventHorizonComponent : Component /// [DataField("consumePeriod")] [ViewVariables(VVAccess.ReadWrite)] - public TimeSpan TargetConsumePeriod { get; set; } = TimeSpan.FromSeconds(0.5); - - /// - /// The last time at which this consumed everything it overlapped with. - /// - [ViewVariables(VVAccess.ReadOnly)] - public TimeSpan LastConsumeWaveTime { get; set; } = default!; + public TimeSpan TargetConsumePeriod = TimeSpan.FromSeconds(0.5); /// /// The next time at which this consumed everything it overlapped with. /// - [ViewVariables(VVAccess.ReadOnly)] - public TimeSpan NextConsumeWaveTime { get; set; } = default!; + [ViewVariables(VVAccess.ReadOnly), DataField("nextConsumeWaveTime", customTypeSerializer:typeof(TimeOffsetSerializer))] + public TimeSpan NextConsumeWaveTime; #endregion Update Timing }