Wire action cleanup (#13496)

This commit is contained in:
Leon Friedrich
2023-01-21 12:51:02 +13:00
committed by GitHub
parent 319cf162fd
commit b20b4b11cc
21 changed files with 294 additions and 627 deletions

View File

@@ -7,75 +7,37 @@ using Content.Shared.Wires;
namespace Content.Server.Doors;
[DataDefinition]
public sealed class DoorSafetyWireAction : BaseWireAction
public sealed class DoorSafetyWireAction : ComponentWireAction<AirlockComponent>
{
[DataField("color")]
private Color _statusColor = Color.Red;
[DataField("name")]
private string _text = "SAFE";
protected override string Text
{
get => _text;
set => _text = value;
}
public override Color Color { get; set; } = Color.Red;
public override string Name { get; set; } = "wire-name-door-safety";
[DataField("timeout")]
private int _timeout = 30;
public override StatusLightData? GetStatusLightData(Wire wire)
{
var lightState = StatusLightState.Off;
if (IsPowered(wire.Owner)
&& EntityManager.TryGetComponent<AirlockComponent>(wire.Owner, out var door))
{
lightState = door.Safety
? StatusLightState.On
: StatusLightState.Off;
}
return new StatusLightData(
_statusColor,
lightState,
_text);
}
public override StatusLightState? GetLightState(Wire wire, AirlockComponent comp)
=> comp.Safety ? StatusLightState.On : StatusLightState.Off;
public override object StatusKey { get; } = AirlockWireStatus.SafetyIndicator;
public override bool Cut(EntityUid user, Wire wire)
public override bool Cut(EntityUid user, Wire wire, AirlockComponent door)
{
base.Cut(user, wire);
if (EntityManager.TryGetComponent<AirlockComponent>(wire.Owner, out var door))
{
WiresSystem.TryCancelWireAction(wire.Owner, PulseTimeoutKey.Key);
EntityManager.System<SharedAirlockSystem>().SetSafety(door, false);
}
WiresSystem.TryCancelWireAction(wire.Owner, PulseTimeoutKey.Key);
EntityManager.System<SharedAirlockSystem>().SetSafety(door, false);
return true;
}
public override bool Mend(EntityUid user, Wire wire)
public override bool Mend(EntityUid user, Wire wire, AirlockComponent door)
{
base.Mend(user, wire);
if (EntityManager.TryGetComponent<AirlockComponent>(wire.Owner, out var door))
{
EntityManager.System<SharedAirlockSystem>().SetSafety(door, true);
}
EntityManager.System<SharedAirlockSystem>().SetSafety(door, true);
return true;
}
public override bool Pulse(EntityUid user, Wire wire)
public override void Pulse(EntityUid user, Wire wire, AirlockComponent door)
{
base.Pulse(user, wire);
if (EntityManager.TryGetComponent<AirlockComponent>(wire.Owner, out var door))
{
EntityManager.System<SharedAirlockSystem>().SetSafety(door, false);
WiresSystem.StartWireAction(wire.Owner, _timeout, PulseTimeoutKey.Key, new TimedWireEvent(AwaitSafetyTimerFinish, wire));
}
return true;
EntityManager.System<SharedAirlockSystem>().SetSafety(door, false);
WiresSystem.StartWireAction(wire.Owner, _timeout, PulseTimeoutKey.Key, new TimedWireEvent(AwaitSafetyTimerFinish, wire));
}
public override void Update(Wire wire)