diff --git a/Content.Client/_White/Overlays/NightVisionSystem.cs b/Content.Client/_White/Overlays/NightVisionSystem.cs index 57fde51804..4da1d57626 100644 --- a/Content.Client/_White/Overlays/NightVisionSystem.cs +++ b/Content.Client/_White/Overlays/NightVisionSystem.cs @@ -28,12 +28,18 @@ public sealed class NightVisionSystem : SharedNightVisionSystem private void OnPlayerAttached(EntityUid uid, NightVisionComponent component, PlayerAttachedEvent args) { - UpdateNightVision(uid, component.IsActive); + if (_player.LocalSession != args.Player) + return; + + UpdateNightVision(component.IsActive); } private void OnPlayerDetached(EntityUid uid, NightVisionComponent component, PlayerDetachedEvent args) { - UpdateNightVision(uid, false); + if (_player.LocalSession != args.Player) + return; + + UpdateNightVision(false); } protected override void UpdateNightVision(EntityUid uid, bool active) @@ -41,6 +47,11 @@ public sealed class NightVisionSystem : SharedNightVisionSystem if (_player.LocalSession?.AttachedEntity != uid) return; + UpdateNightVision(active); + } + + private void UpdateNightVision(bool active) + { if (active) _overlayMan.AddOverlay(_overlay); else diff --git a/Content.Shared/_Miracle/Systems/SharedNightVisionSystem.cs b/Content.Shared/_Miracle/Systems/SharedNightVisionSystem.cs index 860fe42c3a..2354f17dd9 100644 --- a/Content.Shared/_Miracle/Systems/SharedNightVisionSystem.cs +++ b/Content.Shared/_Miracle/Systems/SharedNightVisionSystem.cs @@ -1,6 +1,7 @@ using Content.Shared._White.Overlays; using Content.Shared.Actions; using Robust.Shared.Audio.Systems; +using Robust.Shared.Timing; namespace Content.Shared._Miracle.Systems; @@ -8,6 +9,7 @@ public abstract class SharedNightVisionSystem : EntitySystem { [Dependency] private readonly SharedAudioSystem _audio = default!; [Dependency] private readonly SharedActionsSystem _actions = default!; + [Dependency] private readonly IGameTiming _timing = default!; public override void Initialize() { @@ -34,10 +36,12 @@ public abstract class SharedNightVisionSystem : EntitySystem private void OnToggle(EntityUid uid, NightVisionComponent component, ToggleNightVisionEvent args) { + if (!_timing.IsFirstTimePredicted) + return; + component.IsActive = !component.IsActive; _audio.PlayPredicted(component.ToggleSound, uid, uid); UpdateNightVision(uid, component.IsActive); - Dirty(uid, component); args.Handled = true; }