* The all-in-one hacking solution The thinking man's lockpick The iconic EMAG * emagged medbay's stasis bed * left med, emagged sec' apc * went back to chem, emagged the dispenser * emagged the fax while i was there * had a donut while waiting for emag to charge * i broke into the bridge then announced 'mandatory johnson inspection in medical' * get system instead of dependency * feedback * net suggestion Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> * use EnsureComp and import NetworkedComponent --------- Co-authored-by: deltanedas <user@zenith> Co-authored-by: deltanedas <deltanedas@laptop> Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
68 lines
2.1 KiB
C#
68 lines
2.1 KiB
C#
using Content.Server.Wires;
|
|
using Content.Shared.Access;
|
|
using Content.Shared.Access.Components;
|
|
using Content.Shared.Emag.Components;
|
|
using Content.Shared.Wires;
|
|
|
|
namespace Content.Server.Access;
|
|
|
|
public sealed class AccessWireAction : ComponentWireAction<AccessReaderComponent>
|
|
{
|
|
public override Color Color { get; set; } = Color.Green;
|
|
public override string Name { get; set; } = "wire-name-access";
|
|
|
|
[DataField("pulseTimeout")]
|
|
private int _pulseTimeout = 30;
|
|
|
|
public override StatusLightState? GetLightState(Wire wire, AccessReaderComponent comp)
|
|
{
|
|
return EntityManager.HasComponent<EmaggedComponent>(comp.Owner) ? StatusLightState.On : StatusLightState.Off;
|
|
}
|
|
|
|
public override object StatusKey { get; } = AccessWireActionKey.Status;
|
|
|
|
public override bool Cut(EntityUid user, Wire wire, AccessReaderComponent comp)
|
|
{
|
|
WiresSystem.TryCancelWireAction(wire.Owner, PulseTimeoutKey.Key);
|
|
EntityManager.RemoveComponent<EmaggedComponent>(comp.Owner);
|
|
return true;
|
|
}
|
|
|
|
public override bool Mend(EntityUid user, Wire wire, AccessReaderComponent comp)
|
|
{
|
|
EntityManager.AddComponent<EmaggedComponent>(comp.Owner);
|
|
return true;
|
|
}
|
|
|
|
public override void Pulse(EntityUid user, Wire wire, AccessReaderComponent comp)
|
|
{
|
|
EntityManager.RemoveComponent<EmaggedComponent>(comp.Owner);
|
|
WiresSystem.StartWireAction(wire.Owner, _pulseTimeout, PulseTimeoutKey.Key, new TimedWireEvent(AwaitPulseCancel, wire));
|
|
}
|
|
|
|
public override void Update(Wire wire)
|
|
{
|
|
if (!IsPowered(wire.Owner))
|
|
{
|
|
WiresSystem.TryCancelWireAction(wire.Owner, PulseTimeoutKey.Key);
|
|
}
|
|
}
|
|
|
|
private void AwaitPulseCancel(Wire wire)
|
|
{
|
|
if (!wire.IsCut)
|
|
{
|
|
// check is still here incase you somehow TOCTOU it into unemagging something it shouldn't
|
|
if (EntityManager.TryGetComponent<AccessReaderComponent>(wire.Owner, out var access))
|
|
{
|
|
EntityManager.RemoveComponent<EmaggedComponent>(wire.Owner);
|
|
}
|
|
}
|
|
}
|
|
|
|
private enum PulseTimeoutKey : byte
|
|
{
|
|
Key
|
|
}
|
|
}
|