From e1554aca28a9d096e32f8d93057081a1ea6bf9be Mon Sep 17 00:00:00 2001 From: Aviu00 <93730715+Aviu00@users.noreply.github.com> Date: Wed, 7 Feb 2024 19:30:49 +0900 Subject: [PATCH] - fix: Night vision fix. (#33) --- .../_White/Overlays/NightVisionSystem.cs | 15 +++++++++++++-- .../_Miracle/Systems/SharedNightVisionSystem.cs | 6 +++++- 2 files changed, 18 insertions(+), 3 deletions(-) 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; }