diff --git a/Content.Server/Power/PowerWireAction.cs b/Content.Server/Power/PowerWireAction.cs
index 1a9a85d0b4..6be7195804 100644
--- a/Content.Server/Power/PowerWireAction.cs
+++ b/Content.Server/Power/PowerWireAction.cs
@@ -27,7 +27,7 @@ public sealed class PowerWireAction : BaseWireAction
public override StatusLightData? GetStatusLightData(Wire wire)
{
StatusLightState lightState = StatusLightState.Off;
- if (WiresSystem.TryGetData(wire.Owner, PowerWireActionInternalKeys.MainWire, out int main)
+ if (WiresSystem.TryGetData(wire.Owner, PowerWireActionKey.MainWire, out int main)
&& main != wire.Id)
{
return null;
@@ -35,7 +35,8 @@ public sealed class PowerWireAction : BaseWireAction
if (IsPowered(wire.Owner))
{
- if (WiresSystem.TryGetData(wire.Owner, PowerWireActionKey.Pulsed, out bool pulsed)
+ if (!AllWiresMended(wire.Owner)
+ || WiresSystem.TryGetData(wire.Owner, PowerWireActionKey.Pulsed, out bool pulsed)
&& pulsed)
{
lightState = StatusLightState.BlinkingSlow;
@@ -56,11 +57,17 @@ public sealed class PowerWireAction : BaseWireAction
private bool AllWiresCut(EntityUid owner)
{
- return WiresSystem.TryGetData(owner, PowerWireActionInternalKeys.CutWires, out int? cut)
- && WiresSystem.TryGetData(owner, PowerWireActionInternalKeys.WireCount, out int? count)
+ return WiresSystem.TryGetData(owner, PowerWireActionKey.CutWires, out int? cut)
+ && WiresSystem.TryGetData(owner, PowerWireActionKey.WireCount, out int? count)
&& count == cut;
}
+ private bool AllWiresMended(EntityUid owner)
+ {
+ return WiresSystem.TryGetData(owner, PowerWireActionKey.CutWires, out int? cut)
+ && cut == 0;
+ }
+
// I feel like these two should be within ApcPowerReceiverComponent at this point.
// Getting it from a dictionary is significantly more expensive.
private void SetPower(EntityUid owner, bool pulsed)
@@ -76,8 +83,8 @@ public sealed class PowerWireAction : BaseWireAction
return;
}
- if (WiresSystem.TryGetData(owner, PowerWireActionInternalKeys.CutWires, out int? cut)
- && WiresSystem.TryGetData(owner, PowerWireActionInternalKeys.WireCount, out int? count))
+ if (WiresSystem.TryGetData(owner, PowerWireActionKey.CutWires, out int? cut)
+ && WiresSystem.TryGetData(owner, PowerWireActionKey.WireCount, out int? count))
{
if (AllWiresCut(owner))
{
@@ -98,10 +105,10 @@ public sealed class PowerWireAction : BaseWireAction
private void SetWireCuts(EntityUid owner, bool isCut)
{
- if (WiresSystem.TryGetData(owner, PowerWireActionInternalKeys.CutWires, out int? cut))
+ if (WiresSystem.TryGetData(owner, PowerWireActionKey.CutWires, out int? cut))
{
cut = isCut ? cut + 1 : cut - 1;
- WiresSystem.SetData(owner, PowerWireActionInternalKeys.CutWires, cut);
+ WiresSystem.SetData(owner, PowerWireActionKey.CutWires, cut);
}
}
@@ -114,35 +121,38 @@ public sealed class PowerWireAction : BaseWireAction
electrified.Enabled = setting;
}
- /// false if failed, true otherwise
+ /// false if failed, true otherwise, or if the entity cannot be electrified
private bool TrySetElectrocution(EntityUid user, Wire wire, bool timed = false)
{
- if (EntityManager.TryGetComponent(wire.Owner, out var power)
- && EntityManager.TryGetComponent(wire.Owner, out var electrified))
+ if (!EntityManager.TryGetComponent(wire.Owner, out var electrified))
{
- // always set this to true
- SetElectrified(wire.Owner, true, electrified);
+ return true;
+ }
- // if we were electrified, then return false
- var electrifiedAttempt = _electrocutionSystem.TryDoElectrifiedAct(wire.Owner, user);
+ var allCut = AllWiresCut(wire.Owner);
+ // always set this to true
+ SetElectrified(wire.Owner, true, electrified);
- // if this is timed, we set up a doAfter so that the
- // electrocution continues - unless cancelled
- //
- // if the power is disabled however, just don't bother
- if (timed && IsPowered(wire.Owner))
- {
- WiresSystem.StartWireAction(wire.Owner, _pulseTimeout, PowerWireActionKey.ElectrifiedCancel, new TimedWireEvent(AwaitElectrifiedCancel, wire));
- }
- else
+ // if we were electrified, then return false
+ var electrifiedAttempt = _electrocutionSystem.TryDoElectrifiedAct(wire.Owner, user);
+
+ // if this is timed, we set up a doAfter so that the
+ // electrocution continues - unless cancelled
+ //
+ // if the power is disabled however, just don't bother
+ if (timed && IsPowered(wire.Owner) && !allCut)
+ {
+ WiresSystem.StartWireAction(wire.Owner, _pulseTimeout, PowerWireActionKey.ElectrifiedCancel, new TimedWireEvent(AwaitElectrifiedCancel, wire));
+ }
+ else
+ {
+ if (allCut)
{
SetElectrified(wire.Owner, false, electrified);
}
-
- return !electrifiedAttempt;
}
- return false;
+ return !electrifiedAttempt;
}
public override void Initialize()
@@ -156,17 +166,17 @@ public sealed class PowerWireAction : BaseWireAction
// in WiresComponent or ApcPowerReceiverComponent.
public override bool AddWire(Wire wire, int count)
{
- if (!WiresSystem.HasData(wire.Owner, PowerWireActionInternalKeys.CutWires))
+ if (!WiresSystem.HasData(wire.Owner, PowerWireActionKey.CutWires))
{
- WiresSystem.SetData(wire.Owner, PowerWireActionInternalKeys.CutWires, 0);
+ WiresSystem.SetData(wire.Owner, PowerWireActionKey.CutWires, 0);
}
if (count == 1)
{
- WiresSystem.SetData(wire.Owner, PowerWireActionInternalKeys.MainWire, wire.Id);
+ WiresSystem.SetData(wire.Owner, PowerWireActionKey.MainWire, wire.Id);
}
- WiresSystem.SetData(wire.Owner, PowerWireActionInternalKeys.WireCount, count);
+ WiresSystem.SetData(wire.Owner, PowerWireActionKey.WireCount, count);
return true;
}
@@ -219,8 +229,6 @@ public sealed class PowerWireAction : BaseWireAction
SetPower(wire.Owner, true);
- // AwaitPulseCancel(wire.Owner, wire, _doAfterSystem.WaitDoAfter(doAfter));
-
return true;
}
@@ -239,8 +247,10 @@ public sealed class PowerWireAction : BaseWireAction
private void AwaitElectrifiedCancel(Wire wire)
{
- WiresSystem.SetData(wire.Owner, PowerWireActionKey.Electrified, false);
- SetElectrified(wire.Owner, false);
+ if (AllWiresMended(wire.Owner))
+ {
+ SetElectrified(wire.Owner, false);
+ }
}
private void AwaitPulseCancel(Wire wire)
@@ -248,11 +258,4 @@ public sealed class PowerWireAction : BaseWireAction
WiresSystem.SetData(wire.Owner, PowerWireActionKey.Pulsed, false);
SetPower(wire.Owner, false);
}
-
- private enum PowerWireActionInternalKeys : byte
- {
- MainWire,
- WireCount,
- CutWires
- }
}
diff --git a/Content.Server/Wires/WiresSystem.cs b/Content.Server/Wires/WiresSystem.cs
index 3931a778e8..a0e0037323 100644
--- a/Content.Server/Wires/WiresSystem.cs
+++ b/Content.Server/Wires/WiresSystem.cs
@@ -240,6 +240,7 @@ public sealed class WiresSystem : EntitySystem
SetOrCreateWireLayout(uid, component);
UpdateUserInterface(uid);
+ UpdateAppearance(uid);
}
#endregion
@@ -536,7 +537,7 @@ public sealed class WiresSystem : EntitySystem
private void UpdateAppearance(EntityUid uid, AppearanceComponent? appearance = null, WiresComponent? wires = null)
{
- if (!Resolve(uid, ref appearance, ref wires))
+ if (!Resolve(uid, ref appearance, ref wires, false))
return;
appearance.SetData(WiresVisuals.MaintenancePanelState, wires.IsPanelOpen && wires.IsPanelVisible);
@@ -676,14 +677,22 @@ public sealed class WiresSystem : EntitySystem
private void UpdateWires(EntityUid used, EntityUid user, EntityUid toolEntity, int id, WiresAction action, WiresComponent? wires = null, ToolComponent? tool = null)
{
- if (!Resolve(used, ref wires)
- || !Resolve(toolEntity, ref tool))
+ if (!Resolve(used, ref wires))
return;
+ if (!Resolve(toolEntity, ref tool))
+ {
+ wires.WiresQueue.Remove(id);
+ return;
+ }
+
var wire = TryGetWire(used, id, wires);
if (wire == null)
+ {
+ wires.WiresQueue.Remove(id);
return;
+ }
switch (action)
{
@@ -691,7 +700,7 @@ public sealed class WiresSystem : EntitySystem
if (!_toolSystem.HasQuality(toolEntity, "Cutting", tool))
{
_popupSystem.PopupCursor(Loc.GetString("wires-component-ui-on-receive-message-need-wirecutters"), Filter.Entities(user));
- return;
+ break;
}
_toolSystem.PlayToolSound(toolEntity, tool);
@@ -706,7 +715,7 @@ public sealed class WiresSystem : EntitySystem
if (!_toolSystem.HasQuality(toolEntity, "Cutting", tool))
{
_popupSystem.PopupCursor(Loc.GetString("wires-component-ui-on-receive-message-need-wirecutters"), Filter.Entities(user));
- return;
+ break;
}
_toolSystem.PlayToolSound(toolEntity, tool);
@@ -721,13 +730,13 @@ public sealed class WiresSystem : EntitySystem
if (!_toolSystem.HasQuality(toolEntity, "Pulsing", tool))
{
_popupSystem.PopupCursor(Loc.GetString("wires-component-ui-on-receive-message-need-multitool"), Filter.Entities(user));
- return;
+ break;
}
if (wire.IsCut)
{
_popupSystem.PopupCursor(Loc.GetString("wires-component-ui-on-receive-message-cannot-pulse-cut-wire"), Filter.Entities(user));
- return;
+ break;
}
wire.Action.Pulse(user, wire);
diff --git a/Content.Shared/Power/SharedPower.cs b/Content.Shared/Power/SharedPower.cs
index 12d342cada..481dcf7dc9 100644
--- a/Content.Shared/Power/SharedPower.cs
+++ b/Content.Shared/Power/SharedPower.cs
@@ -18,6 +18,9 @@ namespace Content.Shared.Power
Pulsed,
Electrified,
PulseCancel,
- ElectrifiedCancel
+ ElectrifiedCancel,
+ MainWire,
+ WireCount,
+ CutWires
}
}
diff --git a/Resources/Prototypes/Entities/Structures/Doors/Windoors/base_structurewindoors.yml b/Resources/Prototypes/Entities/Structures/Doors/Windoors/base_structurewindoors.yml
index 47c77070c1..749c898ffe 100644
--- a/Resources/Prototypes/Entities/Structures/Doors/Windoors/base_structurewindoors.yml
+++ b/Resources/Prototypes/Entities/Structures/Doors/Windoors/base_structurewindoors.yml
@@ -84,6 +84,9 @@
path: /Audio/Machines/windoor_open.ogg
denySound:
path: /Audio/Machines/airlock_deny.ogg
+ - type: Electrified
+ enabled: false
+ usesApcPower: true
- type: Wires
BoardName: "Windoor Control"
LayoutId: Windoors
diff --git a/Resources/Prototypes/Wires/layouts.yml b/Resources/Prototypes/Wires/layouts.yml
index 14a2da85ab..cdcba6f084 100644
--- a/Resources/Prototypes/Wires/layouts.yml
+++ b/Resources/Prototypes/Wires/layouts.yml
@@ -21,9 +21,13 @@
parent: Airlock
id: AirlockArmory
+- type: wireLayout
+ parent: Airlock
+ id: Windoors
+
- type: wireLayout
id: HighSec
- wires:
+ wires:
- !type:PowerWireAction
pulseTimeout: 10
- !type:DoorBoltWireAction
@@ -31,7 +35,7 @@
- !type:DoorTimingWireAction
- !type:DoorSafetyWireAction
dummyWires: 5
-
+
- type: wireLayout
id: Vending
wires: