Files
tbd-station-14/Content.Shared/Eye/Blinding/SharedBlindingSystem.cs
Rane 83c03b60a1 [2 lines] fix blinding (#9690)
* Adds blinding + blindfolds (#8688)

* Adds blinding + blindfolds

* Don't break examining lol

* moment

* fix toggle lights behavior

* move checks around

* Sloth review

* Added a salvage funny

* review

* woops

* Switch circle shader

Co-authored-by: wrexbe <wrexbe@protonmail.com>

* resolve merge conflict

Co-authored-by: wrexbe <wrexbe@protonmail.com>
2022-07-14 06:58:24 -05:00

41 lines
1.4 KiB
C#

using Content.Shared.Inventory.Events;
using Content.Shared.Inventory;
using Content.Shared.Item;
namespace Content.Shared.Eye.Blinding
{
public sealed class SharedBlindingSystem : EntitySystem
{
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<BlindfoldComponent, GotEquippedEvent>(OnEquipped);
SubscribeLocalEvent<BlindfoldComponent, GotUnequippedEvent>(OnUnequipped);
}
private void OnEquipped(EntityUid uid, BlindfoldComponent component, GotEquippedEvent args)
{
if (!TryComp<SharedItemComponent>(uid, out var clothing) || clothing.SlotFlags == SlotFlags.PREVENTEQUIP) // we live in a society
return;
// Is the clothing in its actual slot?
if (!clothing.SlotFlags.HasFlag(args.SlotFlags))
return;
component.IsActive = true;
if (!TryComp<BlindableComponent>(args.Equipee, out var blindComp))
return;
blindComp.Sources++;
}
private void OnUnequipped(EntityUid uid, BlindfoldComponent component, GotUnequippedEvent args)
{
if (!component.IsActive)
return;
component.IsActive = false;
if (!TryComp<BlindableComponent>(args.Equipee, out var blindComp))
return;
blindComp.Sources--;
}
}
}