* 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>
41 lines
1.4 KiB
C#
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--;
|
|
}
|
|
}
|
|
}
|