From 037feb3ad05092e15113dc1f904109cd3d998027 Mon Sep 17 00:00:00 2001 From: Rane <60792108+Elijahrane@users.noreply.github.com> Date: Tue, 19 Jul 2022 03:10:08 -0400 Subject: [PATCH] Fix blindfold round cleanup bug (#9821) * Blindness public api * fix blinding round cleanup bug --- Content.Client/Eye/Blinding/BlindingSystem.cs | 15 ++++++++++++++ .../Eye/Blinding/SharedBlindingSystem.cs | 20 +++++++++++++++++-- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/Content.Client/Eye/Blinding/BlindingSystem.cs b/Content.Client/Eye/Blinding/BlindingSystem.cs index 842286006b..5c7176dc77 100644 --- a/Content.Client/Eye/Blinding/BlindingSystem.cs +++ b/Content.Client/Eye/Blinding/BlindingSystem.cs @@ -3,6 +3,14 @@ using Content.Shared.Eye.Blinding; using Robust.Client.GameObjects; using Robust.Client.Graphics; using Robust.Client.Player; +using System; +using System.Collections.Generic; +using System.Linq; +using Content.Shared.Administration; +using Content.Shared.Administration.Events; +using Content.Shared.GameTicking; +using Robust.Shared.GameObjects; +using Robust.Shared.Network; namespace Content.Client.Eye.Blinding; @@ -25,6 +33,8 @@ public sealed class BlindingSystem : EntitySystem SubscribeLocalEvent(OnPlayerAttached); SubscribeLocalEvent(OnPlayerDetached); + SubscribeNetworkEvent(RoundRestartCleanup); + _overlay = new(); } @@ -52,4 +62,9 @@ public sealed class BlindingSystem : EntitySystem _overlayMan.RemoveOverlay(_overlay); } } + + private void RoundRestartCleanup(RoundRestartCleanupEvent ev) + { + _lightManager.Enabled = true; + } } diff --git a/Content.Shared/Eye/Blinding/SharedBlindingSystem.cs b/Content.Shared/Eye/Blinding/SharedBlindingSystem.cs index 70a26f8a22..af9c4e0924 100644 --- a/Content.Shared/Eye/Blinding/SharedBlindingSystem.cs +++ b/Content.Shared/Eye/Blinding/SharedBlindingSystem.cs @@ -1,6 +1,7 @@ using Content.Shared.Inventory.Events; using Content.Shared.Inventory; using Content.Shared.Item; +using JetBrains.Annotations; namespace Content.Shared.Eye.Blinding { @@ -24,7 +25,7 @@ namespace Content.Shared.Eye.Blinding component.IsActive = true; if (!TryComp(args.Equipee, out var blindComp)) return; - blindComp.Sources++; + AdjustBlindSources(args.Equipee, true, blindComp); } private void OnUnequipped(EntityUid uid, BlindfoldComponent component, GotUnequippedEvent args) @@ -34,7 +35,22 @@ namespace Content.Shared.Eye.Blinding component.IsActive = false; if (!TryComp(args.Equipee, out var blindComp)) return; - blindComp.Sources--; + AdjustBlindSources(args.Equipee, false, blindComp); + } + + [PublicAPI] + public void AdjustBlindSources(EntityUid uid, bool Add, BlindableComponent? blindable = null) + { + if (!Resolve(uid, ref blindable, false)) + return; + + if (Add) + { + blindable.Sources++; + } else + { + blindable.Sources--; + } } } }