]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
fix PermanentBlindnessComponent to be not so permanent (#33292)
authorlunarcomets <140772713+lunarcomets@users.noreply.github.com>
Sat, 30 Nov 2024 02:56:52 +0000 (18:56 -0800)
committerGitHub <noreply@github.com>
Sat, 30 Nov 2024 02:56:52 +0000 (13:56 +1100)
* 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 <luanrcomets2@gmail,com>
Content.Shared/Traits/Assorted/PermanentBlindnessSystem.cs

index 6245118466f5896e9c64e50c5dcc3a806490149b..2ab17e2c5e418ec89fcc885a84efac90e4661cdd 100644 (file)
@@ -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!;
 
     /// <inheritdoc/>
@@ -33,20 +32,26 @@ public sealed class PermanentBlindnessSystem : EntitySystem
 
     private void OnShutdown(Entity<PermanentBlindnessComponent> blindness, ref ComponentShutdown args)
     {
-        _blinding.UpdateIsBlind(blindness.Owner);
+        if (!TryComp<BlindableComponent>(blindness.Owner, out var blindable))
+            return;
+
+        if (blindable.MinDamage != 0)
+        {
+            _blinding.SetMinDamage((blindness.Owner, blindable), 0);
+        }
     }
 
     private void OnMapInit(Entity<PermanentBlindnessComponent> blindness, ref MapInitEvent args)
     {
-        if (!_entityManager.TryGetComponent<BlindableComponent>(blindness, out var blindable))
+        if(!TryComp<BlindableComponent>(blindness.Owner, out var blindable))
             return;
 
         if (blindness.Comp.Blindness != 0)
-            _blinding.SetMinDamage(new Entity<BlindableComponent?>(blindness.Owner, blindable), blindness.Comp.Blindness);
+            _blinding.SetMinDamage((blindness.Owner, blindable), blindness.Comp.Blindness);
         else
         {
             var maxMagnitudeInt = (int) BlurryVisionComponent.MaxMagnitude;
-            _blinding.SetMinDamage(new Entity<BlindableComponent?>(blindness.Owner, blindable), maxMagnitudeInt);
+            _blinding.SetMinDamage((blindness.Owner, blindable), maxMagnitudeInt);
         }
     }
 }