* The easy ones * For certain values of easy * Easy test * Hair * Fix sandbox violations * Sort usings
38 lines
1.3 KiB
C#
38 lines
1.3 KiB
C#
using Content.Shared.Eye.Blinding.Components;
|
|
using Content.Shared.StatusEffect;
|
|
using Robust.Shared.Prototypes;
|
|
|
|
namespace Content.Shared.Eye.Blinding.Systems;
|
|
|
|
public sealed class TemporaryBlindnessSystem : EntitySystem
|
|
{
|
|
public static readonly ProtoId<StatusEffectPrototype> BlindingStatusEffect = "TemporaryBlindness";
|
|
|
|
[Dependency] private readonly BlindableSystem _blindableSystem = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<TemporaryBlindnessComponent, ComponentStartup>(OnStartup);
|
|
SubscribeLocalEvent<TemporaryBlindnessComponent, ComponentShutdown>(OnShutdown);
|
|
SubscribeLocalEvent<TemporaryBlindnessComponent, CanSeeAttemptEvent>(OnBlindTrySee);
|
|
}
|
|
|
|
private void OnStartup(EntityUid uid, TemporaryBlindnessComponent component, ComponentStartup args)
|
|
{
|
|
_blindableSystem.UpdateIsBlind(uid);
|
|
}
|
|
|
|
private void OnShutdown(EntityUid uid, TemporaryBlindnessComponent component, ComponentShutdown args)
|
|
{
|
|
_blindableSystem.UpdateIsBlind(uid);
|
|
}
|
|
|
|
private void OnBlindTrySee(EntityUid uid, TemporaryBlindnessComponent component, CanSeeAttemptEvent args)
|
|
{
|
|
if (component.LifeStage <= ComponentLifeStage.Running)
|
|
args.Cancel();
|
|
}
|
|
}
|