Wire action cleanup (#13496)
This commit is contained in:
@@ -5,76 +5,36 @@ using Content.Shared.Wires;
|
|||||||
|
|
||||||
namespace Content.Server.Access;
|
namespace Content.Server.Access;
|
||||||
|
|
||||||
[DataDefinition]
|
public sealed class AccessWireAction : ComponentWireAction<AccessReaderComponent>
|
||||||
public sealed class AccessWireAction : BaseWireAction
|
|
||||||
{
|
{
|
||||||
[DataField("color")]
|
public override Color Color { get; set; } = Color.Green;
|
||||||
private Color _statusColor = Color.Green;
|
public override string Name { get; set; } = "wire-name-access";
|
||||||
|
|
||||||
[DataField("name")]
|
|
||||||
private string _text = "ACC";
|
|
||||||
protected override string Text
|
|
||||||
{
|
|
||||||
get => _text;
|
|
||||||
set => _text = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
[DataField("pulseTimeout")]
|
[DataField("pulseTimeout")]
|
||||||
private int _pulseTimeout = 30;
|
private int _pulseTimeout = 30;
|
||||||
|
|
||||||
public override StatusLightData? GetStatusLightData(Wire wire)
|
public override StatusLightState? GetLightState(Wire wire, AccessReaderComponent comp)
|
||||||
{
|
=> comp.Enabled ? StatusLightState.On : StatusLightState.Off;
|
||||||
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 object StatusKey { get; } = AccessWireActionKey.Status;
|
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);
|
WiresSystem.TryCancelWireAction(wire.Owner, PulseTimeoutKey.Key);
|
||||||
if (EntityManager.TryGetComponent<AccessReaderComponent>(wire.Owner, out var access))
|
comp.Enabled = false;
|
||||||
{
|
|
||||||
WiresSystem.TryCancelWireAction(wire.Owner, PulseTimeoutKey.Key);
|
|
||||||
access.Enabled = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool Mend(EntityUid user, Wire wire)
|
public override bool Mend(EntityUid user, Wire wire, AccessReaderComponent comp)
|
||||||
{
|
{
|
||||||
base.Mend(user, wire);
|
comp.Enabled = true;
|
||||||
if (EntityManager.TryGetComponent<AccessReaderComponent>(wire.Owner, out var access))
|
|
||||||
{
|
|
||||||
access.Enabled = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 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);
|
comp.Enabled = false;
|
||||||
if (EntityManager.TryGetComponent<AccessReaderComponent>(wire.Owner, out var access))
|
WiresSystem.StartWireAction(wire.Owner, _pulseTimeout, PulseTimeoutKey.Key, new TimedWireEvent(AwaitPulseCancel, wire));
|
||||||
{
|
|
||||||
access.Enabled = false;
|
|
||||||
WiresSystem.StartWireAction(wire.Owner, _pulseTimeout, PulseTimeoutKey.Key, new TimedWireEvent(AwaitPulseCancel, wire));
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Update(Wire wire)
|
public override void Update(Wire wire)
|
||||||
|
|||||||
@@ -5,16 +5,11 @@ using Content.Shared.Wires;
|
|||||||
|
|
||||||
namespace Content.Server.Arcade;
|
namespace Content.Server.Arcade;
|
||||||
|
|
||||||
[DataDefinition]
|
|
||||||
public sealed class ArcadePlayerInvincibleWireAction : BaseToggleWireAction
|
public sealed class ArcadePlayerInvincibleWireAction : BaseToggleWireAction
|
||||||
{
|
{
|
||||||
private string _text = "MNGR";
|
public override string Name { get; set; } = "wire-name-arcade-invincible";
|
||||||
protected override string Text
|
|
||||||
{
|
public override Color Color { get; set; } = Color.Purple;
|
||||||
get => _text;
|
|
||||||
set => _text = value;
|
|
||||||
}
|
|
||||||
private Color _color = Color.Purple;
|
|
||||||
|
|
||||||
public override object? StatusKey { get; } = SharedSpaceVillainArcadeComponent.Indicators.HealthManager;
|
public override object? StatusKey { get; } = SharedSpaceVillainArcadeComponent.Indicators.HealthManager;
|
||||||
|
|
||||||
@@ -32,27 +27,24 @@ public sealed class ArcadePlayerInvincibleWireAction : BaseToggleWireAction
|
|||||||
&& !arcade.PlayerInvincibilityFlag;
|
&& !arcade.PlayerInvincibilityFlag;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override StatusLightData? GetStatusLightData(Wire wire)
|
public override StatusLightState? GetLightState(Wire wire)
|
||||||
{
|
{
|
||||||
var lightState = StatusLightState.Off;
|
if (EntityManager.TryGetComponent<SpaceVillainArcadeComponent>(wire.Owner, out var arcade))
|
||||||
|
|
||||||
if (IsPowered(wire.Owner) && EntityManager.TryGetComponent<SpaceVillainArcadeComponent>(wire.Owner, out var arcade))
|
|
||||||
{
|
{
|
||||||
lightState = arcade.PlayerInvincibilityFlag || arcade.EnemyInvincibilityFlag
|
return arcade.PlayerInvincibilityFlag || arcade.EnemyInvincibilityFlag
|
||||||
? StatusLightState.BlinkingSlow
|
? StatusLightState.BlinkingSlow
|
||||||
: StatusLightState.On;
|
: StatusLightState.On;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new StatusLightData(
|
return StatusLightState.Off;
|
||||||
_color,
|
|
||||||
lightState,
|
|
||||||
_text);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[DataDefinition]
|
|
||||||
public sealed class ArcadeEnemyInvincibleWireAction : BaseToggleWireAction
|
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 object? StatusKey { get; } = null;
|
||||||
|
|
||||||
public override void ToggleValue(EntityUid owner, bool setting)
|
public override void ToggleValue(EntityUid owner, bool setting)
|
||||||
|
|||||||
@@ -5,17 +5,11 @@ using Content.Shared.Wires;
|
|||||||
|
|
||||||
namespace Content.Server.Arcade;
|
namespace Content.Server.Arcade;
|
||||||
|
|
||||||
[DataDefinition]
|
|
||||||
public sealed class ArcadeOverflowWireAction : BaseToggleWireAction
|
public sealed class ArcadeOverflowWireAction : BaseToggleWireAction
|
||||||
{
|
{
|
||||||
private Color _color = Color.Red;
|
public override Color Color { get; set; } = Color.Red;
|
||||||
private string _text = "LMTR";
|
public override string Name { get; set; } = "wire-name-arcade-overflow";
|
||||||
protected override string Text
|
|
||||||
{
|
|
||||||
get => _text;
|
|
||||||
set => _text = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override object? StatusKey { get; } = SharedSpaceVillainArcadeComponent.Indicators.HealthLimiter;
|
public override object? StatusKey { get; } = SharedSpaceVillainArcadeComponent.Indicators.HealthLimiter;
|
||||||
|
|
||||||
public override void ToggleValue(EntityUid owner, bool setting)
|
public override void ToggleValue(EntityUid owner, bool setting)
|
||||||
@@ -32,20 +26,15 @@ public sealed class ArcadeOverflowWireAction : BaseToggleWireAction
|
|||||||
&& !arcade.OverflowFlag;
|
&& !arcade.OverflowFlag;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override StatusLightData? GetStatusLightData(Wire wire)
|
public override StatusLightState? GetLightState(Wire wire)
|
||||||
{
|
{
|
||||||
var lightState = StatusLightState.Off;
|
if (EntityManager.HasComponent<SpaceVillainArcadeComponent>(wire.Owner))
|
||||||
|
|
||||||
if (IsPowered(wire.Owner) && EntityManager.HasComponent<SpaceVillainArcadeComponent>(wire.Owner))
|
|
||||||
{
|
{
|
||||||
lightState = !GetValue(wire.Owner)
|
return !GetValue(wire.Owner)
|
||||||
? StatusLightState.BlinkingSlow
|
? StatusLightState.BlinkingSlow
|
||||||
: StatusLightState.On;
|
: StatusLightState.On;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new StatusLightData(
|
return StatusLightState.Off;
|
||||||
_color,
|
|
||||||
lightState,
|
|
||||||
_text);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,36 +7,19 @@ using Content.Shared.Wires;
|
|||||||
|
|
||||||
namespace Content.Server.Atmos.Monitor;
|
namespace Content.Server.Atmos.Monitor;
|
||||||
|
|
||||||
[DataDefinition]
|
public sealed class AirAlarmPanicWire : ComponentWireAction<AirAlarmComponent>
|
||||||
public sealed class AirAlarmPanicWire : BaseWireAction
|
|
||||||
{
|
{
|
||||||
private string _text = "PANC";
|
public override string Name { get; set; } = "wire-name-air-alarm-panic";
|
||||||
protected override string Text
|
public override Color Color { get; set; } = Color.Red;
|
||||||
{
|
|
||||||
get => _text;
|
|
||||||
set => _text = value;
|
|
||||||
}
|
|
||||||
private Color _color = Color.Red;
|
|
||||||
|
|
||||||
private AirAlarmSystem _airAlarmSystem = default!;
|
private AirAlarmSystem _airAlarmSystem = default!;
|
||||||
|
|
||||||
public override object StatusKey { get; } = AirAlarmWireStatus.Panic;
|
public override object StatusKey { get; } = AirAlarmWireStatus.Panic;
|
||||||
|
|
||||||
public override StatusLightData? GetStatusLightData(Wire wire)
|
public override StatusLightState? GetLightState(Wire wire, AirAlarmComponent comp)
|
||||||
{
|
=> comp.CurrentMode == AirAlarmMode.Panic
|
||||||
var lightState = StatusLightState.Off;
|
|
||||||
if (IsPowered(wire.Owner) && EntityManager.TryGetComponent<AirAlarmComponent>(wire.Owner, out var alarm))
|
|
||||||
{
|
|
||||||
lightState = alarm.CurrentMode == AirAlarmMode.Panic
|
|
||||||
? StatusLightState.On
|
? StatusLightState.On
|
||||||
: StatusLightState.Off;
|
: StatusLightState.Off;
|
||||||
}
|
|
||||||
|
|
||||||
return new StatusLightData(
|
|
||||||
_color,
|
|
||||||
lightState,
|
|
||||||
_text);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
@@ -45,9 +28,8 @@ public sealed class AirAlarmPanicWire : BaseWireAction
|
|||||||
_airAlarmSystem = EntityManager.System<AirAlarmSystem>();
|
_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))
|
if (EntityManager.TryGetComponent<DeviceNetworkComponent>(wire.Owner, out var devNet))
|
||||||
{
|
{
|
||||||
_airAlarmSystem.SetMode(wire.Owner, devNet.Address, AirAlarmMode.Panic, false);
|
_airAlarmSystem.SetMode(wire.Owner, devNet.Address, AirAlarmMode.Panic, false);
|
||||||
@@ -56,28 +38,22 @@ public sealed class AirAlarmPanicWire : BaseWireAction
|
|||||||
return true;
|
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)
|
if (EntityManager.TryGetComponent<DeviceNetworkComponent>(wire.Owner, out var devNet)
|
||||||
&& EntityManager.TryGetComponent<AirAlarmComponent>(wire.Owner, out var alarm)
|
|
||||||
&& alarm.CurrentMode == AirAlarmMode.Panic)
|
&& alarm.CurrentMode == AirAlarmMode.Panic)
|
||||||
{
|
{
|
||||||
_airAlarmSystem.SetMode(wire.Owner, devNet.Address, AirAlarmMode.Filtering, false, alarm);
|
_airAlarmSystem.SetMode(wire.Owner, devNet.Address, AirAlarmMode.Filtering, false, alarm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return true;
|
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))
|
if (EntityManager.TryGetComponent<DeviceNetworkComponent>(wire.Owner, out var devNet))
|
||||||
{
|
{
|
||||||
_airAlarmSystem.SetMode(wire.Owner, devNet.Address, AirAlarmMode.Panic, false);
|
_airAlarmSystem.SetMode(wire.Owner, devNet.Address, AirAlarmMode.Panic, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,46 +6,30 @@ using Content.Shared.Wires;
|
|||||||
|
|
||||||
namespace Content.Server.Atmos.Monitor;
|
namespace Content.Server.Atmos.Monitor;
|
||||||
|
|
||||||
[DataDefinition]
|
public sealed class AtmosMonitorDeviceNetWire : ComponentWireAction<AtmosAlarmableComponent>
|
||||||
public sealed class AtmosMonitorDeviceNetWire : BaseWireAction
|
|
||||||
{
|
{
|
||||||
// whether or not this wire will send out an alarm upon
|
// whether or not this wire will send out an alarm upon
|
||||||
// being pulsed
|
// being pulsed
|
||||||
[DataField("alarmOnPulse")]
|
[DataField("alarmOnPulse")]
|
||||||
private bool _alarmOnPulse = false;
|
private bool _alarmOnPulse = false;
|
||||||
|
|
||||||
private string _text = "NETW";
|
public override string Name { get; set; } = "wire-name-device-net";
|
||||||
protected override string Text
|
public override Color Color { get; set; } = Color.Orange;
|
||||||
{
|
|
||||||
get => _text;
|
|
||||||
set => _text = value;
|
|
||||||
}
|
|
||||||
private Color _color = Color.Orange;
|
|
||||||
|
|
||||||
private AtmosAlarmableSystem _atmosAlarmableSystem = default!;
|
private AtmosAlarmableSystem _atmosAlarmableSystem = default!;
|
||||||
|
|
||||||
public override object StatusKey { get; } = AtmosMonitorAlarmWireActionKeys.Network;
|
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 (!_atmosAlarmableSystem.TryGetHighestAlert(wire.Owner, out var alarm, comp))
|
||||||
|
|
||||||
if (IsPowered(wire.Owner) && EntityManager.TryGetComponent<AtmosMonitorComponent>(wire.Owner, out var monitor))
|
|
||||||
{
|
{
|
||||||
if (!_atmosAlarmableSystem.TryGetHighestAlert(wire.Owner, out var alarm))
|
alarm = AtmosAlarmType.Normal;
|
||||||
{
|
|
||||||
alarm = AtmosAlarmType.Normal;
|
|
||||||
}
|
|
||||||
|
|
||||||
lightState = alarm == AtmosAlarmType.Danger
|
|
||||||
? StatusLightState.BlinkingFast
|
|
||||||
: StatusLightState.On;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return new StatusLightData(
|
return alarm == AtmosAlarmType.Danger
|
||||||
_color,
|
? StatusLightState.BlinkingFast
|
||||||
lightState,
|
: StatusLightState.On;
|
||||||
_text);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
@@ -55,36 +39,21 @@ public sealed class AtmosMonitorDeviceNetWire : BaseWireAction
|
|||||||
_atmosAlarmableSystem = EntityManager.System<AtmosAlarmableSystem>();
|
_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);
|
comp.IgnoreAlarms = true;
|
||||||
if (EntityManager.TryGetComponent<AtmosAlarmableComponent>(wire.Owner, out var monitor))
|
|
||||||
{
|
|
||||||
monitor.IgnoreAlarms = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 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);
|
comp.IgnoreAlarms = false;
|
||||||
if (EntityManager.TryGetComponent<AtmosAlarmableComponent>(wire.Owner, out var monitor))
|
|
||||||
{
|
|
||||||
monitor.IgnoreAlarms = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
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)
|
if (_alarmOnPulse)
|
||||||
{
|
_atmosAlarmableSystem.ForceAlert(wire.Owner, AtmosAlarmType.Danger, comp);
|
||||||
_atmosAlarmableSystem.ForceAlert(wire.Owner, AtmosAlarmType.Danger);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
using Content.Server.Doors.Components;
|
|
||||||
using Content.Server.Doors.Systems;
|
using Content.Server.Doors.Systems;
|
||||||
using Content.Server.Wires;
|
using Content.Server.Wires;
|
||||||
using Content.Shared.Doors;
|
using Content.Shared.Doors;
|
||||||
@@ -7,68 +6,31 @@ using Content.Shared.Wires;
|
|||||||
|
|
||||||
namespace Content.Server.Doors;
|
namespace Content.Server.Doors;
|
||||||
|
|
||||||
[DataDefinition]
|
public sealed class DoorBoltLightWireAction : ComponentWireAction<AirlockComponent>
|
||||||
public sealed class DoorBoltLightWireAction : BaseWireAction
|
|
||||||
{
|
{
|
||||||
[DataField("color")]
|
public override Color Color { get; set; } = Color.Lime;
|
||||||
private Color _statusColor = Color.Lime;
|
public override string Name { get; set; } = "wire-name-bolt-light";
|
||||||
|
|
||||||
[DataField("name")]
|
public override StatusLightState? GetLightState(Wire wire, AirlockComponent comp)
|
||||||
private string _text = "BLIT";
|
=> comp.BoltLightsEnabled ? StatusLightState.On : StatusLightState.Off;
|
||||||
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 object StatusKey { get; } = AirlockWireStatus.BoltLightIndicator;
|
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);
|
EntityManager.System<AirlockSystem>().SetBoltLightsEnabled(wire.Owner, door, false);
|
||||||
if (EntityManager.TryGetComponent<AirlockComponent>(wire.Owner, out var door))
|
|
||||||
{
|
|
||||||
EntityManager.System<AirlockSystem>().SetBoltLightsEnabled(wire.Owner, door, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 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<AirlockSystem>().SetBoltLightsEnabled(wire.Owner, door, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
EntityManager.System<AirlockSystem>().SetBoltLightsEnabled(wire.Owner, door, true);
|
||||||
return 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);
|
EntityManager.System<AirlockSystem>().SetBoltLightsEnabled(wire.Owner, door, !door.BoltLightsEnabled);
|
||||||
if (EntityManager.TryGetComponent<AirlockComponent>(wire.Owner, out var door))
|
|
||||||
{
|
|
||||||
EntityManager.System<AirlockSystem>().SetBoltLightsEnabled(wire.Owner, door, !door.BoltLightsEnabled);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
using Content.Server.Doors.Components;
|
|
||||||
using Content.Server.Doors.Systems;
|
using Content.Server.Doors.Systems;
|
||||||
using Content.Server.Wires;
|
using Content.Server.Wires;
|
||||||
using Content.Shared.Doors;
|
using Content.Shared.Doors;
|
||||||
@@ -8,78 +7,36 @@ using Content.Shared.Wires;
|
|||||||
|
|
||||||
namespace Content.Server.Doors;
|
namespace Content.Server.Doors;
|
||||||
|
|
||||||
[DataDefinition]
|
public sealed class DoorBoltWireAction : ComponentWireAction<AirlockComponent>
|
||||||
public sealed class DoorBoltWireAction : BaseWireAction
|
|
||||||
{
|
{
|
||||||
[DataField("color")]
|
public override Color Color { get; set; } = Color.Red;
|
||||||
private Color _statusColor = Color.Red;
|
public override string Name { get; set; } = "wire-name-door-bolt";
|
||||||
|
|
||||||
[DataField("name")]
|
public override StatusLightState? GetLightState(Wire wire, AirlockComponent comp)
|
||||||
private string _text = "BOLT";
|
=> comp.BoltsDown ? StatusLightState.On : StatusLightState.Off;
|
||||||
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 object StatusKey { get; } = AirlockWireStatus.BoltIndicator;
|
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);
|
EntityManager.System<SharedAirlockSystem>().SetBoltWireCut(airlock, true);
|
||||||
if (EntityManager.TryGetComponent<AirlockComponent>(wire.Owner, out var airlock))
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool Mend(EntityUid user, Wire wire)
|
public override bool Mend(EntityUid user, Wire wire, AirlockComponent door)
|
||||||
{
|
{
|
||||||
base.Mend(user, wire);
|
EntityManager.System<SharedAirlockSystem>().SetBoltWireCut(door, true);
|
||||||
if (EntityManager.TryGetComponent<AirlockComponent>(wire.Owner, out var door))
|
|
||||||
EntityManager.System<SharedAirlockSystem>().SetBoltWireCut(door, true);
|
|
||||||
|
|
||||||
return 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 (IsPowered(wire.Owner))
|
||||||
if (EntityManager.TryGetComponent<AirlockComponent>(wire.Owner, out var door))
|
EntityManager.System<AirlockSystem>().SetBoltsWithAudio(wire.Owner, door, !door.BoltsDown);
|
||||||
{
|
else if (!door.BoltsDown)
|
||||||
if (IsPowered(wire.Owner))
|
EntityManager.System<AirlockSystem>().SetBoltsWithAudio(wire.Owner, door, true);
|
||||||
{
|
|
||||||
EntityManager.System<AirlockSystem>().SetBoltsWithAudio(wire.Owner, door, !door.BoltsDown);
|
|
||||||
}
|
|
||||||
else if (!door.BoltsDown)
|
|
||||||
{
|
|
||||||
EntityManager.System<AirlockSystem>().SetBoltsWithAudio(wire.Owner, door, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,75 +7,37 @@ using Content.Shared.Wires;
|
|||||||
|
|
||||||
namespace Content.Server.Doors;
|
namespace Content.Server.Doors;
|
||||||
|
|
||||||
[DataDefinition]
|
public sealed class DoorSafetyWireAction : ComponentWireAction<AirlockComponent>
|
||||||
public sealed class DoorSafetyWireAction : BaseWireAction
|
|
||||||
{
|
{
|
||||||
[DataField("color")]
|
public override Color Color { get; set; } = Color.Red;
|
||||||
private Color _statusColor = Color.Red;
|
public override string Name { get; set; } = "wire-name-door-safety";
|
||||||
|
|
||||||
[DataField("name")]
|
|
||||||
private string _text = "SAFE";
|
|
||||||
protected override string Text
|
|
||||||
{
|
|
||||||
get => _text;
|
|
||||||
set => _text = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
[DataField("timeout")]
|
[DataField("timeout")]
|
||||||
private int _timeout = 30;
|
private int _timeout = 30;
|
||||||
|
|
||||||
public override StatusLightData? GetStatusLightData(Wire wire)
|
public override StatusLightState? GetLightState(Wire wire, AirlockComponent comp)
|
||||||
{
|
=> comp.Safety ? StatusLightState.On : StatusLightState.Off;
|
||||||
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 object StatusKey { get; } = AirlockWireStatus.SafetyIndicator;
|
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);
|
WiresSystem.TryCancelWireAction(wire.Owner, PulseTimeoutKey.Key);
|
||||||
if (EntityManager.TryGetComponent<AirlockComponent>(wire.Owner, out var door))
|
EntityManager.System<SharedAirlockSystem>().SetSafety(door, false);
|
||||||
{
|
|
||||||
WiresSystem.TryCancelWireAction(wire.Owner, PulseTimeoutKey.Key);
|
|
||||||
EntityManager.System<SharedAirlockSystem>().SetSafety(door, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 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);
|
EntityManager.System<SharedAirlockSystem>().SetSafety(door, true);
|
||||||
if (EntityManager.TryGetComponent<AirlockComponent>(wire.Owner, out var door))
|
|
||||||
{
|
|
||||||
EntityManager.System<SharedAirlockSystem>().SetSafety(door, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 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);
|
EntityManager.System<SharedAirlockSystem>().SetSafety(door, false);
|
||||||
if (EntityManager.TryGetComponent<AirlockComponent>(wire.Owner, out var door))
|
WiresSystem.StartWireAction(wire.Owner, _timeout, PulseTimeoutKey.Key, new TimedWireEvent(AwaitSafetyTimerFinish, wire));
|
||||||
{
|
|
||||||
EntityManager.System<SharedAirlockSystem>().SetSafety(door, false);
|
|
||||||
WiresSystem.StartWireAction(wire.Owner, _timeout, PulseTimeoutKey.Key, new TimedWireEvent(AwaitSafetyTimerFinish, wire));
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Update(Wire wire)
|
public override void Update(Wire wire)
|
||||||
|
|||||||
@@ -7,85 +7,46 @@ using Content.Shared.Wires;
|
|||||||
|
|
||||||
namespace Content.Server.Doors;
|
namespace Content.Server.Doors;
|
||||||
|
|
||||||
[DataDefinition]
|
public sealed class DoorTimingWireAction : ComponentWireAction<AirlockComponent>
|
||||||
public sealed class DoorTimingWireAction : BaseWireAction
|
|
||||||
{
|
{
|
||||||
[DataField("color")]
|
public override Color Color { get; set; } = Color.Orange;
|
||||||
private Color _statusColor = Color.Orange;
|
public override string Name { get; set; } = "wire-name-door-timer";
|
||||||
|
|
||||||
[DataField("name")]
|
|
||||||
private string _text = "TIMR";
|
|
||||||
protected override string Text
|
|
||||||
{
|
|
||||||
get => _text;
|
|
||||||
set => _text = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
[DataField("timeout")]
|
[DataField("timeout")]
|
||||||
private int _timeout = 30;
|
private int _timeout = 30;
|
||||||
|
|
||||||
public override StatusLightData? GetStatusLightData(Wire wire)
|
public override StatusLightState? GetLightState(Wire wire, AirlockComponent comp)
|
||||||
{
|
{
|
||||||
var lightState = StatusLightState.Off;
|
switch (comp.AutoCloseDelayModifier)
|
||||||
if (IsPowered(wire.Owner)
|
|
||||||
&& EntityManager.TryGetComponent<AirlockComponent>(wire.Owner, out var door))
|
|
||||||
{
|
{
|
||||||
switch (door.AutoCloseDelayModifier)
|
case 0.01f:
|
||||||
{
|
return StatusLightState.Off;
|
||||||
case 0.01f:
|
case <= 0.5f:
|
||||||
lightState = StatusLightState.Off;
|
return StatusLightState.BlinkingSlow;
|
||||||
break;
|
default:
|
||||||
case <= 0.5f:
|
return StatusLightState.On;
|
||||||
lightState = StatusLightState.BlinkingSlow;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
lightState = StatusLightState.On;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return new StatusLightData(
|
|
||||||
_statusColor,
|
|
||||||
lightState,
|
|
||||||
_text);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override object StatusKey { get; } = AirlockWireStatus.TimingIndicator;
|
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);
|
WiresSystem.TryCancelWireAction(wire.Owner, PulseTimeoutKey.Key);
|
||||||
if (EntityManager.TryGetComponent<AirlockComponent>(wire.Owner, out var door))
|
EntityManager.System<SharedAirlockSystem>().SetAutoCloseDelayModifier(door, 0.01f);
|
||||||
{
|
|
||||||
WiresSystem.TryCancelWireAction(wire.Owner, PulseTimeoutKey.Key);
|
|
||||||
EntityManager.System<SharedAirlockSystem>().SetAutoCloseDelayModifier(door, 0.01f);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 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);
|
EntityManager.System<SharedAirlockSystem>().SetAutoCloseDelayModifier(door, 1f);
|
||||||
if (EntityManager.TryGetComponent<AirlockComponent>(wire.Owner, out var door))
|
|
||||||
{
|
|
||||||
EntityManager.System<SharedAirlockSystem>().SetAutoCloseDelayModifier(door, 1f);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 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);
|
EntityManager.System<SharedAirlockSystem>().SetAutoCloseDelayModifier(door, 0.5f);
|
||||||
if (EntityManager.TryGetComponent<AirlockComponent>(wire.Owner, out var door))
|
WiresSystem.StartWireAction(wire.Owner, _timeout, PulseTimeoutKey.Key, new TimedWireEvent(AwaitTimingTimerFinish, wire));
|
||||||
{
|
|
||||||
EntityManager.System<SharedAirlockSystem>().SetAutoCloseDelayModifier(door, 0.5f);
|
|
||||||
WiresSystem.StartWireAction(wire.Owner, _timeout, PulseTimeoutKey.Key, new TimedWireEvent(AwaitTimingTimerFinish, wire));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Update(Wire 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.Server.Wires;
|
||||||
using Content.Shared.Medical.Cryogenics;
|
using Content.Shared.Medical.Cryogenics;
|
||||||
using Content.Shared.Wires;
|
using Content.Shared.Wires;
|
||||||
@@ -8,52 +8,31 @@ namespace Content.Server.Medical;
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Causes a failure in the cryo pod ejection system when cut. A crowbar will be needed to pry open the pod.
|
/// Causes a failure in the cryo pod ejection system when cut. A crowbar will be needed to pry open the pod.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DataDefinition]
|
public sealed class CryoPodEjectLockWireAction: ComponentWireAction<CryoPodComponent>
|
||||||
public sealed class CryoPodEjectLockWireAction: BaseWireAction
|
|
||||||
{
|
{
|
||||||
[DataField("color")]
|
public override Color Color { get; set; } = Color.Red;
|
||||||
private Color _statusColor = Color.Red;
|
public override string Name { get; set; } = "wire-name-lock";
|
||||||
|
public override bool LightRequiresPower { get; set; } = false;
|
||||||
[DataField("name")]
|
|
||||||
private string _text = "LOCK";
|
|
||||||
|
|
||||||
public override object? StatusKey { get; } = CryoPodWireActionKey.Key;
|
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;
|
cryoPodComponent.Locked = true;
|
||||||
}
|
|
||||||
|
|
||||||
return 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;
|
cryoPodComponent.Locked = false;
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool Pulse(EntityUid user, Wire wire)
|
public override void Pulse(EntityUid user, Wire wire, CryoPodComponent cryoPodComponent) { }
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override StatusLightData? GetStatusLightData(Wire wire)
|
public override StatusLightState? GetLightState(Wire wire, CryoPodComponent comp)
|
||||||
{
|
=> comp.Locked ? StatusLightState.On : StatusLightState.Off;
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,19 +8,10 @@ namespace Content.Server.Power;
|
|||||||
|
|
||||||
// Generic power wire action. Use on anything
|
// Generic power wire action. Use on anything
|
||||||
// that requires power.
|
// that requires power.
|
||||||
[DataDefinition]
|
|
||||||
public sealed class PowerWireAction : BaseWireAction
|
public sealed class PowerWireAction : BaseWireAction
|
||||||
{
|
{
|
||||||
[DataField("color")]
|
public override Color Color { get; set; } = Color.Red;
|
||||||
private Color _statusColor = Color.Red;
|
public override string Name { get; set; } = "wire-name-power";
|
||||||
|
|
||||||
[DataField("name")]
|
|
||||||
private string _text = "POWR";
|
|
||||||
protected override string Text
|
|
||||||
{
|
|
||||||
get => _text;
|
|
||||||
set => _text = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
[DataField("pulseTimeout")]
|
[DataField("pulseTimeout")]
|
||||||
private int _pulseTimeout = 30;
|
private int _pulseTimeout = 30;
|
||||||
@@ -29,35 +20,22 @@ public sealed class PowerWireAction : BaseWireAction
|
|||||||
|
|
||||||
public override object StatusKey { get; } = PowerWireActionKey.Status;
|
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)
|
if (WiresSystem.TryGetData(wire.Owner, PowerWireActionKey.MainWire, out int main)
|
||||||
&& main != wire.Id)
|
&& main != wire.Id)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsPowered(wire.Owner))
|
if (!AllWiresMended(wire.Owner)
|
||||||
{
|
|
||||||
if (!AllWiresMended(wire.Owner)
|
|
||||||
|| WiresSystem.TryGetData(wire.Owner, PowerWireActionKey.Pulsed, out bool pulsed)
|
|| WiresSystem.TryGetData(wire.Owner, PowerWireActionKey.Pulsed, out bool pulsed)
|
||||||
&& pulsed)
|
&& pulsed)
|
||||||
{
|
{
|
||||||
lightState = StatusLightState.BlinkingSlow;
|
return StatusLightState.BlinkingSlow;
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
lightState = (AllWiresCut(wire.Owner))
|
|
||||||
? StatusLightState.Off
|
|
||||||
: StatusLightState.On;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return new StatusLightData(
|
return AllWiresCut(wire.Owner) ? StatusLightState.Off : StatusLightState.On;
|
||||||
_statusColor,
|
|
||||||
lightState,
|
|
||||||
_text);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool AllWiresCut(EntityUid owner)
|
private bool AllWiresCut(EntityUid owner)
|
||||||
@@ -233,29 +211,23 @@ public sealed class PowerWireAction : BaseWireAction
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool Pulse(EntityUid user, Wire wire)
|
public override void Pulse(EntityUid user, Wire wire)
|
||||||
{
|
{
|
||||||
base.Pulse(user, wire);
|
base.Pulse(user, wire);
|
||||||
WiresSystem.TryCancelWireAction(wire.Owner, PowerWireActionKey.ElectrifiedCancel);
|
WiresSystem.TryCancelWireAction(wire.Owner, PowerWireActionKey.ElectrifiedCancel);
|
||||||
|
|
||||||
var electrocuted = !TrySetElectrocution(user, wire, true);
|
var electrocuted = !TrySetElectrocution(user, wire, true);
|
||||||
|
|
||||||
if (WiresSystem.TryGetData(wire.Owner, PowerWireActionKey.Pulsed, out bool pulsedKey)
|
if (WiresSystem.TryGetData(wire.Owner, PowerWireActionKey.Pulsed, out bool pulsedKey) && pulsedKey)
|
||||||
&& pulsedKey)
|
return;
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
WiresSystem.SetData(wire.Owner, PowerWireActionKey.Pulsed, true);
|
WiresSystem.SetData(wire.Owner, PowerWireActionKey.Pulsed, true);
|
||||||
WiresSystem.StartWireAction(wire.Owner, _pulseTimeout, PowerWireActionKey.PulseCancel, new TimedWireEvent(AwaitPulseCancel, wire));
|
WiresSystem.StartWireAction(wire.Owner, _pulseTimeout, PowerWireActionKey.PulseCancel, new TimedWireEvent(AwaitPulseCancel, wire));
|
||||||
|
|
||||||
if (electrocuted)
|
if (electrocuted)
|
||||||
{
|
return;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
SetPower(wire.Owner, true);
|
SetPower(wire.Owner, true);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Update(Wire wire)
|
public override void Update(Wire wire)
|
||||||
|
|||||||
@@ -7,25 +7,21 @@ namespace Content.Server.VendingMachines;
|
|||||||
[DataDefinition]
|
[DataDefinition]
|
||||||
public sealed class VendingMachineContrabandWireAction : BaseToggleWireAction
|
public sealed class VendingMachineContrabandWireAction : BaseToggleWireAction
|
||||||
{
|
{
|
||||||
private readonly Color _color = Color.Green;
|
public override Color Color { get; set; } = Color.Green;
|
||||||
private readonly string _text = "MNGR";
|
public override string Name { get; set; } = "wire-name-vending-contraband";
|
||||||
public override object? StatusKey { get; } = ContrabandWireKey.StatusKey;
|
public override object? StatusKey { get; } = ContrabandWireKey.StatusKey;
|
||||||
public override object? TimeoutKey { get; } = ContrabandWireKey.TimeoutKey;
|
public override object? TimeoutKey { get; } = ContrabandWireKey.TimeoutKey;
|
||||||
|
|
||||||
public override StatusLightData? GetStatusLightData(Wire wire)
|
public override StatusLightState? GetLightState(Wire wire)
|
||||||
{
|
{
|
||||||
var lightState = StatusLightState.Off;
|
if (EntityManager.TryGetComponent(wire.Owner, out VendingMachineComponent? vending))
|
||||||
if (IsPowered(wire.Owner) && EntityManager.TryGetComponent(wire.Owner, out VendingMachineComponent? vending))
|
|
||||||
{
|
{
|
||||||
lightState = vending.Contraband
|
return vending.Contraband
|
||||||
? StatusLightState.BlinkingSlow
|
? StatusLightState.BlinkingSlow
|
||||||
: StatusLightState.On;
|
: StatusLightState.On;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new StatusLightData(
|
return StatusLightState.Off;
|
||||||
_color,
|
|
||||||
lightState,
|
|
||||||
_text);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void ToggleValue(EntityUid owner, bool setting)
|
public override void ToggleValue(EntityUid owner, bool setting)
|
||||||
|
|||||||
@@ -4,72 +4,39 @@ using Content.Shared.Wires;
|
|||||||
|
|
||||||
namespace Content.Server.VendingMachines;
|
namespace Content.Server.VendingMachines;
|
||||||
|
|
||||||
[DataDefinition]
|
public sealed class VendingMachineEjectItemWireAction : ComponentWireAction<VendingMachineComponent>
|
||||||
public sealed class VendingMachineEjectItemWireAction : BaseWireAction
|
|
||||||
{
|
{
|
||||||
private VendingMachineSystem _vendingMachineSystem = default!;
|
private VendingMachineSystem _vendingMachineSystem = default!;
|
||||||
|
|
||||||
private Color _color = Color.Red;
|
public override Color Color { get; set; } = Color.Red;
|
||||||
private string _text = "VEND";
|
public override string Name { get; set; } = "wire-name-vending-eject";
|
||||||
protected override string Text
|
|
||||||
{
|
|
||||||
get => _text;
|
|
||||||
set => _text = value;
|
|
||||||
}
|
|
||||||
public override object? StatusKey { get; } = EjectWireKey.StatusKey;
|
public override object? StatusKey { get; } = EjectWireKey.StatusKey;
|
||||||
|
|
||||||
public override StatusLightData? GetStatusLightData(Wire wire)
|
public override StatusLightState? GetLightState(Wire wire, VendingMachineComponent comp)
|
||||||
{
|
=> comp.CanShoot ? StatusLightState.BlinkingFast : StatusLightState.On;
|
||||||
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 void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
base.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);
|
_vendingMachineSystem.SetShooting(wire.Owner, true, vending);
|
||||||
if (EntityManager.TryGetComponent(wire.Owner, out VendingMachineComponent? vending))
|
|
||||||
{
|
|
||||||
_vendingMachineSystem.SetShooting(wire.Owner, true, vending);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool Mend(EntityUid user, Wire wire)
|
public override bool Mend(EntityUid user, Wire wire, VendingMachineComponent vending)
|
||||||
{
|
{
|
||||||
base.Mend(user, wire);
|
_vendingMachineSystem.SetShooting(wire.Owner, false, vending);
|
||||||
if (EntityManager.TryGetComponent(wire.Owner, out VendingMachineComponent? vending))
|
|
||||||
{
|
|
||||||
_vendingMachineSystem.SetShooting(wire.Owner, false, vending);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
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, vendComponent: vending);
|
||||||
_vendingMachineSystem.EjectRandom(wire.Owner, true);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ public abstract class BaseToggleWireAction : BaseWireAction
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool Pulse(EntityUid user, Wire wire)
|
public override void Pulse(EntityUid user, Wire wire)
|
||||||
{
|
{
|
||||||
base.Pulse(user, wire);
|
base.Pulse(user, wire);
|
||||||
ToggleValue(wire.Owner, !GetValue(wire.Owner));
|
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));
|
WiresSystem.StartWireAction(wire.Owner, Delay, TimeoutKey, new TimedWireEvent(AwaitPulseCancel, wire));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Update(Wire wire)
|
public override void Update(Wire wire)
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
using Content.Server.Power.Components;
|
|
||||||
using Content.Server.Power.EntitySystems;
|
using Content.Server.Power.EntitySystems;
|
||||||
using Content.Shared.Administration.Logs;
|
using Content.Shared.Administration.Logs;
|
||||||
using Content.Shared.Database;
|
using Content.Shared.Database;
|
||||||
@@ -7,15 +6,43 @@ using Content.Shared.Wires;
|
|||||||
namespace Content.Server.Wires;
|
namespace Content.Server.Wires;
|
||||||
|
|
||||||
/// <summary><see cref="IWireAction" /></summary>
|
/// <summary><see cref="IWireAction" /></summary>
|
||||||
|
[ImplicitDataDefinitionForInheritors]
|
||||||
public abstract class BaseWireAction : IWireAction
|
public abstract class BaseWireAction : IWireAction
|
||||||
{
|
{
|
||||||
private ISharedAdminLogManager _adminLogger = default!;
|
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", "");
|
if (LightRequiresPower && !IsPowered(wire.Owner))
|
||||||
set { }
|
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 IEntityManager EntityManager = default!;
|
||||||
public WiresSystem WiresSystem = 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 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)}");
|
var player = EntityManager.ToPrettyString(user);
|
||||||
return false;
|
var owner = EntityManager.ToPrettyString(wire.Owner);
|
||||||
}
|
var name = Loc.GetString(Name);
|
||||||
public virtual bool Mend(EntityUid user, Wire wire)
|
var color = wire.Color.Name();
|
||||||
{
|
var action = GetType().Name;
|
||||||
_adminLogger.Add(LogType.Action, LogImpact.Medium, $"{EntityManager.ToPrettyString(user):player} mended {wire.Color.Name()} {Text} in {EntityManager.ToPrettyString(wire.Owner)}");
|
|
||||||
return false;
|
// logs something like "... mended red POWR wire (PowerWireAction) in ...."
|
||||||
}
|
_adminLogger.Add(LogType.WireHacking, LogImpact.Medium, $"{player} {verb} {color} {name} wire ({action}) in {owner}");
|
||||||
public virtual bool Pulse(EntityUid user, Wire wire)
|
return true;
|
||||||
{
|
|
||||||
_adminLogger.Add(LogType.Action, LogImpact.Medium, $"{EntityManager.ToPrettyString(user):player} pulsed {wire.Color.Name()} {Text} in {EntityManager.ToPrettyString(wire.Owner)}");
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void Update(Wire wire)
|
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>
|
/// <summary>
|
||||||
/// Utility function to check if this given entity is powered.
|
/// Utility function to check if this given entity is powered.
|
||||||
/// </summary>
|
/// </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);
|
public bool AddWire(Wire wire, int count);
|
||||||
|
|
||||||
/// <summary>
|
/// <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>
|
/// </summary>
|
||||||
/// <param name="user">The user attempting to interact with the wire.</param>
|
/// <param name="user">The user attempting to interact with the wire.</param>
|
||||||
/// <param name="wire">The wire being interacted with.</param>
|
/// <param name="wire">The wire being interacted with.</param>
|
||||||
@@ -49,7 +49,7 @@ public interface IWireAction
|
|||||||
public bool Cut(EntityUid user, Wire wire);
|
public bool Cut(EntityUid user, Wire wire);
|
||||||
|
|
||||||
/// <summary>
|
/// <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>
|
/// </summary>
|
||||||
/// <param name="user">The user attempting to interact with the wire.</param>
|
/// <param name="user">The user attempting to interact with the wire.</param>
|
||||||
/// <param name="wire">The wire being interacted with.</param>
|
/// <param name="wire">The wire being interacted with.</param>
|
||||||
@@ -57,12 +57,11 @@ public interface IWireAction
|
|||||||
public bool Mend(EntityUid user, Wire wire);
|
public bool Mend(EntityUid user, Wire wire);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// What happens when this wire is pulsed.
|
/// This method gets called when the wire is pulsed..
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="user">The user attempting to interact with the wire.</param>
|
/// <param name="user">The user attempting to interact with the wire.</param>
|
||||||
/// <param name="wire">The wire being interacted with.</param>
|
/// <param name="wire">The wire being interacted with.</param>
|
||||||
/// <returns>true if successful, false otherwise.</returns>
|
public void Pulse(EntityUid user, Wire wire);
|
||||||
public bool Pulse(EntityUid user, Wire wire);
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Used when a wire's state on an entity needs to be updated.
|
/// 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 Content.Shared.Wires;
|
||||||
using Robust.Server.GameObjects;
|
using Robust.Server.GameObjects;
|
||||||
using Robust.Server.Player;
|
using Robust.Server.Player;
|
||||||
using Robust.Shared.Audio;
|
|
||||||
using Robust.Shared.Player;
|
|
||||||
using Robust.Shared.Prototypes;
|
using Robust.Shared.Prototypes;
|
||||||
using Robust.Shared.Random;
|
using Robust.Shared.Random;
|
||||||
|
|
||||||
@@ -42,13 +40,9 @@ public sealed class WiresSystem : EntitySystem
|
|||||||
private const float ScrewTime = 1f;
|
private const float ScrewTime = 1f;
|
||||||
private float _toolTime = 0f;
|
private float _toolTime = 0f;
|
||||||
|
|
||||||
private static DummyWireAction _dummyWire = new DummyWireAction();
|
|
||||||
|
|
||||||
#region Initialization
|
#region Initialization
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
_dummyWire.Initialize();
|
|
||||||
|
|
||||||
SubscribeLocalEvent<RoundRestartCleanupEvent>(Reset);
|
SubscribeLocalEvent<RoundRestartCleanupEvent>(Reset);
|
||||||
|
|
||||||
// this is a broadcast event
|
// this is a broadcast event
|
||||||
@@ -133,6 +127,10 @@ public sealed class WiresSystem : EntitySystem
|
|||||||
var id = 0;
|
var id = 0;
|
||||||
foreach (var wire in wires.WiresList)
|
foreach (var wire in wires.WiresList)
|
||||||
{
|
{
|
||||||
|
wire.Id = id++;
|
||||||
|
if (wire.Action == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
var wireType = wire.Action.GetType();
|
var wireType = wire.Action.GetType();
|
||||||
if (types.ContainsKey(wireType))
|
if (types.ContainsKey(wireType))
|
||||||
{
|
{
|
||||||
@@ -143,9 +141,6 @@ public sealed class WiresSystem : EntitySystem
|
|||||||
types.Add(wireType, 1);
|
types.Add(wireType, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
wire.Id = id;
|
|
||||||
id++;
|
|
||||||
|
|
||||||
// don't care about the result, this should've
|
// don't care about the result, this should've
|
||||||
// been handled in layout creation
|
// been handled in layout creation
|
||||||
wire.Action.AddWire(wire, types[wireType]);
|
wire.Action.AddWire(wire, types[wireType]);
|
||||||
@@ -165,25 +160,20 @@ public sealed class WiresSystem : EntitySystem
|
|||||||
{
|
{
|
||||||
(int id, Wire d) = enumeratedList[i];
|
(int id, Wire d) = enumeratedList[i];
|
||||||
|
|
||||||
var wireType = d.Action.GetType();
|
if (d.Action != null)
|
||||||
if (types.ContainsKey(wireType))
|
|
||||||
{
|
{
|
||||||
types[wireType] += 1;
|
var actionType = d.Action.GetType();
|
||||||
}
|
if (types.ContainsKey(actionType))
|
||||||
else
|
types[actionType] += 1;
|
||||||
{
|
else
|
||||||
types.Add(wireType, 1);
|
types.Add(actionType, 1);
|
||||||
}
|
|
||||||
|
|
||||||
d.Id = i;
|
d.Id = i;
|
||||||
|
if (!d.Action.AddWire(d, types[actionType]))
|
||||||
if (!d.Action.AddWire(d, types[wireType]))
|
d.Action = null;
|
||||||
{
|
|
||||||
d.Action = _dummyWire;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
data.Add(id, new WireLayout.WireData(d.Letter, d.Color, i));
|
data.Add(id, new WireLayout.WireData(d.Letter, d.Color, i));
|
||||||
|
|
||||||
wires.WiresList[i] = wireSet[id];
|
wires.WiresList[i] = wireSet[id];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -214,13 +204,13 @@ public sealed class WiresSystem : EntitySystem
|
|||||||
|
|
||||||
for (var i = 1; i <= dummyWires; i++)
|
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;
|
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;
|
WireLetter letter;
|
||||||
WireColor color;
|
WireColor color;
|
||||||
@@ -402,7 +392,7 @@ public sealed class WiresSystem : EntitySystem
|
|||||||
UpdateUserInterface(uid);
|
UpdateUserInterface(uid);
|
||||||
foreach (var wire in component.WiresList)
|
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,
|
clientList.Add(new ClientWire(entry.Id, entry.IsCut, entry.Color,
|
||||||
entry.Letter));
|
entry.Letter));
|
||||||
|
|
||||||
var statusData = entry.Action.GetStatusLightData(entry);
|
var statusData = entry.Action?.GetStatusLightData(entry);
|
||||||
if (statusData != null && entry.Action.StatusKey != null)
|
if (statusData != null && entry.Action?.StatusKey != null)
|
||||||
{
|
{
|
||||||
wires.Statuses[entry.Action.StatusKey] = (entry.OriginalPosition, statusData);
|
wires.Statuses[entry.Action.StatusKey] = (entry.OriginalPosition, statusData);
|
||||||
}
|
}
|
||||||
@@ -786,7 +776,7 @@ public sealed class WiresSystem : EntitySystem
|
|||||||
}
|
}
|
||||||
|
|
||||||
_toolSystem.PlayToolSound(toolEntity, tool);
|
_toolSystem.PlayToolSound(toolEntity, tool);
|
||||||
if (wire.Action.Cut(user, wire))
|
if (wire.Action == null || wire.Action.Cut(user, wire))
|
||||||
{
|
{
|
||||||
wire.IsCut = true;
|
wire.IsCut = true;
|
||||||
}
|
}
|
||||||
@@ -807,7 +797,7 @@ public sealed class WiresSystem : EntitySystem
|
|||||||
}
|
}
|
||||||
|
|
||||||
_toolSystem.PlayToolSound(toolEntity, tool);
|
_toolSystem.PlayToolSound(toolEntity, tool);
|
||||||
if (wire.Action.Mend(user, wire))
|
if (wire.Action == null || wire.Action.Mend(user, wire))
|
||||||
{
|
{
|
||||||
wire.IsCut = false;
|
wire.IsCut = false;
|
||||||
}
|
}
|
||||||
@@ -827,14 +817,14 @@ public sealed class WiresSystem : EntitySystem
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
wire.Action.Pulse(user, wire);
|
wire.Action?.Pulse(user, wire);
|
||||||
|
|
||||||
UpdateUserInterface(used);
|
UpdateUserInterface(used);
|
||||||
_audio.PlayPvs(wires.PulseSound, used);
|
_audio.PlayPvs(wires.PulseSound, used);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
wire.Action.Update(wire);
|
wire.Action?.Update(wire);
|
||||||
wires.WiresQueue.Remove(id);
|
wires.WiresQueue.Remove(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -991,10 +981,12 @@ public sealed class Wire
|
|||||||
[ViewVariables]
|
[ViewVariables]
|
||||||
public WireLetter Letter { get; }
|
public WireLetter Letter { get; }
|
||||||
|
|
||||||
// The action that this wire performs upon activation.
|
/// <summary>
|
||||||
public IWireAction Action { get; set; }
|
/// 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;
|
Owner = owner;
|
||||||
IsCut = isCut;
|
IsCut = isCut;
|
||||||
|
|||||||
@@ -81,5 +81,6 @@ public enum LogType
|
|||||||
Stamina = 76,
|
Stamina = 76,
|
||||||
EntitySpawn = 77,
|
EntitySpawn = 77,
|
||||||
AdminMessage = 78,
|
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