From 4700e5bc8022d88d2ea668403d09e430a3185530 Mon Sep 17 00:00:00 2001 From: Flipp Syder <76629141+vulppine@users.noreply.github.com> Date: Fri, 15 Apr 2022 14:21:11 -0700 Subject: [PATCH] Adds the ability for electrification to check if the entity is powered by an APC (#7533) --- .../Electrocution/Components/ElectrifiedComponent.cs | 3 +++ Content.Server/Electrocution/ElectrocutionSystem.cs | 12 +++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Content.Server/Electrocution/Components/ElectrifiedComponent.cs b/Content.Server/Electrocution/Components/ElectrifiedComponent.cs index 588b6101c7..d37201f076 100644 --- a/Content.Server/Electrocution/Components/ElectrifiedComponent.cs +++ b/Content.Server/Electrocution/Components/ElectrifiedComponent.cs @@ -30,6 +30,9 @@ namespace Content.Server.Electrocution [DataField("requirePower")] public bool RequirePower { get; } = true; + [DataField("usesApcPower")] + public bool UsesApcPower { get; } = false; + [DataField("highVoltageNode")] public string? HighVoltageNode { get; } diff --git a/Content.Server/Electrocution/ElectrocutionSystem.cs b/Content.Server/Electrocution/ElectrocutionSystem.cs index 1722732fe6..fdb6569a52 100644 --- a/Content.Server/Electrocution/ElectrocutionSystem.cs +++ b/Content.Server/Electrocution/ElectrocutionSystem.cs @@ -183,8 +183,18 @@ namespace Content.Server.Electrocution var targets = new List<(EntityUid entity, int depth)>(); GetChainedElectrocutionTargets(targetUid, targets); - if (!electrified.RequirePower) + if (!electrified.RequirePower || electrified.UsesApcPower) { + // Does it use APC power for its electrification check? Check if it's powered, and then + // attempt an electrocution if all the checks succeed. + + if (electrified.UsesApcPower && + (!TryComp(uid, out ApcPowerReceiverComponent? power) + || !power.Powered)) + { + return false; + } + var lastRet = true; for (var i = targets.Count - 1; i >= 0; i--) {