Wire action cleanup (#13496)
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
using Content.Server.Doors.Components;
|
||||
using Content.Server.Doors.Systems;
|
||||
using Content.Server.Wires;
|
||||
using Content.Shared.Doors;
|
||||
@@ -7,68 +6,31 @@ using Content.Shared.Wires;
|
||||
|
||||
namespace Content.Server.Doors;
|
||||
|
||||
[DataDefinition]
|
||||
public sealed class DoorBoltLightWireAction : BaseWireAction
|
||||
public sealed class DoorBoltLightWireAction : ComponentWireAction<AirlockComponent>
|
||||
{
|
||||
[DataField("color")]
|
||||
private Color _statusColor = Color.Lime;
|
||||
public override Color Color { get; set; } = Color.Lime;
|
||||
public override string Name { get; set; } = "wire-name-bolt-light";
|
||||
|
||||
[DataField("name")]
|
||||
private string _text = "BLIT";
|
||||
protected override string Text
|
||||
{
|
||||
get => _text;
|
||||
set => _text = value;
|
||||
}
|
||||
|
||||
public override StatusLightData? GetStatusLightData(Wire wire)
|
||||
{
|
||||
var lightState = StatusLightState.Off;
|
||||
if (IsPowered(wire.Owner) && EntityManager.TryGetComponent<AirlockComponent>(wire.Owner, out var door))
|
||||
{
|
||||
lightState = door.BoltLightsEnabled
|
||||
? StatusLightState.On
|
||||
: StatusLightState.Off;
|
||||
}
|
||||
|
||||
return new StatusLightData(
|
||||
_statusColor,
|
||||
lightState,
|
||||
_text);
|
||||
}
|
||||
public override StatusLightState? GetLightState(Wire wire, AirlockComponent comp)
|
||||
=> comp.BoltLightsEnabled ? StatusLightState.On : StatusLightState.Off;
|
||||
|
||||
public override object StatusKey { get; } = AirlockWireStatus.BoltLightIndicator;
|
||||
|
||||
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))
|
||||
{
|
||||
EntityManager.System<AirlockSystem>().SetBoltLightsEnabled(wire.Owner, door, false);
|
||||
}
|
||||
|
||||
EntityManager.System<AirlockSystem>().SetBoltLightsEnabled(wire.Owner, 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<AirlockSystem>().SetBoltLightsEnabled(wire.Owner, door, true);
|
||||
}
|
||||
|
||||
EntityManager.System<AirlockSystem>().SetBoltLightsEnabled(wire.Owner, 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<AirlockSystem>().SetBoltLightsEnabled(wire.Owner, door, !door.BoltLightsEnabled);
|
||||
}
|
||||
|
||||
return true;
|
||||
EntityManager.System<AirlockSystem>().SetBoltLightsEnabled(wire.Owner, door, !door.BoltLightsEnabled);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user