Fix blindness and UIs (#12326)

* fix part 1

* fix blindness and BUIs

* remove extra file
This commit is contained in:
Rane
2022-11-08 16:10:13 -05:00
committed by GitHub
parent 0b3038e1f6
commit 20032b5ecc
5 changed files with 96 additions and 0 deletions

View File

@@ -103,9 +103,21 @@ namespace Content.Shared.Eye.Blinding
if (!Resolve(uid, ref blindable, false))
return;
var oldSources = blindable.Sources;
blindable.Sources += amount;
blindable.Sources = Math.Max(blindable.Sources, 0);
if (oldSources == 0 && blindable.Sources > 0)
{
var ev = new BlindnessChangedEvent(true);
RaiseLocalEvent(uid, ev, false);
} else if (blindable.Sources == 0 && oldSources > 0)
{
var ev = new BlindnessChangedEvent(false);
RaiseLocalEvent(uid, ev, false);
}
Dirty(blindable);
}
@@ -152,4 +164,17 @@ namespace Content.Shared.Eye.Blinding
Magnitude = magnitude;
}
}
/// <summary>
/// You became blind or lost blindess, not just changed # of sources.
/// </summary>
public sealed class BlindnessChangedEvent : EntityEventArgs
{
public bool Blind;
public BlindnessChangedEvent(bool blind)
{
Blind = blind;
}
}
}