diff --git a/code/datums/components/empprotection.dm b/code/datums/components/empprotection.dm deleted file mode 100644 index c85cdf31c7..0000000000 --- a/code/datums/components/empprotection.dm +++ /dev/null @@ -1,11 +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) - return flags diff --git a/code/datums/components/fantasy/_fantasy.dm b/code/datums/components/fantasy/_fantasy.dm index a203264fae..8441f962f9 100644 --- a/code/datums/components/fantasy/_fantasy.dm +++ b/code/datums/components/fantasy/_fantasy.dm @@ -9,6 +9,7 @@ var/originalName var/list/affixes var/list/appliedComponents + var/list/appliedElements var/static/list/affixListing @@ -22,6 +23,7 @@ src.affixes = affixes appliedComponents = list() + appliedElements = list() randomAffixes() /datum/component/fantasy/Destroy() @@ -118,6 +120,8 @@ affix.remove(src) for(var/i in appliedComponents) qdel(i) + for(var/i in appliedElements) + master._RemoveElement(i) master.force = max(0, master.force - quality) master.throwforce = max(0, master.throwforce - quality) diff --git a/code/datums/components/fantasy/prefixes.dm b/code/datums/components/fantasy/prefixes.dm index 5ef2ac2baf..b6de85cab0 100644 --- a/code/datums/components/fantasy/prefixes.dm +++ b/code/datums/components/fantasy/prefixes.dm @@ -45,7 +45,8 @@ /datum/fantasy_affix/tactical/apply(datum/component/fantasy/comp, newName) var/obj/item/master = comp.parent - comp.appliedComponents += master.AddComponent(/datum/component/tactical) + master.AddElement(/datum/element/tactical) + comp.appliedElements += list(/datum/element/tactical) return "tactical [newName]" /datum/fantasy_affix/pyromantic diff --git a/code/datums/components/forced_gravity.dm b/code/datums/components/forced_gravity.dm deleted file mode 100644 index 100bcf781c..0000000000 --- a/code/datums/components/forced_gravity.dm +++ /dev/null @@ -1,20 +0,0 @@ -/datum/component/forced_gravity - var/gravity - var/ignore_space = FALSE //If forced gravity should also work on space turfs - -/datum/component/forced_gravity/Initialize(forced_value = 1) - if(!isatom(parent)) - return COMPONENT_INCOMPATIBLE - RegisterSignal(COMSIG_ATOM_HAS_GRAVITY, .proc/gravity_check) - if(isturf(parent)) - RegisterSignal(COMSIG_TURF_HAS_GRAVITY, .proc/turf_gravity_check) - - gravity = forced_value - -/datum/component/forced_gravity/proc/gravity_check(datum/source, turf/location, list/gravs) - if(!ignore_space && isspaceturf(location)) - return - gravs += gravity - -/datum/component/forced_gravity/proc/turf_gravity_check(datum/source, atom/checker, list/gravs) - return gravity_check(parent, gravs) \ No newline at end of file diff --git a/code/datums/components/tactical.dm b/code/datums/components/tactical.dm deleted file mode 100644 index b73c58604a..0000000000 --- a/code/datums/components/tactical.dm +++ /dev/null @@ -1,44 +0,0 @@ - -/datum/component/tactical - var/allowed_slot - -/datum/component/tactical/Initialize(allowed_slot) - if(!isitem(parent)) - return COMPONENT_INCOMPATIBLE - - src.allowed_slot = allowed_slot - -/datum/component/tactical/RegisterWithParent() - . = ..() - RegisterSignal(parent, COMSIG_ITEM_EQUIPPED, .proc/modify) - RegisterSignal(parent, COMSIG_ITEM_DROPPED, .proc/unmodify) - -/datum/component/tactical/UnregisterFromParent() - . = ..() - UnregisterSignal(parent, list(COMSIG_ITEM_EQUIPPED, COMSIG_ITEM_DROPPED)) - unmodify() - -/datum/component/tactical/Destroy() - unmodify() - return ..() - -/datum/component/tactical/proc/modify(obj/item/source, mob/user, slot) - if(allowed_slot && slot != allowed_slot) - unmodify() - return - - var/obj/item/master = parent - var/image/I = image(icon = master.icon, icon_state = master.icon_state, loc = user) - I.copy_overlays(master) - I.override = TRUE - source.add_alt_appearance(/datum/atom_hud/alternate_appearance/basic/everyone, "sneaking_mission", I) - I.layer = ABOVE_MOB_LAYER - -/datum/component/tactical/proc/unmodify(obj/item/source, mob/user) - var/obj/item/master = source || parent - if(!user) - if(!ismob(master.loc)) - return - user = master.loc - - user.remove_alt_appearance("sneaking_mission") diff --git a/code/datums/elements/empprotection.dm b/code/datums/elements/empprotection.dm new file mode 100644 index 0000000000..c24914decb --- /dev/null +++ b/code/datums/elements/empprotection.dm @@ -0,0 +1,18 @@ +/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) + return flags diff --git a/code/datums/elements/forced_gravity.dm b/code/datums/elements/forced_gravity.dm new file mode 100644 index 0000000000..0b50df5b21 --- /dev/null +++ b/code/datums/elements/forced_gravity.dm @@ -0,0 +1,30 @@ +/datum/element/forced_gravity + element_flags = ELEMENT_BESPOKE + id_arg_index = 2 + var/gravity + var/ignore_space + +/datum/element/forced_gravity/Attach(datum/target, gravity=1, ignore_space=FALSE) + . = ..() + if(!isatom(target)) + return ELEMENT_INCOMPATIBLE + + src.gravity = gravity + src.ignore_space = ignore_space + + RegisterSignal(target, COMSIG_ATOM_HAS_GRAVITY, .proc/gravity_check) + if(isturf(target)) + RegisterSignal(target, COMSIG_TURF_HAS_GRAVITY, .proc/turf_gravity_check) + +/datum/element/forced_gravity/Detach(datum/source, force) + . = ..() + var/static/list/signals_b_gone = list(COMSIG_ATOM_HAS_GRAVITY, COMSIG_TURF_HAS_GRAVITY) + UnregisterSignal(source, signals_b_gone) + +/datum/element/forced_gravity/proc/gravity_check(datum/source, turf/location, list/gravs) + if(!ignore_space && isspaceturf(location)) + return + gravs += gravity + +/datum/element/forced_gravity/proc/turf_gravity_check(datum/source, atom/checker, list/gravs) + return gravity_check(null, source, gravs) diff --git a/code/datums/elements/tactical.dm b/code/datums/elements/tactical.dm new file mode 100644 index 0000000000..c74850795b --- /dev/null +++ b/code/datums/elements/tactical.dm @@ -0,0 +1,37 @@ +/datum/element/tactical + element_flags = ELEMENT_BESPOKE|ELEMENT_DETACH + id_arg_index = 2 + var/allowed_slot + +/datum/element/tactical/Attach(datum/target, allowed_slot) + . = ..() + if(. == ELEMENT_INCOMPATIBLE || !isitem(target)) + return ELEMENT_INCOMPATIBLE + + src.allowed_slot = allowed_slot + RegisterSignal(target, COMSIG_ITEM_EQUIPPED, .proc/modify) + RegisterSignal(target, COMSIG_ITEM_DROPPED, .proc/unmodify) + +/datum/element/tactical/Detach(datum/target) + UnregisterSignal(target, list(COMSIG_ITEM_EQUIPPED, COMSIG_ITEM_DROPPED)) + unmodify() + return ..() + +/datum/element/tactical/proc/modify(obj/item/source, mob/user, slot) + if(allowed_slot && slot != allowed_slot) + unmodify() + return + + var/image/I = image(icon = source.icon, icon_state = source.icon_state, loc = user) + I.copy_overlays(source) + I.override = TRUE + source.add_alt_appearance(/datum/atom_hud/alternate_appearance/basic/everyone, "sneaking_mission", I) + I.layer = ABOVE_MOB_LAYER + +/datum/element/tactical/proc/unmodify(obj/item/source, mob/user) + if(!user) + if(!ismob(source.loc)) + return + user = source.loc + + user.remove_alt_appearance("sneaking_mission") diff --git a/code/game/machinery/camera/presets.dm b/code/game/machinery/camera/presets.dm index 021232f435..33e250fa59 100644 --- a/code/game/machinery/camera/presets.dm +++ b/code/game/machinery/camera/presets.dm @@ -75,7 +75,7 @@ // UPGRADE PROCS /obj/machinery/camera/proc/upgradeEmpProof() - 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) assembly.upgrades.Add(new /obj/item/stack/sheet/mineral/plasma(assembly)) 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 ff79038a96..1887ee46c0 100644 --- a/code/game/machinery/porta_turret/portable_turret.dm +++ b/code/game/machinery/porta_turret/portable_turret.dm @@ -679,7 +679,7 @@ /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/energy icon_state = "standard_stun" @@ -788,7 +788,7 @@ /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 897f452091..5fe9de75aa 100644 --- a/code/game/objects/items/devices/radio/radio.dm +++ b/code/game/objects/items/devices/radio/radio.dm @@ -98,7 +98,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/antigravity.dm b/code/game/objects/items/grenades/antigravity.dm index 43b2f94986..a4bc207be0 100644 --- a/code/game/objects/items/grenades/antigravity.dm +++ b/code/game/objects/items/grenades/antigravity.dm @@ -2,16 +2,16 @@ name = "antigravity grenade" icon_state = "emp" item_state = "emp" - + var/range = 7 var/forced_value = 0 var/duration = 300 /obj/item/grenade/antigravity/prime() update_mob() - + for(var/turf/T in view(range,src)) - var/datum/component/C = T.AddComponent(/datum/component/forced_gravity,forced_value) - QDEL_IN(C,duration) - + T.AddElement(/datum/element/forced_gravity, forced_value) + addtimer(CALLBACK(T, /datum/.proc/_RemoveElement, list(forced_value)), duration) + qdel(src) diff --git a/code/game/objects/items/grenades/plastic.dm b/code/game/objects/items/grenades/plastic.dm index 66869d6f04..fe2a27f1a8 100644 --- a/code/game/objects/items/grenades/plastic.dm +++ b/code/game/objects/items/grenades/plastic.dm @@ -26,7 +26,7 @@ /obj/item/grenade/plastic/ComponentInitialize() . = ..() - AddComponent(/datum/component/empprotection, EMP_PROTECT_WIRES) + AddElement(/datum/element/empprotection, EMP_PROTECT_WIRES) /obj/item/grenade/plastic/Destroy() qdel(nadeassembly) diff --git a/code/game/objects/structures/flora.dm b/code/game/objects/structures/flora.dm index c0ee7bb987..e03ece2dfa 100644 --- a/code/game/objects/structures/flora.dm +++ b/code/game/objects/structures/flora.dm @@ -302,7 +302,7 @@ /obj/item/twohanded/required/kirbyplants/Initialize() . = ..() - AddComponent(/datum/component/tactical) + AddElement(/datum/element/tactical) /obj/item/twohanded/required/kirbyplants/random icon = 'icons/obj/flora/_flora.dmi' diff --git a/code/modules/fields/gravity.dm b/code/modules/fields/gravity.dm index 8b16bb6487..2334a84e04 100644 --- a/code/modules/fields/gravity.dm +++ b/code/modules/fields/gravity.dm @@ -2,16 +2,17 @@ name = "modified gravity zone" setup_field_turfs = TRUE var/gravity_value = 0 - var/list/grav_components = list() + var/list/modified_turfs = list() field_shape = FIELD_SHAPE_RADIUS_SQUARE /datum/proximity_monitor/advanced/gravity/setup_field_turf(turf/T) . = ..() - grav_components[T] = T.AddComponent(/datum/component/forced_gravity,gravity_value) + T.AddElement(/datum/element/forced_gravity, gravity_value) + modified_turfs[T] = gravity_value /datum/proximity_monitor/advanced/gravity/cleanup_field_turf(turf/T) . = ..() - var/datum/component/forced_gravity/G = grav_components[T] - grav_components -= T - if(G) - qdel(G) \ No newline at end of file + if(isnull(modified_turfs[T])) + return + T.RemoveElement(/datum/element/forced_gravity, modified_turfs[T]) + modified_turfs -= T \ No newline at end of file diff --git a/code/modules/mob/living/silicon/robot/robot.dm b/code/modules/mob/living/silicon/robot/robot.dm index 98a5f0f234..633135b3d2 100644 --- a/code/modules/mob/living/silicon/robot/robot.dm +++ b/code/modules/mob/living/silicon/robot/robot.dm @@ -14,7 +14,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) robot_modules_background = new() robot_modules_background.icon_state = "block" diff --git a/code/modules/power/cell.dm b/code/modules/power/cell.dm index 2cefb2803c..c788b9b033 100644 --- a/code/modules/power/cell.dm +++ b/code/modules/power/cell.dm @@ -317,7 +317,7 @@ /obj/item/stock_parts/cell/emproof/ComponentInitialize() . = ..() - AddComponent(/datum/component/empprotection, EMP_PROTECT_SELF) + AddElement(/datum/element/empprotection, EMP_PROTECT_SELF) /obj/item/stock_parts/cell/emproof/empty start_charged = FALSE diff --git a/code/modules/power/singularity/emitter.dm b/code/modules/power/singularity/emitter.dm index d57f78e5b6..0d182e0a1b 100644 --- a/code/modules/power/singularity/emitter.dm +++ b/code/modules/power/singularity/emitter.dm @@ -75,7 +75,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/RefreshParts() var/max_firedelay = 120 diff --git a/code/modules/power/singularity/field_generator.dm b/code/modules/power/singularity/field_generator.dm index 950e34098c..af2237a426 100644 --- a/code/modules/power/singularity/field_generator.dm +++ b/code/modules/power/singularity/field_generator.dm @@ -61,7 +61,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 0e0e677735..bfe75a2a79 100755 --- a/tgstation.dme +++ b/tgstation.dme @@ -399,11 +399,9 @@ #include "code\datums\components\dejavu.dm" #include "code\datums\components\earprotection.dm" #include "code\datums\components\edit_complainer.dm" -#include "code\datums\components\empprotection.dm" #include "code\datums\components\explodable.dm" #include "code\datums\components\field_of_vision.dm" #include "code\datums\components\footstep.dm" -#include "code\datums\components\forced_gravity.dm" #include "code\datums\components\identification.dm" #include "code\datums\components\igniter.dm" #include "code\datums\components\infective.dm" @@ -438,7 +436,6 @@ #include "code\datums\components\summoning.dm" #include "code\datums\components\swarming.dm" #include "code\datums\components\tackle.dm" -#include "code\datums\components\tactical.dm" #include "code\datums\components\thermite.dm" #include "code\datums\components\uplink.dm" #include "code\datums\components\virtual_reality.dm" @@ -530,8 +527,10 @@ #include "code\datums\elements\dusts_on_leaving_area.dm" #include "code\datums\elements\dwarfism.dm" #include "code\datums\elements\earhealing.dm" +#include "code\datums\elements\empprotection.dm" #include "code\datums\elements\firestacker.dm" #include "code\datums\elements\flavor_text.dm" +#include "code\datums\elements\forced_gravity.dm" #include "code\datums\elements\ghost_role_eligibility.dm" #include "code\datums\elements\mob_holder.dm" #include "code\datums\elements\polychromic.dm" @@ -541,6 +540,7 @@ #include "code\datums\elements\squish.dm" #include "code\datums\elements\swimming.dm" #include "code\datums\elements\sword_point.dm" +#include "code\datums\elements\tactical.dm" #include "code\datums\elements\update_icon_blocker.dm" #include "code\datums\elements\update_icon_updates_onmob.dm" #include "code\datums\elements\wuv.dm"