Wire action cleanup (#13496)
This commit is contained in:
@@ -5,76 +5,36 @@ using Content.Shared.Wires;
|
||||
|
||||
namespace Content.Server.Access;
|
||||
|
||||
[DataDefinition]
|
||||
public sealed class AccessWireAction : BaseWireAction
|
||||
public sealed class AccessWireAction : ComponentWireAction<AccessReaderComponent>
|
||||
{
|
||||
[DataField("color")]
|
||||
private Color _statusColor = Color.Green;
|
||||
|
||||
[DataField("name")]
|
||||
private string _text = "ACC";
|
||||
protected override string Text
|
||||
{
|
||||
get => _text;
|
||||
set => _text = value;
|
||||
}
|
||||
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 StatusLightData? GetStatusLightData(Wire wire)
|
||||
{
|
||||
StatusLightState lightState = StatusLightState.Off;
|
||||
if (IsPowered(wire.Owner)
|
||||
&& EntityManager.TryGetComponent<AccessReaderComponent>(wire.Owner, out var access))
|
||||
{
|
||||
if (access.Enabled)
|
||||
{
|
||||
lightState = StatusLightState.On;
|
||||
}
|
||||
}
|
||||
|
||||
return new StatusLightData(
|
||||
_statusColor,
|
||||
lightState,
|
||||
_text);
|
||||
}
|
||||
public override StatusLightState? GetLightState(Wire wire, AccessReaderComponent comp)
|
||||
=> comp.Enabled ? StatusLightState.On : StatusLightState.Off;
|
||||
|
||||
public override object StatusKey { get; } = AccessWireActionKey.Status;
|
||||
|
||||
public override bool Cut(EntityUid user, Wire wire)
|
||||
public override bool Cut(EntityUid user, Wire wire, AccessReaderComponent comp)
|
||||
{
|
||||
base.Cut(user, wire);
|
||||
if (EntityManager.TryGetComponent<AccessReaderComponent>(wire.Owner, out var access))
|
||||
{
|
||||
WiresSystem.TryCancelWireAction(wire.Owner, PulseTimeoutKey.Key);
|
||||
access.Enabled = false;
|
||||
}
|
||||
|
||||
WiresSystem.TryCancelWireAction(wire.Owner, PulseTimeoutKey.Key);
|
||||
comp.Enabled = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool Mend(EntityUid user, Wire wire)
|
||||
public override bool Mend(EntityUid user, Wire wire, AccessReaderComponent comp)
|
||||
{
|
||||
base.Mend(user, wire);
|
||||
if (EntityManager.TryGetComponent<AccessReaderComponent>(wire.Owner, out var access))
|
||||
{
|
||||
access.Enabled = true;
|
||||
}
|
||||
|
||||
comp.Enabled = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool Pulse(EntityUid user, Wire wire)
|
||||
public override void Pulse(EntityUid user, Wire wire, AccessReaderComponent comp)
|
||||
{
|
||||
base.Pulse(user, wire);
|
||||
if (EntityManager.TryGetComponent<AccessReaderComponent>(wire.Owner, out var access))
|
||||
{
|
||||
access.Enabled = false;
|
||||
WiresSystem.StartWireAction(wire.Owner, _pulseTimeout, PulseTimeoutKey.Key, new TimedWireEvent(AwaitPulseCancel, wire));
|
||||
}
|
||||
|
||||
return true;
|
||||
comp.Enabled = false;
|
||||
WiresSystem.StartWireAction(wire.Owner, _pulseTimeout, PulseTimeoutKey.Key, new TimedWireEvent(AwaitPulseCancel, wire));
|
||||
}
|
||||
|
||||
public override void Update(Wire wire)
|
||||
|
||||
@@ -5,16 +5,11 @@ using Content.Shared.Wires;
|
||||
|
||||
namespace Content.Server.Arcade;
|
||||
|
||||
[DataDefinition]
|
||||
public sealed class ArcadePlayerInvincibleWireAction : BaseToggleWireAction
|
||||
{
|
||||
private string _text = "MNGR";
|
||||
protected override string Text
|
||||
{
|
||||
get => _text;
|
||||
set => _text = value;
|
||||
}
|
||||
private Color _color = Color.Purple;
|
||||
public override string Name { get; set; } = "wire-name-arcade-invincible";
|
||||
|
||||
public override Color Color { get; set; } = Color.Purple;
|
||||
|
||||
public override object? StatusKey { get; } = SharedSpaceVillainArcadeComponent.Indicators.HealthManager;
|
||||
|
||||
@@ -32,27 +27,24 @@ public sealed class ArcadePlayerInvincibleWireAction : BaseToggleWireAction
|
||||
&& !arcade.PlayerInvincibilityFlag;
|
||||
}
|
||||
|
||||
public override StatusLightData? GetStatusLightData(Wire wire)
|
||||
public override StatusLightState? GetLightState(Wire wire)
|
||||
{
|
||||
var lightState = StatusLightState.Off;
|
||||
|
||||
if (IsPowered(wire.Owner) && EntityManager.TryGetComponent<SpaceVillainArcadeComponent>(wire.Owner, out var arcade))
|
||||
if (EntityManager.TryGetComponent<SpaceVillainArcadeComponent>(wire.Owner, out var arcade))
|
||||
{
|
||||
lightState = arcade.PlayerInvincibilityFlag || arcade.EnemyInvincibilityFlag
|
||||
return arcade.PlayerInvincibilityFlag || arcade.EnemyInvincibilityFlag
|
||||
? StatusLightState.BlinkingSlow
|
||||
: StatusLightState.On;
|
||||
}
|
||||
|
||||
return new StatusLightData(
|
||||
_color,
|
||||
lightState,
|
||||
_text);
|
||||
return StatusLightState.Off;
|
||||
}
|
||||
}
|
||||
|
||||
[DataDefinition]
|
||||
public sealed class ArcadeEnemyInvincibleWireAction : BaseToggleWireAction
|
||||
{
|
||||
public override string Name { get; set; } = "wire-name-player-invincible";
|
||||
public override Color Color { get; set; } = Color.Purple;
|
||||
|
||||
public override object? StatusKey { get; } = null;
|
||||
|
||||
public override void ToggleValue(EntityUid owner, bool setting)
|
||||
|
||||
@@ -5,17 +5,11 @@ using Content.Shared.Wires;
|
||||
|
||||
namespace Content.Server.Arcade;
|
||||
|
||||
[DataDefinition]
|
||||
public sealed class ArcadeOverflowWireAction : BaseToggleWireAction
|
||||
{
|
||||
private Color _color = Color.Red;
|
||||
private string _text = "LMTR";
|
||||
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-arcade-overflow";
|
||||
|
||||
public override object? StatusKey { get; } = SharedSpaceVillainArcadeComponent.Indicators.HealthLimiter;
|
||||
|
||||
public override void ToggleValue(EntityUid owner, bool setting)
|
||||
@@ -32,20 +26,15 @@ public sealed class ArcadeOverflowWireAction : BaseToggleWireAction
|
||||
&& !arcade.OverflowFlag;
|
||||
}
|
||||
|
||||
public override StatusLightData? GetStatusLightData(Wire wire)
|
||||
public override StatusLightState? GetLightState(Wire wire)
|
||||
{
|
||||
var lightState = StatusLightState.Off;
|
||||
|
||||
if (IsPowered(wire.Owner) && EntityManager.HasComponent<SpaceVillainArcadeComponent>(wire.Owner))
|
||||
if (EntityManager.HasComponent<SpaceVillainArcadeComponent>(wire.Owner))
|
||||
{
|
||||
lightState = !GetValue(wire.Owner)
|
||||
return !GetValue(wire.Owner)
|
||||
? StatusLightState.BlinkingSlow
|
||||
: StatusLightState.On;
|
||||
}
|
||||
|
||||
return new StatusLightData(
|
||||
_color,
|
||||
lightState,
|
||||
_text);
|
||||
return StatusLightState.Off;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,36 +7,19 @@ using Content.Shared.Wires;
|
||||
|
||||
namespace Content.Server.Atmos.Monitor;
|
||||
|
||||
[DataDefinition]
|
||||
public sealed class AirAlarmPanicWire : BaseWireAction
|
||||
public sealed class AirAlarmPanicWire : ComponentWireAction<AirAlarmComponent>
|
||||
{
|
||||
private string _text = "PANC";
|
||||
protected override string Text
|
||||
{
|
||||
get => _text;
|
||||
set => _text = value;
|
||||
}
|
||||
private Color _color = Color.Red;
|
||||
public override string Name { get; set; } = "wire-name-air-alarm-panic";
|
||||
public override Color Color { get; set; } = Color.Red;
|
||||
|
||||
private AirAlarmSystem _airAlarmSystem = default!;
|
||||
|
||||
public override object StatusKey { get; } = AirAlarmWireStatus.Panic;
|
||||
|
||||
public override StatusLightData? GetStatusLightData(Wire wire)
|
||||
{
|
||||
var lightState = StatusLightState.Off;
|
||||
if (IsPowered(wire.Owner) && EntityManager.TryGetComponent<AirAlarmComponent>(wire.Owner, out var alarm))
|
||||
{
|
||||
lightState = alarm.CurrentMode == AirAlarmMode.Panic
|
||||
public override StatusLightState? GetLightState(Wire wire, AirAlarmComponent comp)
|
||||
=> comp.CurrentMode == AirAlarmMode.Panic
|
||||
? StatusLightState.On
|
||||
: StatusLightState.Off;
|
||||
}
|
||||
|
||||
return new StatusLightData(
|
||||
_color,
|
||||
lightState,
|
||||
_text);
|
||||
}
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
@@ -45,9 +28,8 @@ public sealed class AirAlarmPanicWire : BaseWireAction
|
||||
_airAlarmSystem = EntityManager.System<AirAlarmSystem>();
|
||||
}
|
||||
|
||||
public override bool Cut(EntityUid user, Wire wire)
|
||||
public override bool Cut(EntityUid user, Wire wire, AirAlarmComponent comp)
|
||||
{
|
||||
base.Cut(user, wire);
|
||||
if (EntityManager.TryGetComponent<DeviceNetworkComponent>(wire.Owner, out var devNet))
|
||||
{
|
||||
_airAlarmSystem.SetMode(wire.Owner, devNet.Address, AirAlarmMode.Panic, false);
|
||||
@@ -56,28 +38,22 @@ public sealed class AirAlarmPanicWire : BaseWireAction
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool Mend(EntityUid user, Wire wire)
|
||||
public override bool Mend(EntityUid user, Wire wire, AirAlarmComponent alarm)
|
||||
{
|
||||
base.Mend(user, wire);
|
||||
if (EntityManager.TryGetComponent<DeviceNetworkComponent>(wire.Owner, out var devNet)
|
||||
&& EntityManager.TryGetComponent<AirAlarmComponent>(wire.Owner, out var alarm)
|
||||
&& alarm.CurrentMode == AirAlarmMode.Panic)
|
||||
{
|
||||
_airAlarmSystem.SetMode(wire.Owner, devNet.Address, AirAlarmMode.Filtering, false, alarm);
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool Pulse(EntityUid user, Wire wire)
|
||||
public override void Pulse(EntityUid user, Wire wire, AirAlarmComponent comp)
|
||||
{
|
||||
base.Pulse(user, wire);
|
||||
if (EntityManager.TryGetComponent<DeviceNetworkComponent>(wire.Owner, out var devNet))
|
||||
{
|
||||
_airAlarmSystem.SetMode(wire.Owner, devNet.Address, AirAlarmMode.Panic, false);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,46 +6,30 @@ using Content.Shared.Wires;
|
||||
|
||||
namespace Content.Server.Atmos.Monitor;
|
||||
|
||||
[DataDefinition]
|
||||
public sealed class AtmosMonitorDeviceNetWire : BaseWireAction
|
||||
public sealed class AtmosMonitorDeviceNetWire : ComponentWireAction<AtmosAlarmableComponent>
|
||||
{
|
||||
// whether or not this wire will send out an alarm upon
|
||||
// being pulsed
|
||||
[DataField("alarmOnPulse")]
|
||||
private bool _alarmOnPulse = false;
|
||||
|
||||
private string _text = "NETW";
|
||||
protected override string Text
|
||||
{
|
||||
get => _text;
|
||||
set => _text = value;
|
||||
}
|
||||
private Color _color = Color.Orange;
|
||||
public override string Name { get; set; } = "wire-name-device-net";
|
||||
public override Color Color { get; set; } = Color.Orange;
|
||||
|
||||
private AtmosAlarmableSystem _atmosAlarmableSystem = default!;
|
||||
|
||||
public override object StatusKey { get; } = AtmosMonitorAlarmWireActionKeys.Network;
|
||||
|
||||
public override StatusLightData? GetStatusLightData(Wire wire)
|
||||
public override StatusLightState? GetLightState(Wire wire, AtmosAlarmableComponent comp)
|
||||
{
|
||||
var lightState = StatusLightState.Off;
|
||||
|
||||
if (IsPowered(wire.Owner) && EntityManager.TryGetComponent<AtmosMonitorComponent>(wire.Owner, out var monitor))
|
||||
if (!_atmosAlarmableSystem.TryGetHighestAlert(wire.Owner, out var alarm, comp))
|
||||
{
|
||||
if (!_atmosAlarmableSystem.TryGetHighestAlert(wire.Owner, out var alarm))
|
||||
{
|
||||
alarm = AtmosAlarmType.Normal;
|
||||
}
|
||||
|
||||
lightState = alarm == AtmosAlarmType.Danger
|
||||
? StatusLightState.BlinkingFast
|
||||
: StatusLightState.On;
|
||||
alarm = AtmosAlarmType.Normal;
|
||||
}
|
||||
|
||||
return new StatusLightData(
|
||||
_color,
|
||||
lightState,
|
||||
_text);
|
||||
return alarm == AtmosAlarmType.Danger
|
||||
? StatusLightState.BlinkingFast
|
||||
: StatusLightState.On;
|
||||
}
|
||||
|
||||
public override void Initialize()
|
||||
@@ -55,36 +39,21 @@ public sealed class AtmosMonitorDeviceNetWire : BaseWireAction
|
||||
_atmosAlarmableSystem = EntityManager.System<AtmosAlarmableSystem>();
|
||||
}
|
||||
|
||||
public override bool Cut(EntityUid user, Wire wire)
|
||||
public override bool Cut(EntityUid user, Wire wire, AtmosAlarmableComponent comp)
|
||||
{
|
||||
base.Cut(user, wire);
|
||||
if (EntityManager.TryGetComponent<AtmosAlarmableComponent>(wire.Owner, out var monitor))
|
||||
{
|
||||
monitor.IgnoreAlarms = true;
|
||||
}
|
||||
|
||||
comp.IgnoreAlarms = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool Mend(EntityUid user, Wire wire)
|
||||
public override bool Mend(EntityUid user, Wire wire, AtmosAlarmableComponent comp)
|
||||
{
|
||||
base.Mend(user, wire);
|
||||
if (EntityManager.TryGetComponent<AtmosAlarmableComponent>(wire.Owner, out var monitor))
|
||||
{
|
||||
monitor.IgnoreAlarms = false;
|
||||
}
|
||||
|
||||
comp.IgnoreAlarms = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool Pulse(EntityUid user, Wire wire)
|
||||
public override void Pulse(EntityUid user, Wire wire, AtmosAlarmableComponent comp)
|
||||
{
|
||||
base.Pulse(user, wire);
|
||||
if (_alarmOnPulse)
|
||||
{
|
||||
_atmosAlarmableSystem.ForceAlert(wire.Owner, AtmosAlarmType.Danger);
|
||||
}
|
||||
|
||||
return true;
|
||||
_atmosAlarmableSystem.ForceAlert(wire.Owner, AtmosAlarmType.Danger, comp);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
using Content.Server.Doors.Components;
|
||||
using Content.Server.Doors.Systems;
|
||||
using Content.Server.Wires;
|
||||
using Content.Shared.Doors;
|
||||
@@ -8,78 +7,36 @@ using Content.Shared.Wires;
|
||||
|
||||
namespace Content.Server.Doors;
|
||||
|
||||
[DataDefinition]
|
||||
public sealed class DoorBoltWireAction : BaseWireAction
|
||||
public sealed class DoorBoltWireAction : ComponentWireAction<AirlockComponent>
|
||||
{
|
||||
[DataField("color")]
|
||||
private Color _statusColor = Color.Red;
|
||||
|
||||
[DataField("name")]
|
||||
private string _text = "BOLT";
|
||||
protected override string Text
|
||||
{
|
||||
get => _text;
|
||||
set => _text = value;
|
||||
}
|
||||
|
||||
public override StatusLightData? GetStatusLightData(Wire wire)
|
||||
{
|
||||
StatusLightState lightState = StatusLightState.Off;
|
||||
if (IsPowered(wire.Owner)
|
||||
&& EntityManager.TryGetComponent<AirlockComponent>(wire.Owner, out var door))
|
||||
{
|
||||
if (door.BoltsDown)
|
||||
{
|
||||
lightState = StatusLightState.On;
|
||||
}
|
||||
}
|
||||
|
||||
return new StatusLightData(
|
||||
_statusColor,
|
||||
lightState,
|
||||
_text);
|
||||
}
|
||||
public override Color Color { get; set; } = Color.Red;
|
||||
public override string Name { get; set; } = "wire-name-door-bolt";
|
||||
|
||||
public override StatusLightState? GetLightState(Wire wire, AirlockComponent comp)
|
||||
=> comp.BoltsDown ? StatusLightState.On : StatusLightState.Off;
|
||||
|
||||
public override object StatusKey { get; } = AirlockWireStatus.BoltIndicator;
|
||||
|
||||
public override bool Cut(EntityUid user, Wire wire)
|
||||
public override bool Cut(EntityUid user, Wire wire, AirlockComponent airlock)
|
||||
{
|
||||
base.Cut(user, wire);
|
||||
if (EntityManager.TryGetComponent<AirlockComponent>(wire.Owner, out var airlock))
|
||||
{
|
||||
EntityManager.System<SharedAirlockSystem>().SetBoltWireCut(airlock, true);
|
||||
if (!airlock.BoltsDown && IsPowered(wire.Owner))
|
||||
EntityManager.System<AirlockSystem>().SetBoltsWithAudio(wire.Owner, airlock, true);
|
||||
}
|
||||
EntityManager.System<SharedAirlockSystem>().SetBoltWireCut(airlock, true);
|
||||
if (!airlock.BoltsDown && IsPowered(wire.Owner))
|
||||
EntityManager.System<AirlockSystem>().SetBoltsWithAudio(wire.Owner, airlock, true);
|
||||
|
||||
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>().SetBoltWireCut(door, true);
|
||||
|
||||
EntityManager.System<SharedAirlockSystem>().SetBoltWireCut(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))
|
||||
{
|
||||
if (IsPowered(wire.Owner))
|
||||
{
|
||||
EntityManager.System<AirlockSystem>().SetBoltsWithAudio(wire.Owner, door, !door.BoltsDown);
|
||||
}
|
||||
else if (!door.BoltsDown)
|
||||
{
|
||||
EntityManager.System<AirlockSystem>().SetBoltsWithAudio(wire.Owner, door, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
if (IsPowered(wire.Owner))
|
||||
EntityManager.System<AirlockSystem>().SetBoltsWithAudio(wire.Owner, door, !door.BoltsDown);
|
||||
else if (!door.BoltsDown)
|
||||
EntityManager.System<AirlockSystem>().SetBoltsWithAudio(wire.Owner, door, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -7,85 +7,46 @@ using Content.Shared.Wires;
|
||||
|
||||
namespace Content.Server.Doors;
|
||||
|
||||
[DataDefinition]
|
||||
public sealed class DoorTimingWireAction : BaseWireAction
|
||||
public sealed class DoorTimingWireAction : ComponentWireAction<AirlockComponent>
|
||||
{
|
||||
[DataField("color")]
|
||||
private Color _statusColor = Color.Orange;
|
||||
|
||||
[DataField("name")]
|
||||
private string _text = "TIMR";
|
||||
protected override string Text
|
||||
{
|
||||
get => _text;
|
||||
set => _text = value;
|
||||
}
|
||||
|
||||
public override Color Color { get; set; } = Color.Orange;
|
||||
public override string Name { get; set; } = "wire-name-door-timer";
|
||||
|
||||
[DataField("timeout")]
|
||||
private int _timeout = 30;
|
||||
|
||||
public override StatusLightData? GetStatusLightData(Wire wire)
|
||||
public override StatusLightState? GetLightState(Wire wire, AirlockComponent comp)
|
||||
{
|
||||
var lightState = StatusLightState.Off;
|
||||
if (IsPowered(wire.Owner)
|
||||
&& EntityManager.TryGetComponent<AirlockComponent>(wire.Owner, out var door))
|
||||
switch (comp.AutoCloseDelayModifier)
|
||||
{
|
||||
switch (door.AutoCloseDelayModifier)
|
||||
{
|
||||
case 0.01f:
|
||||
lightState = StatusLightState.Off;
|
||||
break;
|
||||
case <= 0.5f:
|
||||
lightState = StatusLightState.BlinkingSlow;
|
||||
break;
|
||||
default:
|
||||
lightState = StatusLightState.On;
|
||||
break;
|
||||
}
|
||||
case 0.01f:
|
||||
return StatusLightState.Off;
|
||||
case <= 0.5f:
|
||||
return StatusLightState.BlinkingSlow;
|
||||
default:
|
||||
return StatusLightState.On;
|
||||
}
|
||||
|
||||
return new StatusLightData(
|
||||
_statusColor,
|
||||
lightState,
|
||||
_text);
|
||||
}
|
||||
|
||||
public override object StatusKey { get; } = AirlockWireStatus.TimingIndicator;
|
||||
|
||||
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>().SetAutoCloseDelayModifier(door, 0.01f);
|
||||
}
|
||||
|
||||
WiresSystem.TryCancelWireAction(wire.Owner, PulseTimeoutKey.Key);
|
||||
EntityManager.System<SharedAirlockSystem>().SetAutoCloseDelayModifier(door, 0.01f);
|
||||
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>().SetAutoCloseDelayModifier(door, 1f);
|
||||
}
|
||||
|
||||
EntityManager.System<SharedAirlockSystem>().SetAutoCloseDelayModifier(door, 1f);
|
||||
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>().SetAutoCloseDelayModifier(door, 0.5f);
|
||||
WiresSystem.StartWireAction(wire.Owner, _timeout, PulseTimeoutKey.Key, new TimedWireEvent(AwaitTimingTimerFinish, wire));
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
EntityManager.System<SharedAirlockSystem>().SetAutoCloseDelayModifier(door, 0.5f);
|
||||
WiresSystem.StartWireAction(wire.Owner, _timeout, PulseTimeoutKey.Key, new TimedWireEvent(AwaitTimingTimerFinish, wire));
|
||||
}
|
||||
|
||||
public override void Update(Wire wire)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Content.Server.Medical.Components;
|
||||
using Content.Server.Medical.Components;
|
||||
using Content.Server.Wires;
|
||||
using Content.Shared.Medical.Cryogenics;
|
||||
using Content.Shared.Wires;
|
||||
@@ -8,52 +8,31 @@ namespace Content.Server.Medical;
|
||||
/// <summary>
|
||||
/// Causes a failure in the cryo pod ejection system when cut. A crowbar will be needed to pry open the pod.
|
||||
/// </summary>
|
||||
[DataDefinition]
|
||||
public sealed class CryoPodEjectLockWireAction: BaseWireAction
|
||||
public sealed class CryoPodEjectLockWireAction: ComponentWireAction<CryoPodComponent>
|
||||
{
|
||||
[DataField("color")]
|
||||
private Color _statusColor = Color.Red;
|
||||
|
||||
[DataField("name")]
|
||||
private string _text = "LOCK";
|
||||
public override Color Color { get; set; } = Color.Red;
|
||||
public override string Name { get; set; } = "wire-name-lock";
|
||||
public override bool LightRequiresPower { get; set; } = false;
|
||||
|
||||
public override object? StatusKey { get; } = CryoPodWireActionKey.Key;
|
||||
public override bool Cut(EntityUid user, Wire wire)
|
||||
public override bool Cut(EntityUid user, Wire wire, CryoPodComponent cryoPodComponent)
|
||||
{
|
||||
if (EntityManager.TryGetComponent<CryoPodComponent>(wire.Owner, out var cryoPodComponent) && !cryoPodComponent.PermaLocked)
|
||||
{
|
||||
if (!cryoPodComponent.PermaLocked)
|
||||
cryoPodComponent.Locked = true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool Mend(EntityUid user, Wire wire)
|
||||
public override bool Mend(EntityUid user, Wire wire, CryoPodComponent cryoPodComponent)
|
||||
{
|
||||
if (EntityManager.TryGetComponent<CryoPodComponent>(wire.Owner, out var cryoPodComponent) && !cryoPodComponent.PermaLocked)
|
||||
{
|
||||
if (!cryoPodComponent.PermaLocked)
|
||||
cryoPodComponent.Locked = false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool Pulse(EntityUid user, Wire wire)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
public override void Pulse(EntityUid user, Wire wire, CryoPodComponent cryoPodComponent) { }
|
||||
|
||||
public override StatusLightData? GetStatusLightData(Wire wire)
|
||||
{
|
||||
StatusLightState lightState = StatusLightState.Off;
|
||||
if (EntityManager.TryGetComponent<CryoPodComponent>(wire.Owner, out var cryoPodComponent) && cryoPodComponent.Locked)
|
||||
{
|
||||
lightState = StatusLightState.On; //TODO figure out why this doesn't get updated when the pod is emagged
|
||||
}
|
||||
|
||||
return new StatusLightData(
|
||||
_statusColor,
|
||||
lightState,
|
||||
_text);
|
||||
}
|
||||
public override StatusLightState? GetLightState(Wire wire, CryoPodComponent comp)
|
||||
=> comp.Locked ? StatusLightState.On : StatusLightState.Off;
|
||||
}
|
||||
|
||||
@@ -8,19 +8,10 @@ namespace Content.Server.Power;
|
||||
|
||||
// Generic power wire action. Use on anything
|
||||
// that requires power.
|
||||
[DataDefinition]
|
||||
public sealed class PowerWireAction : BaseWireAction
|
||||
{
|
||||
[DataField("color")]
|
||||
private Color _statusColor = Color.Red;
|
||||
|
||||
[DataField("name")]
|
||||
private string _text = "POWR";
|
||||
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-power";
|
||||
|
||||
[DataField("pulseTimeout")]
|
||||
private int _pulseTimeout = 30;
|
||||
@@ -29,35 +20,22 @@ public sealed class PowerWireAction : BaseWireAction
|
||||
|
||||
public override object StatusKey { get; } = PowerWireActionKey.Status;
|
||||
|
||||
public override StatusLightData? GetStatusLightData(Wire wire)
|
||||
public override StatusLightState? GetLightState(Wire wire)
|
||||
{
|
||||
StatusLightState lightState = StatusLightState.Off;
|
||||
if (WiresSystem.TryGetData(wire.Owner, PowerWireActionKey.MainWire, out int main)
|
||||
&& main != wire.Id)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (IsPowered(wire.Owner))
|
||||
{
|
||||
if (!AllWiresMended(wire.Owner)
|
||||
if (!AllWiresMended(wire.Owner)
|
||||
|| WiresSystem.TryGetData(wire.Owner, PowerWireActionKey.Pulsed, out bool pulsed)
|
||||
&& pulsed)
|
||||
{
|
||||
lightState = StatusLightState.BlinkingSlow;
|
||||
}
|
||||
else
|
||||
{
|
||||
lightState = (AllWiresCut(wire.Owner))
|
||||
? StatusLightState.Off
|
||||
: StatusLightState.On;
|
||||
}
|
||||
{
|
||||
return StatusLightState.BlinkingSlow;
|
||||
}
|
||||
|
||||
return new StatusLightData(
|
||||
_statusColor,
|
||||
lightState,
|
||||
_text);
|
||||
return AllWiresCut(wire.Owner) ? StatusLightState.Off : StatusLightState.On;
|
||||
}
|
||||
|
||||
private bool AllWiresCut(EntityUid owner)
|
||||
@@ -233,29 +211,23 @@ public sealed class PowerWireAction : BaseWireAction
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool Pulse(EntityUid user, Wire wire)
|
||||
public override void Pulse(EntityUid user, Wire wire)
|
||||
{
|
||||
base.Pulse(user, wire);
|
||||
WiresSystem.TryCancelWireAction(wire.Owner, PowerWireActionKey.ElectrifiedCancel);
|
||||
|
||||
var electrocuted = !TrySetElectrocution(user, wire, true);
|
||||
|
||||
if (WiresSystem.TryGetData(wire.Owner, PowerWireActionKey.Pulsed, out bool pulsedKey)
|
||||
&& pulsedKey)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (WiresSystem.TryGetData(wire.Owner, PowerWireActionKey.Pulsed, out bool pulsedKey) && pulsedKey)
|
||||
return;
|
||||
|
||||
WiresSystem.SetData(wire.Owner, PowerWireActionKey.Pulsed, true);
|
||||
WiresSystem.StartWireAction(wire.Owner, _pulseTimeout, PowerWireActionKey.PulseCancel, new TimedWireEvent(AwaitPulseCancel, wire));
|
||||
|
||||
if (electrocuted)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return;
|
||||
|
||||
SetPower(wire.Owner, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void Update(Wire wire)
|
||||
|
||||
@@ -7,25 +7,21 @@ namespace Content.Server.VendingMachines;
|
||||
[DataDefinition]
|
||||
public sealed class VendingMachineContrabandWireAction : BaseToggleWireAction
|
||||
{
|
||||
private readonly Color _color = Color.Green;
|
||||
private readonly string _text = "MNGR";
|
||||
public override Color Color { get; set; } = Color.Green;
|
||||
public override string Name { get; set; } = "wire-name-vending-contraband";
|
||||
public override object? StatusKey { get; } = ContrabandWireKey.StatusKey;
|
||||
public override object? TimeoutKey { get; } = ContrabandWireKey.TimeoutKey;
|
||||
|
||||
public override StatusLightData? GetStatusLightData(Wire wire)
|
||||
public override StatusLightState? GetLightState(Wire wire)
|
||||
{
|
||||
var lightState = StatusLightState.Off;
|
||||
if (IsPowered(wire.Owner) && EntityManager.TryGetComponent(wire.Owner, out VendingMachineComponent? vending))
|
||||
if (EntityManager.TryGetComponent(wire.Owner, out VendingMachineComponent? vending))
|
||||
{
|
||||
lightState = vending.Contraband
|
||||
return vending.Contraband
|
||||
? StatusLightState.BlinkingSlow
|
||||
: StatusLightState.On;
|
||||
}
|
||||
|
||||
return new StatusLightData(
|
||||
_color,
|
||||
lightState,
|
||||
_text);
|
||||
return StatusLightState.Off;
|
||||
}
|
||||
|
||||
public override void ToggleValue(EntityUid owner, bool setting)
|
||||
|
||||
@@ -4,72 +4,39 @@ using Content.Shared.Wires;
|
||||
|
||||
namespace Content.Server.VendingMachines;
|
||||
|
||||
[DataDefinition]
|
||||
public sealed class VendingMachineEjectItemWireAction : BaseWireAction
|
||||
public sealed class VendingMachineEjectItemWireAction : ComponentWireAction<VendingMachineComponent>
|
||||
{
|
||||
private VendingMachineSystem _vendingMachineSystem = default!;
|
||||
|
||||
private Color _color = Color.Red;
|
||||
private string _text = "VEND";
|
||||
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-vending-eject";
|
||||
|
||||
public override object? StatusKey { get; } = EjectWireKey.StatusKey;
|
||||
|
||||
public override StatusLightData? GetStatusLightData(Wire wire)
|
||||
{
|
||||
var lightState = StatusLightState.Off;
|
||||
|
||||
if (IsPowered(wire.Owner)
|
||||
&& EntityManager.TryGetComponent(wire.Owner, out VendingMachineComponent? vending))
|
||||
{
|
||||
lightState = vending.CanShoot
|
||||
? StatusLightState.BlinkingFast
|
||||
: StatusLightState.On;
|
||||
}
|
||||
|
||||
return new StatusLightData(
|
||||
_color,
|
||||
lightState,
|
||||
_text);
|
||||
}
|
||||
public override StatusLightState? GetLightState(Wire wire, VendingMachineComponent comp)
|
||||
=> comp.CanShoot ? StatusLightState.BlinkingFast : StatusLightState.On;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
_vendingMachineSystem = EntitySystem.Get<VendingMachineSystem>();
|
||||
_vendingMachineSystem = EntityManager.System<VendingMachineSystem>();
|
||||
}
|
||||
|
||||
public override bool Cut(EntityUid user, Wire wire)
|
||||
public override bool Cut(EntityUid user, Wire wire, VendingMachineComponent vending)
|
||||
{
|
||||
base.Cut(user, wire);
|
||||
if (EntityManager.TryGetComponent(wire.Owner, out VendingMachineComponent? vending))
|
||||
{
|
||||
_vendingMachineSystem.SetShooting(wire.Owner, true, vending);
|
||||
}
|
||||
|
||||
_vendingMachineSystem.SetShooting(wire.Owner, true, vending);
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool Mend(EntityUid user, Wire wire)
|
||||
public override bool Mend(EntityUid user, Wire wire, VendingMachineComponent vending)
|
||||
{
|
||||
base.Mend(user, wire);
|
||||
if (EntityManager.TryGetComponent(wire.Owner, out VendingMachineComponent? vending))
|
||||
{
|
||||
_vendingMachineSystem.SetShooting(wire.Owner, false, vending);
|
||||
}
|
||||
|
||||
_vendingMachineSystem.SetShooting(wire.Owner, false, vending);
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool Pulse(EntityUid user, Wire wire)
|
||||
public override void Pulse(EntityUid user, Wire wire, VendingMachineComponent vending)
|
||||
{
|
||||
base.Pulse(user, wire);
|
||||
_vendingMachineSystem.EjectRandom(wire.Owner, true);
|
||||
|
||||
return true;
|
||||
_vendingMachineSystem.EjectRandom(wire.Owner, true, vendComponent: vending);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ public abstract class BaseToggleWireAction : BaseWireAction
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool Pulse(EntityUid user, Wire wire)
|
||||
public override void Pulse(EntityUid user, Wire wire)
|
||||
{
|
||||
base.Pulse(user, wire);
|
||||
ToggleValue(wire.Owner, !GetValue(wire.Owner));
|
||||
@@ -57,8 +57,6 @@ public abstract class BaseToggleWireAction : BaseWireAction
|
||||
{
|
||||
WiresSystem.StartWireAction(wire.Owner, Delay, TimeoutKey, new TimedWireEvent(AwaitPulseCancel, wire));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void Update(Wire wire)
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
using Content.Server.Power.Components;
|
||||
using Content.Server.Power.EntitySystems;
|
||||
using Content.Shared.Administration.Logs;
|
||||
using Content.Shared.Database;
|
||||
@@ -7,15 +6,43 @@ using Content.Shared.Wires;
|
||||
namespace Content.Server.Wires;
|
||||
|
||||
/// <summary><see cref="IWireAction" /></summary>
|
||||
[ImplicitDataDefinitionForInheritors]
|
||||
public abstract class BaseWireAction : IWireAction
|
||||
{
|
||||
private ISharedAdminLogManager _adminLogger = default!;
|
||||
protected virtual string Text
|
||||
|
||||
/// <summary>
|
||||
/// The loc-string of the text that gets returned by <see cref="GetStatusLightData(Wire)"/>. Also used for admin logging.
|
||||
/// </summary>
|
||||
[DataField("name")]
|
||||
public abstract string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Default color that gets returned by <see cref="GetStatusLightData(Wire)"/>.
|
||||
/// </summary>
|
||||
[DataField("color")]
|
||||
public abstract Color Color { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// If true, the default behavior of <see cref="GetStatusLightData(Wire)"/> will return an off-light when the
|
||||
/// wire owner is not powered.
|
||||
/// </summary>
|
||||
[DataField("lightRequiresPower")]
|
||||
public virtual bool LightRequiresPower { get; set; } = true;
|
||||
|
||||
public virtual StatusLightData? GetStatusLightData(Wire wire)
|
||||
{
|
||||
get => GetType().Name.Replace("WireAction", "");
|
||||
set { }
|
||||
if (LightRequiresPower && !IsPowered(wire.Owner))
|
||||
return new StatusLightData(Color, StatusLightState.Off, Loc.GetString(Name));
|
||||
|
||||
var state = GetLightState(wire);
|
||||
return state == null
|
||||
? null
|
||||
: new StatusLightData(Color, state.Value, Loc.GetString(Name));
|
||||
}
|
||||
|
||||
public virtual StatusLightState? GetLightState(Wire wire) => null;
|
||||
|
||||
public IEntityManager EntityManager = default!;
|
||||
public WiresSystem WiresSystem = default!;
|
||||
|
||||
@@ -32,31 +59,27 @@ public abstract class BaseWireAction : IWireAction
|
||||
}
|
||||
|
||||
public virtual bool AddWire(Wire wire, int count) => count == 1;
|
||||
public virtual bool Cut(EntityUid user, Wire wire)
|
||||
public virtual bool Cut(EntityUid user, Wire wire) => Log(user, wire, "cut");
|
||||
public virtual bool Mend(EntityUid user, Wire wire) => Log(user, wire, "mended");
|
||||
public virtual void Pulse(EntityUid user, Wire wire) => Log(user, wire, "pulsed");
|
||||
|
||||
private bool Log(EntityUid user, Wire wire, string verb)
|
||||
{
|
||||
_adminLogger.Add(LogType.Action, LogImpact.Medium, $"{EntityManager.ToPrettyString(user):player} cut {wire.Color.Name()} {Text} in {EntityManager.ToPrettyString(wire.Owner)}");
|
||||
return false;
|
||||
}
|
||||
public virtual bool Mend(EntityUid user, Wire wire)
|
||||
{
|
||||
_adminLogger.Add(LogType.Action, LogImpact.Medium, $"{EntityManager.ToPrettyString(user):player} mended {wire.Color.Name()} {Text} in {EntityManager.ToPrettyString(wire.Owner)}");
|
||||
return false;
|
||||
}
|
||||
public virtual bool Pulse(EntityUid user, Wire wire)
|
||||
{
|
||||
_adminLogger.Add(LogType.Action, LogImpact.Medium, $"{EntityManager.ToPrettyString(user):player} pulsed {wire.Color.Name()} {Text} in {EntityManager.ToPrettyString(wire.Owner)}");
|
||||
return false;
|
||||
var player = EntityManager.ToPrettyString(user);
|
||||
var owner = EntityManager.ToPrettyString(wire.Owner);
|
||||
var name = Loc.GetString(Name);
|
||||
var color = wire.Color.Name();
|
||||
var action = GetType().Name;
|
||||
|
||||
// logs something like "... mended red POWR wire (PowerWireAction) in ...."
|
||||
_adminLogger.Add(LogType.WireHacking, LogImpact.Medium, $"{player} {verb} {color} {name} wire ({action}) in {owner}");
|
||||
return true;
|
||||
}
|
||||
|
||||
public virtual void Update(Wire wire)
|
||||
{
|
||||
return;
|
||||
}
|
||||
public abstract StatusLightData? GetStatusLightData(Wire wire);
|
||||
|
||||
// most things that use wires are powered by *something*, so
|
||||
//
|
||||
// this isn't required by any wire system methods though, so whatever inherits it here
|
||||
// can use it
|
||||
/// <summary>
|
||||
/// Utility function to check if this given entity is powered.
|
||||
/// </summary>
|
||||
|
||||
40
Content.Server/Wires/ComponentWireAction.cs
Normal file
40
Content.Server/Wires/ComponentWireAction.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using Content.Shared.Wires;
|
||||
|
||||
namespace Content.Server.Wires;
|
||||
|
||||
/// <summary>
|
||||
/// convenience class for wires that depend on the existence of some component to function. Slightly reduces boilerplate.
|
||||
/// </summary>
|
||||
public abstract class ComponentWireAction<TComponent> : BaseWireAction where TComponent : Component
|
||||
{
|
||||
public abstract StatusLightState? GetLightState(Wire wire, TComponent component);
|
||||
public override StatusLightState? GetLightState(Wire wire)
|
||||
{
|
||||
return EntityManager.TryGetComponent(wire.Owner, out TComponent? component)
|
||||
? GetLightState(wire, component)
|
||||
: StatusLightState.Off;
|
||||
}
|
||||
|
||||
public abstract bool Cut(EntityUid user, Wire wire, TComponent component);
|
||||
public abstract bool Mend(EntityUid user, Wire wire, TComponent component);
|
||||
public abstract void Pulse(EntityUid user, Wire wire, TComponent component);
|
||||
|
||||
public override bool Cut(EntityUid user, Wire wire)
|
||||
{
|
||||
base.Cut(user, wire);
|
||||
return EntityManager.TryGetComponent(wire.Owner, out TComponent? component) && Cut(user, wire, component);
|
||||
}
|
||||
|
||||
public override bool Mend(EntityUid user, Wire wire)
|
||||
{
|
||||
base.Mend(user, wire);
|
||||
return EntityManager.TryGetComponent(wire.Owner, out TComponent? component) && Mend(user, wire, component);
|
||||
}
|
||||
|
||||
public override void Pulse(EntityUid user, Wire wire)
|
||||
{
|
||||
base.Pulse(user, wire);
|
||||
if (EntityManager.TryGetComponent(wire.Owner, out TComponent? component))
|
||||
Pulse(user, wire, component);
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
using Content.Shared.Wires;
|
||||
|
||||
namespace Content.Server.Wires;
|
||||
|
||||
// Exists so that dummy wires can be added.
|
||||
//
|
||||
// You *shouldn't* be adding these as raw
|
||||
// wire actions, but it's here anyways as
|
||||
// a serializable class for consistency.
|
||||
// C'est la vie.
|
||||
[DataDefinition]
|
||||
public sealed class DummyWireAction : BaseWireAction
|
||||
{
|
||||
public override object? StatusKey { get; } = null;
|
||||
|
||||
public override StatusLightData? GetStatusLightData(Wire wire) => null;
|
||||
public override bool AddWire(Wire wire, int count) => true;
|
||||
|
||||
public override bool Cut(EntityUid user, Wire wire)
|
||||
{
|
||||
base.Cut(user, wire);
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool Mend(EntityUid user, Wire wire)
|
||||
{
|
||||
base.Mend(user, wire);
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool Pulse(EntityUid user, Wire wire)
|
||||
{
|
||||
base.Pulse(user, wire);
|
||||
return true;
|
||||
}
|
||||
|
||||
// doesn't matter if you get any information off of this,
|
||||
// if you really want to mess with dummy wires, you should
|
||||
// probably code your own implementation?
|
||||
private enum DummyWireActionIdentifier
|
||||
{
|
||||
Key,
|
||||
}
|
||||
}
|
||||
@@ -41,7 +41,7 @@ public interface IWireAction
|
||||
public bool AddWire(Wire wire, int count);
|
||||
|
||||
/// <summary>
|
||||
/// What happens when this wire is cut.
|
||||
/// What happens when this wire is cut. If this returns false, the wire will not actually get cut.
|
||||
/// </summary>
|
||||
/// <param name="user">The user attempting to interact with the wire.</param>
|
||||
/// <param name="wire">The wire being interacted with.</param>
|
||||
@@ -49,7 +49,7 @@ public interface IWireAction
|
||||
public bool Cut(EntityUid user, Wire wire);
|
||||
|
||||
/// <summary>
|
||||
/// What happens when this wire is mended.
|
||||
/// What happens when this wire is mended. If this returns false, the wire will not actually get cut.
|
||||
/// </summary>
|
||||
/// <param name="user">The user attempting to interact with the wire.</param>
|
||||
/// <param name="wire">The wire being interacted with.</param>
|
||||
@@ -57,12 +57,11 @@ public interface IWireAction
|
||||
public bool Mend(EntityUid user, Wire wire);
|
||||
|
||||
/// <summary>
|
||||
/// What happens when this wire is pulsed.
|
||||
/// This method gets called when the wire is pulsed..
|
||||
/// </summary>
|
||||
/// <param name="user">The user attempting to interact with the wire.</param>
|
||||
/// <param name="wire">The wire being interacted with.</param>
|
||||
/// <returns>true if successful, false otherwise.</returns>
|
||||
public bool Pulse(EntityUid user, Wire wire);
|
||||
public void Pulse(EntityUid user, Wire wire);
|
||||
|
||||
/// <summary>
|
||||
/// Used when a wire's state on an entity needs to be updated.
|
||||
|
||||
@@ -15,8 +15,6 @@ using Content.Shared.Tools.Components;
|
||||
using Content.Shared.Wires;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Server.Player;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Random;
|
||||
|
||||
@@ -42,13 +40,9 @@ public sealed class WiresSystem : EntitySystem
|
||||
private const float ScrewTime = 1f;
|
||||
private float _toolTime = 0f;
|
||||
|
||||
private static DummyWireAction _dummyWire = new DummyWireAction();
|
||||
|
||||
#region Initialization
|
||||
public override void Initialize()
|
||||
{
|
||||
_dummyWire.Initialize();
|
||||
|
||||
SubscribeLocalEvent<RoundRestartCleanupEvent>(Reset);
|
||||
|
||||
// this is a broadcast event
|
||||
@@ -133,6 +127,10 @@ public sealed class WiresSystem : EntitySystem
|
||||
var id = 0;
|
||||
foreach (var wire in wires.WiresList)
|
||||
{
|
||||
wire.Id = id++;
|
||||
if (wire.Action == null)
|
||||
continue;
|
||||
|
||||
var wireType = wire.Action.GetType();
|
||||
if (types.ContainsKey(wireType))
|
||||
{
|
||||
@@ -143,9 +141,6 @@ public sealed class WiresSystem : EntitySystem
|
||||
types.Add(wireType, 1);
|
||||
}
|
||||
|
||||
wire.Id = id;
|
||||
id++;
|
||||
|
||||
// don't care about the result, this should've
|
||||
// been handled in layout creation
|
||||
wire.Action.AddWire(wire, types[wireType]);
|
||||
@@ -165,25 +160,20 @@ public sealed class WiresSystem : EntitySystem
|
||||
{
|
||||
(int id, Wire d) = enumeratedList[i];
|
||||
|
||||
var wireType = d.Action.GetType();
|
||||
if (types.ContainsKey(wireType))
|
||||
if (d.Action != null)
|
||||
{
|
||||
types[wireType] += 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
types.Add(wireType, 1);
|
||||
}
|
||||
var actionType = d.Action.GetType();
|
||||
if (types.ContainsKey(actionType))
|
||||
types[actionType] += 1;
|
||||
else
|
||||
types.Add(actionType, 1);
|
||||
|
||||
d.Id = i;
|
||||
|
||||
if (!d.Action.AddWire(d, types[wireType]))
|
||||
{
|
||||
d.Action = _dummyWire;
|
||||
d.Id = i;
|
||||
if (!d.Action.AddWire(d, types[actionType]))
|
||||
d.Action = null;
|
||||
}
|
||||
|
||||
|
||||
data.Add(id, new WireLayout.WireData(d.Letter, d.Color, i));
|
||||
|
||||
wires.WiresList[i] = wireSet[id];
|
||||
}
|
||||
|
||||
@@ -214,13 +204,13 @@ public sealed class WiresSystem : EntitySystem
|
||||
|
||||
for (var i = 1; i <= dummyWires; i++)
|
||||
{
|
||||
wireSet.Add(CreateWire(uid, _dummyWire, wires.Count + i, layout, colors, letters));
|
||||
wireSet.Add(CreateWire(uid, null, wires.Count + i, layout, colors, letters));
|
||||
}
|
||||
|
||||
return wireSet;
|
||||
}
|
||||
|
||||
private Wire CreateWire(EntityUid uid, IWireAction action, int position, WireLayout? layout, List<WireColor> colors, List<WireLetter> letters)
|
||||
private Wire CreateWire(EntityUid uid, IWireAction? action, int position, WireLayout? layout, List<WireColor> colors, List<WireLetter> letters)
|
||||
{
|
||||
WireLetter letter;
|
||||
WireColor color;
|
||||
@@ -402,7 +392,7 @@ public sealed class WiresSystem : EntitySystem
|
||||
UpdateUserInterface(uid);
|
||||
foreach (var wire in component.WiresList)
|
||||
{
|
||||
wire.Action.Update(wire);
|
||||
wire.Action?.Update(wire);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -592,8 +582,8 @@ public sealed class WiresSystem : EntitySystem
|
||||
clientList.Add(new ClientWire(entry.Id, entry.IsCut, entry.Color,
|
||||
entry.Letter));
|
||||
|
||||
var statusData = entry.Action.GetStatusLightData(entry);
|
||||
if (statusData != null && entry.Action.StatusKey != null)
|
||||
var statusData = entry.Action?.GetStatusLightData(entry);
|
||||
if (statusData != null && entry.Action?.StatusKey != null)
|
||||
{
|
||||
wires.Statuses[entry.Action.StatusKey] = (entry.OriginalPosition, statusData);
|
||||
}
|
||||
@@ -786,7 +776,7 @@ public sealed class WiresSystem : EntitySystem
|
||||
}
|
||||
|
||||
_toolSystem.PlayToolSound(toolEntity, tool);
|
||||
if (wire.Action.Cut(user, wire))
|
||||
if (wire.Action == null || wire.Action.Cut(user, wire))
|
||||
{
|
||||
wire.IsCut = true;
|
||||
}
|
||||
@@ -807,7 +797,7 @@ public sealed class WiresSystem : EntitySystem
|
||||
}
|
||||
|
||||
_toolSystem.PlayToolSound(toolEntity, tool);
|
||||
if (wire.Action.Mend(user, wire))
|
||||
if (wire.Action == null || wire.Action.Mend(user, wire))
|
||||
{
|
||||
wire.IsCut = false;
|
||||
}
|
||||
@@ -827,14 +817,14 @@ public sealed class WiresSystem : EntitySystem
|
||||
break;
|
||||
}
|
||||
|
||||
wire.Action.Pulse(user, wire);
|
||||
wire.Action?.Pulse(user, wire);
|
||||
|
||||
UpdateUserInterface(used);
|
||||
_audio.PlayPvs(wires.PulseSound, used);
|
||||
break;
|
||||
}
|
||||
|
||||
wire.Action.Update(wire);
|
||||
wire.Action?.Update(wire);
|
||||
wires.WiresQueue.Remove(id);
|
||||
}
|
||||
|
||||
@@ -991,10 +981,12 @@ public sealed class Wire
|
||||
[ViewVariables]
|
||||
public WireLetter Letter { get; }
|
||||
|
||||
// The action that this wire performs upon activation.
|
||||
public IWireAction Action { get; set; }
|
||||
/// <summary>
|
||||
/// The action that this wire performs when mended, cut or puled. This also determines the status lights that this wire adds.
|
||||
/// </summary>
|
||||
public IWireAction? Action { get; set; }
|
||||
|
||||
public Wire(EntityUid owner, bool isCut, WireColor color, WireLetter letter, int position, IWireAction action)
|
||||
public Wire(EntityUid owner, bool isCut, WireColor color, WireLetter letter, int position, IWireAction? action)
|
||||
{
|
||||
Owner = owner;
|
||||
IsCut = isCut;
|
||||
|
||||
@@ -81,5 +81,6 @@ public enum LogType
|
||||
Stamina = 76,
|
||||
EntitySpawn = 77,
|
||||
AdminMessage = 78,
|
||||
Anomaly = 79
|
||||
Anomaly = 79,
|
||||
WireHacking = 80,
|
||||
}
|
||||
|
||||
16
Resources/Locale/en-US/wires/wire-names.ftl
Normal file
16
Resources/Locale/en-US/wires/wire-names.ftl
Normal file
@@ -0,0 +1,16 @@
|
||||
|
||||
# names that get displayed in the wire hacking hud & admin logs.
|
||||
|
||||
wire-name-access = ACC
|
||||
wire-name-arcade-overflow = LMTR
|
||||
wire-name-air-alarm-panic = PANC
|
||||
wire-name-device-net = NETW
|
||||
wire-name-bolt-light = BLIT
|
||||
wire-name-door-bolt = BOLT
|
||||
wire-name-door-safety = SAFE
|
||||
wire-name-door-timer = TIMR
|
||||
wire-name-lock = LOCK
|
||||
wire-name-power = POWR
|
||||
wire-name-arcade-invincible = MNGR
|
||||
wire-name-vending-contraband = MNGR
|
||||
wire-name-vending-eject = VEND
|
||||
Reference in New Issue
Block a user