From 6f76ae4720226efc9e2ed85683b95062e03cc079 Mon Sep 17 00:00:00 2001 From: Leon Friedrich <60421075+ElectroJr@users.noreply.github.com> Date: Mon, 26 Jun 2023 08:36:35 +1200 Subject: [PATCH] Try fix time offset serialization issues (#17580) --- Content.Server/CardboardBox/CardboardBoxSystem.cs | 4 ++-- .../Anomaly/Components/AnomalyPulsingComponent.cs | 2 +- .../Components/AnomalySupercriticalComponent.cs | 2 +- .../Components/CardboardBoxComponent.cs | 14 ++++++-------- .../Components/EmitSoundOnCollideComponent.cs | 2 +- 5 files changed, 11 insertions(+), 13 deletions(-) diff --git a/Content.Server/CardboardBox/CardboardBoxSystem.cs b/Content.Server/CardboardBox/CardboardBoxSystem.cs index c199c2473a..b3f2aa561c 100644 --- a/Content.Server/CardboardBox/CardboardBoxSystem.cs +++ b/Content.Server/CardboardBox/CardboardBoxSystem.cs @@ -38,7 +38,7 @@ public sealed class CardboardBoxSystem : SharedCardboardBoxSystem SubscribeLocalEvent(OnDamage); } - + private void OnInteracted(EntityUid uid, CardboardBoxComponent component, ActivateInWorldEvent args) { if (!TryComp(uid, out var box)) @@ -75,7 +75,7 @@ public sealed class CardboardBoxSystem : SharedCardboardBoxSystem { RaiseNetworkEvent(new PlayBoxEffectMessage(uid, component.Mover.Value)); _audio.PlayPvs(component.EffectSound, uid); - component.EffectCooldown = _timing.CurTime + CardboardBoxComponent.MaxEffectCooldown; + component.EffectCooldown = _timing.CurTime + component.CooldownDuration; } } } diff --git a/Content.Shared/Anomaly/Components/AnomalyPulsingComponent.cs b/Content.Shared/Anomaly/Components/AnomalyPulsingComponent.cs index 7321a279fd..0420ffac0a 100644 --- a/Content.Shared/Anomaly/Components/AnomalyPulsingComponent.cs +++ b/Content.Shared/Anomaly/Components/AnomalyPulsingComponent.cs @@ -12,7 +12,7 @@ public sealed class AnomalyPulsingComponent : Component /// The time at which the pulse will be over. /// [DataField("endTime", customTypeSerializer: typeof(TimeOffsetSerializer)), ViewVariables(VVAccess.ReadWrite)] - public TimeSpan EndTime = TimeSpan.MaxValue; + public TimeSpan EndTime; /// /// How long the pulse visual lasts diff --git a/Content.Shared/Anomaly/Components/AnomalySupercriticalComponent.cs b/Content.Shared/Anomaly/Components/AnomalySupercriticalComponent.cs index 14751d726c..b02a7a4333 100644 --- a/Content.Shared/Anomaly/Components/AnomalySupercriticalComponent.cs +++ b/Content.Shared/Anomaly/Components/AnomalySupercriticalComponent.cs @@ -14,7 +14,7 @@ public sealed class AnomalySupercriticalComponent : Component /// The time when the supercritical animation ends and it does whatever effect. /// [DataField("endTime", customTypeSerializer: typeof(TimeOffsetSerializer)), ViewVariables(VVAccess.ReadWrite)] - public TimeSpan EndTime = TimeSpan.MaxValue; + public TimeSpan EndTime; /// /// The length of the animation before it goes supercritical. diff --git a/Content.Shared/CardboardBox/Components/CardboardBoxComponent.cs b/Content.Shared/CardboardBox/Components/CardboardBoxComponent.cs index 33db21593e..0da44dab3c 100644 --- a/Content.Shared/CardboardBox/Components/CardboardBoxComponent.cs +++ b/Content.Shared/CardboardBox/Components/CardboardBoxComponent.cs @@ -30,7 +30,7 @@ public sealed class CardboardBoxComponent : Component [ViewVariables(VVAccess.ReadWrite)] [DataField("effectSound")] public SoundSpecifier? EffectSound; - + /// /// Whether to prevent the box from making the sound and effect /// @@ -46,18 +46,16 @@ public sealed class CardboardBoxComponent : Component public float Distance = 6f; /// - /// Current time + max effect cooldown to check to see if effect can play again - /// Prevents effect spam + /// Time at which the sound effect can next be played. /// [DataField("effectCooldown", customTypeSerializer: typeof(TimeOffsetSerializer))] - public TimeSpan EffectCooldown = TimeSpan.FromSeconds(1f); + public TimeSpan EffectCooldown; /// - /// How much time should pass + current time until the effect plays again - /// Prevents effect spam + /// Time between sound effects. Prevents effect spam /// - [DataField("maxEffectCooldown", customTypeSerializer: typeof(TimeOffsetSerializer))] - public static readonly TimeSpan MaxEffectCooldown = TimeSpan.FromSeconds(5f); + [DataField("cooldownDuration")] + public readonly TimeSpan CooldownDuration = TimeSpan.FromSeconds(5f); } [Serializable, NetSerializable] diff --git a/Content.Shared/Sound/Components/EmitSoundOnCollideComponent.cs b/Content.Shared/Sound/Components/EmitSoundOnCollideComponent.cs index d582fc0fa3..cc9896d4da 100644 --- a/Content.Shared/Sound/Components/EmitSoundOnCollideComponent.cs +++ b/Content.Shared/Sound/Components/EmitSoundOnCollideComponent.cs @@ -18,5 +18,5 @@ public sealed class EmitSoundOnCollideComponent : BaseEmitSoundComponent /// To avoid sound spam add a cooldown to it. /// [ViewVariables(VVAccess.ReadWrite), DataField("nextSound", customTypeSerializer: typeof(TimeOffsetSerializer))] - public TimeSpan NextSound = TimeSpan.FromSeconds(0.2); + public TimeSpan NextSound; }