From 23ca0b88db7749015902b12cf2ed8eaecf66f993 Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Tue, 27 Oct 2020 18:38:50 +0100 Subject: [PATCH] [MIRROR] Converting the EMP protection component into an element. (#1494) * Converting the EMP protection component into an element. (#54617) * Converting the EMP protection component into an element. Co-authored-by: Ghom <42542238+Ghommie@users.noreply.github.com> --- code/datums/components/empprotection.dm | 13 ------------ code/datums/elements/empprotection.dm | 20 +++++++++++++++++++ code/game/machinery/camera/camera.dm | 1 - code/game/machinery/camera/presets.dm | 4 ++-- .../machinery/porta_turret/portable_turret.dm | 4 ++-- .../game/objects/items/devices/radio/radio.dm | 2 +- .../objects/items/grenades/chem_grenade.dm | 2 +- code/game/objects/items/grenades/plastic.dm | 2 +- .../clothing/spacesuits/miscellaneous.dm | 2 +- .../modules/mob/living/silicon/robot/robot.dm | 2 +- code/modules/power/cell.dm | 2 +- code/modules/power/singularity/emitter.dm | 2 +- .../power/singularity/field_generator.dm | 2 +- tgstation.dme | 2 +- 14 files changed, 33 insertions(+), 27 deletions(-) delete mode 100644 code/datums/components/empprotection.dm create mode 100644 code/datums/elements/empprotection.dm diff --git a/code/datums/components/empprotection.dm b/code/datums/components/empprotection.dm deleted file mode 100644 index 513370f3d5f..00000000000 --- a/code/datums/components/empprotection.dm +++ /dev/null @@ -1,13 +0,0 @@ -/datum/component/empprotection - var/flags = NONE - -/datum/component/empprotection/Initialize(_flags) - if(!istype(parent, /atom)) - return COMPONENT_INCOMPATIBLE - flags = _flags - RegisterSignal(parent, list(COMSIG_ATOM_EMP_ACT), .proc/getEmpFlags) - -/datum/component/empprotection/proc/getEmpFlags(datum/source, severity) - SIGNAL_HANDLER - - return flags diff --git a/code/datums/elements/empprotection.dm b/code/datums/elements/empprotection.dm new file mode 100644 index 00000000000..5a924057658 --- /dev/null +++ b/code/datums/elements/empprotection.dm @@ -0,0 +1,20 @@ +/datum/element/empprotection + element_flags = ELEMENT_DETACH | ELEMENT_BESPOKE + id_arg_index = 2 + var/flags = NONE + +/datum/element/empprotection/Attach(datum/target, _flags) + . = ..() + if(. == ELEMENT_INCOMPATIBLE || !isatom(target)) + return ELEMENT_INCOMPATIBLE + flags = _flags + RegisterSignal(target, COMSIG_ATOM_EMP_ACT, .proc/getEmpFlags) + +/datum/element/empprotection/Detach(atom/target) + UnregisterSignal(target, COMSIG_ATOM_EMP_ACT) + return ..() + +/datum/element/empprotection/proc/getEmpFlags(datum/source, severity) + SIGNAL_HANDLER + + return flags diff --git a/code/game/machinery/camera/camera.dm b/code/game/machinery/camera/camera.dm index cb5a9d49c85..5f4784ac819 100644 --- a/code/game/machinery/camera/camera.dm +++ b/code/game/machinery/camera/camera.dm @@ -38,7 +38,6 @@ // Upgrades bitflag var/upgrades = 0 - var/datum/component/empprotection/emp_component var/internal_light = TRUE //Whether it can light up when an AI views it diff --git a/code/game/machinery/camera/presets.dm b/code/game/machinery/camera/presets.dm index 50bc2eac90c..a830950b026 100644 --- a/code/game/machinery/camera/presets.dm +++ b/code/game/machinery/camera/presets.dm @@ -77,7 +77,7 @@ /obj/machinery/camera/proc/upgradeEmpProof(malf_upgrade, ignore_malf_upgrades) if(isEmpProof(ignore_malf_upgrades)) //pass a malf upgrade to ignore_malf_upgrades so we can replace the malf module with the normal one return //that way if someone tries to upgrade an already malf-upgraded camera, it'll just upgrade it to a normal version. - emp_component = AddComponent(/datum/component/empprotection, EMP_PROTECT_SELF | EMP_PROTECT_WIRES | EMP_PROTECT_CONTENTS) + AddElement(/datum/element/empprotection, EMP_PROTECT_SELF | EMP_PROTECT_WIRES | EMP_PROTECT_CONTENTS) if(malf_upgrade) assembly.malf_emp_firmware_active = TRUE //don't add parts to drop, update icon, ect. reconstructing it will also retain the upgrade. assembly.malf_emp_firmware_present = TRUE //so the upgrade is retained after incompatible parts are removed. @@ -92,7 +92,7 @@ /obj/machinery/camera/proc/removeEmpProof(ignore_malf_upgrades) if(ignore_malf_upgrades) //don't downgrade it if malf software is forced onto it. return - QDEL_NULL(emp_component) + RemoveElement(/datum/element/empprotection, EMP_PROTECT_SELF | EMP_PROTECT_WIRES | EMP_PROTECT_CONTENTS) upgrades &= ~CAMERA_UPGRADE_EMP_PROOF diff --git a/code/game/machinery/porta_turret/portable_turret.dm b/code/game/machinery/porta_turret/portable_turret.dm index 365fd155f8f..af9954376d0 100644 --- a/code/game/machinery/porta_turret/portable_turret.dm +++ b/code/game/machinery/porta_turret/portable_turret.dm @@ -708,7 +708,7 @@ DEFINE_BITFIELD(turret_flags, list( /obj/machinery/porta_turret/syndicate/ComponentInitialize() . = ..() - AddComponent(/datum/component/empprotection, EMP_PROTECT_SELF | EMP_PROTECT_WIRES) + AddElement(/datum/element/empprotection, EMP_PROTECT_SELF | EMP_PROTECT_WIRES) /obj/machinery/porta_turret/syndicate/setup() return @@ -814,7 +814,7 @@ DEFINE_BITFIELD(turret_flags, list( /obj/machinery/porta_turret/centcom_shuttle/ComponentInitialize() . = ..() - AddComponent(/datum/component/empprotection, EMP_PROTECT_SELF | EMP_PROTECT_WIRES) + AddElement(/datum/element/empprotection, EMP_PROTECT_SELF | EMP_PROTECT_WIRES) /obj/machinery/porta_turret/centcom_shuttle/assess_perp(mob/living/carbon/human/perp) return 0 diff --git a/code/game/objects/items/devices/radio/radio.dm b/code/game/objects/items/devices/radio/radio.dm index d375bb4df30..a106b4a8775 100644 --- a/code/game/objects/items/devices/radio/radio.dm +++ b/code/game/objects/items/devices/radio/radio.dm @@ -104,7 +104,7 @@ /obj/item/radio/ComponentInitialize() . = ..() - AddComponent(/datum/component/empprotection, EMP_PROTECT_WIRES) + AddElement(/datum/element/empprotection, EMP_PROTECT_WIRES) /obj/item/radio/interact(mob/user) if(unscrewed && !isAI(user)) diff --git a/code/game/objects/items/grenades/chem_grenade.dm b/code/game/objects/items/grenades/chem_grenade.dm index a55f2fa290b..0181e72cfdd 100644 --- a/code/game/objects/items/grenades/chem_grenade.dm +++ b/code/game/objects/items/grenades/chem_grenade.dm @@ -18,7 +18,7 @@ /obj/item/grenade/chem_grenade/ComponentInitialize() . = ..() - AddComponent(/datum/component/empprotection, EMP_PROTECT_WIRES) + AddElement(/datum/element/empprotection, EMP_PROTECT_WIRES) /obj/item/grenade/chem_grenade/Initialize() . = ..() diff --git a/code/game/objects/items/grenades/plastic.dm b/code/game/objects/items/grenades/plastic.dm index 58fb19c513e..b7e1b291a9a 100644 --- a/code/game/objects/items/grenades/plastic.dm +++ b/code/game/objects/items/grenades/plastic.dm @@ -26,7 +26,7 @@ /obj/item/grenade/c4/ComponentInitialize() . = ..() - AddComponent(/datum/component/empprotection, EMP_PROTECT_WIRES) + AddElement(/datum/element/empprotection, EMP_PROTECT_WIRES) /obj/item/grenade/c4/Destroy() qdel(wires) diff --git a/code/modules/clothing/spacesuits/miscellaneous.dm b/code/modules/clothing/spacesuits/miscellaneous.dm index 050f179c86f..e7b6d18b2a2 100644 --- a/code/modules/clothing/spacesuits/miscellaneous.dm +++ b/code/modules/clothing/spacesuits/miscellaneous.dm @@ -193,7 +193,7 @@ Contains: // ERT suit's gets EMP Protection /obj/item/clothing/suit/space/hardsuit/ert/Initialize() . = ..() - AddComponent(/datum/component/empprotection, EMP_PROTECT_CONTENTS) + AddElement(/datum/element/empprotection, EMP_PROTECT_CONTENTS) //ERT Security /obj/item/clothing/head/helmet/space/hardsuit/ert/sec diff --git a/code/modules/mob/living/silicon/robot/robot.dm b/code/modules/mob/living/silicon/robot/robot.dm index e85b0b9f33e..0e8f0207c12 100644 --- a/code/modules/mob/living/silicon/robot/robot.dm +++ b/code/modules/mob/living/silicon/robot/robot.dm @@ -115,7 +115,7 @@ spark_system.attach(src) wires = new /datum/wires/robot(src) - AddComponent(/datum/component/empprotection, EMP_PROTECT_WIRES) + AddElement(/datum/element/empprotection, EMP_PROTECT_WIRES) RegisterSignal(src, COMSIG_PROCESS_BORGCHARGER_OCCUPANT, .proc/charge) robot_modules_background = new() diff --git a/code/modules/power/cell.dm b/code/modules/power/cell.dm index a297c8fe10f..e1bace8db24 100644 --- a/code/modules/power/cell.dm +++ b/code/modules/power/cell.dm @@ -338,7 +338,7 @@ /obj/item/stock_parts/cell/emproof/empty/ComponentInitialize() . = ..() - AddComponent(/datum/component/empprotection, EMP_PROTECT_SELF) + AddElement(/datum/element/empprotection, EMP_PROTECT_SELF) /obj/item/stock_parts/cell/emproof/corrupt() return diff --git a/code/modules/power/singularity/emitter.dm b/code/modules/power/singularity/emitter.dm index 78dd47bab20..be2cdc1eddc 100644 --- a/code/modules/power/singularity/emitter.dm +++ b/code/modules/power/singularity/emitter.dm @@ -69,7 +69,7 @@ /obj/machinery/power/emitter/ComponentInitialize() . = ..() - AddComponent(/datum/component/empprotection, EMP_PROTECT_SELF | EMP_PROTECT_WIRES) + AddElement(/datum/element/empprotection, EMP_PROTECT_SELF | EMP_PROTECT_WIRES) /obj/machinery/power/emitter/set_anchored(anchorvalue) . = ..() diff --git a/code/modules/power/singularity/field_generator.dm b/code/modules/power/singularity/field_generator.dm index 836a507b413..0f7ecdb5bce 100644 --- a/code/modules/power/singularity/field_generator.dm +++ b/code/modules/power/singularity/field_generator.dm @@ -65,7 +65,7 @@ field_generator power level display /obj/machinery/field/generator/ComponentInitialize() . = ..() - AddComponent(/datum/component/empprotection, EMP_PROTECT_SELF | EMP_PROTECT_WIRES) + AddElement(/datum/element/empprotection, EMP_PROTECT_SELF | EMP_PROTECT_WIRES) /obj/machinery/field/generator/process() if(active == FG_ONLINE) diff --git a/tgstation.dme b/tgstation.dme index 616927fa6d2..054e0af31c5 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -438,7 +438,6 @@ #include "code\datums\components\earprotection.dm" #include "code\datums\components\edit_complainer.dm" #include "code\datums\components\embedded.dm" -#include "code\datums\components\empprotection.dm" #include "code\datums\components\explodable.dm" #include "code\datums\components\footstep.dm" #include "code\datums\components\forensics.dm" @@ -592,6 +591,7 @@ #include "code\datums\elements\digitalcamo.dm" #include "code\datums\elements\earhealing.dm" #include "code\datums\elements\embed.dm" +#include "code\datums\elements\empprotection.dm" #include "code\datums\elements\firestacker.dm" #include "code\datums\elements\forced_gravity.dm" #include "code\datums\elements\light_blocking.dm"