[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>
This commit is contained in:
Rane
2022-07-14 07:58:24 -04:00
committed by GitHub
parent ef92c351bf
commit 83c03b60a1
21 changed files with 309 additions and 1 deletions

View File

@@ -0,0 +1,26 @@
using Robust.Shared.GameStates;
namespace Content.Shared.Eye.Blinding
{
[RegisterComponent]
[NetworkedComponent]
public sealed class BlindableComponent : Component
{
/// <description>
/// How many sources of blindness are affecting us?
/// </description>
[DataField("sources")]
public int Sources = 0;
/// <description>
/// Used to ensure that this doesn't break with sandbox or admin tools.
/// This is not "enabled/disabled".
/// </description>
public bool LightSetup = false;
/// <description>
/// Gives an extra frame of blindness to reenable light manager during
/// </description>
public bool GraceFrame = false;
}
}

View File

@@ -0,0 +1,12 @@
using Robust.Shared.GameStates;
namespace Content.Shared.Eye.Blinding
{
[RegisterComponent]
[NetworkedComponent]
public sealed class BlindfoldComponent : Component
{
[ViewVariables]
public bool IsActive = false;
}
}

View File

@@ -0,0 +1,40 @@
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--;
}
}
}