From b45c9d5129e35dd978148f8da07997afc7ce5276 Mon Sep 17 00:00:00 2001 From: lunarcomets <140772713+lunarcomets@users.noreply.github.com> Date: Fri, 29 Nov 2024 18:56:52 -0800 Subject: [PATCH] fix PermanentBlindnessComponent to be not so permanent (#33292) * adjust min blindness back to 0 when PermanentBlindnessComponent is removed * mapinit changes * remove OnRemove, move changes to OnShutdown * goodbye event * dependency removal * final adjustment --------- Co-authored-by: lunarcomets --- .../Traits/Assorted/PermanentBlindnessSystem.cs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Content.Shared/Traits/Assorted/PermanentBlindnessSystem.cs b/Content.Shared/Traits/Assorted/PermanentBlindnessSystem.cs index 6245118466f589..2ab17e2c5e418e 100644 --- a/Content.Shared/Traits/Assorted/PermanentBlindnessSystem.cs +++ b/Content.Shared/Traits/Assorted/PermanentBlindnessSystem.cs @@ -12,7 +12,6 @@ namespace Content.Shared.Traits.Assorted; public sealed class PermanentBlindnessSystem : EntitySystem { [Dependency] private readonly INetManager _net = default!; - [Dependency] private readonly IEntityManager _entityManager = default!; [Dependency] private readonly BlindableSystem _blinding = default!; /// @@ -33,20 +32,26 @@ private void OnExamined(Entity blindness, ref Exami private void OnShutdown(Entity blindness, ref ComponentShutdown args) { - _blinding.UpdateIsBlind(blindness.Owner); + if (!TryComp(blindness.Owner, out var blindable)) + return; + + if (blindable.MinDamage != 0) + { + _blinding.SetMinDamage((blindness.Owner, blindable), 0); + } } private void OnMapInit(Entity blindness, ref MapInitEvent args) { - if (!_entityManager.TryGetComponent(blindness, out var blindable)) + if(!TryComp(blindness.Owner, out var blindable)) return; if (blindness.Comp.Blindness != 0) - _blinding.SetMinDamage(new Entity(blindness.Owner, blindable), blindness.Comp.Blindness); + _blinding.SetMinDamage((blindness.Owner, blindable), blindness.Comp.Blindness); else { var maxMagnitudeInt = (int) BlurryVisionComponent.MaxMagnitude; - _blinding.SetMinDamage(new Entity(blindness.Owner, blindable), maxMagnitudeInt); + _blinding.SetMinDamage((blindness.Owner, blindable), maxMagnitudeInt); } } }