diff --git a/code/__DEFINES/components.dm b/code/__DEFINES/components.dm
index b79f1c2e59..9dad2926f8 100644
--- a/code/__DEFINES/components.dm
+++ b/code/__DEFINES/components.dm
@@ -5,6 +5,11 @@
#define COMPONENT_INCOMPATIBLE 1
#define COMPONENT_NOTRANSFER 2
+#define ELEMENT_INCOMPATIBLE 1 // Return value to cancel attaching
+
+// /datum/element flags
+#define ELEMENT_DETACH (1 << 0)
+
// How multiple components of the exact same type are handled in the same datum
#define COMPONENT_DUPE_HIGHLANDER 0 //old component is deleted (default)
@@ -28,7 +33,7 @@
#define COMSIG_COMPONENT_ADDED "component_added" //when a component is added to a datum: (/datum/component)
#define COMSIG_COMPONENT_REMOVING "component_removing" //before a component is removed from a datum because of RemoveComponent: (/datum/component)
#define COMSIG_PARENT_PREQDELETED "parent_preqdeleted" //before a datum's Destroy() is called: (force), returning a nonzero value will cancel the qdel operation
-#define COMSIG_PARENT_QDELETED "parent_qdeleted" //after a datum's Destroy() is called: (force, qdel_hint), at this point none of the other components chose to interrupt qdel and Destroy has been called
+#define COMSIG_PARENT_QDELETING "parent_qdeleting" //just before a datum's Destroy() is called: (force), at this point none of the other components chose to interrupt qdel and Destroy will be called
// /atom signals
#define COMSIG_PARENT_ATTACKBY "atom_attackby" //from base of atom/attackby(): (/obj/item, /mob/living, params)
diff --git a/code/__DEFINES/obj_flags.dm b/code/__DEFINES/obj_flags.dm
index d3e724aefb..94c2c372f0 100644
--- a/code/__DEFINES/obj_flags.dm
+++ b/code/__DEFINES/obj_flags.dm
@@ -25,23 +25,22 @@
#define NO_MAT_REDEMPTION (1<<5) //Stops you from putting things like an RCD or other items into an ORM or protolathe for materials.
#define DROPDEL (1<<6) //When dropped, it calls qdel on itself
#define NOBLUDGEON (1<<7) //when an item has this it produces no "X has been hit by Y with Z" message in the default attackby()
-#define ABSTRACT (1<<8) //for all things that are technically items but used for various different stuff
+#define ABSTRACT (1<<8) //for all things that are technically items but used for various different stuff
#define IMMUTABLE_SLOW (1<<9) //When players should not be able to change the slowdown of the item (Speed potions, ect)
#define SURGICAL_TOOL (1<<10) //Tool commonly used for surgery: won't attack targets in an active surgical operation on help intent (in case of mistakes)
-#define NO_UNIFORM_REQUIRED (1<<11) //Can be worn on certain slots (currently belt and id) that would otherwise require an uniform.
+#define NO_UNIFORM_REQUIRED (1<<11) //Can be worn on certain slots (currently belt and id) that would otherwise require an uniform.
// Flags for the clothing_flags var on /obj/item/clothing
#define LAVAPROTECT (1<<0)
#define STOPSPRESSUREDAMAGE (1<<1) //SUIT and HEAD items which stop pressure damage. To stop you taking all pressure damage you must have both a suit and head item with this flag.
#define BLOCK_GAS_SMOKE_EFFECT (1<<2) //blocks the effect that chemical clouds would have on a mob --glasses, mask and helmets ONLY!
-#define ALLOWINTERNALS (1<<3) //mask allows internals
+#define ALLOWINTERNALS (1<<3) //mask allows internals
#define NOSLIP (1<<4) //prevents from slipping on wet floors, in space etc
#define THICKMATERIAL (1<<5) //prevents syringes, parapens and hypos if the external suit or helmet (if targeting head) has this flag. Example: space suits, biosuit, bombsuits, thick suits that cover your body.
#define VOICEBOX_TOGGLABLE (1<<6) //The voicebox in this clothing can be toggled.
#define VOICEBOX_DISABLED (1<<7) //The voicebox is currently turned off.
-#define SNUG_FIT (1<<8) //Prevents knock-off from things like hat-throwing.
-#define ANTI_TINFOIL_MANEUVER (1<<9) //Hats with negative effects when worn (i.e the tinfoil hat).
+#define IGNORE_HAT_TOSS (1<<8) //Hats with negative effects when worn (i.e the tinfoil hat).
// Flags for the organ_flags var on /obj/item/organ
@@ -50,4 +49,4 @@
#define ORGAN_FAILING (1<<2) //Failing organs perform damaging effects until replaced or fixed
#define ORGAN_EXTERNAL (1<<3) //Was this organ implanted/inserted/etc, if true will not be removed during species change.
#define ORGAN_VITAL (1<<4) //Currently only the brain
-#define ORGAN_NO_SPOIL (1<<5) //Do not spoil under any circumstances
\ No newline at end of file
+#define ORGAN_NO_SPOIL (1<<5) //Do not spoil under any circumstances
diff --git a/code/_globalvars/bitfields.dm b/code/_globalvars/bitfields.dm
index 91f5105553..e0cf8ebdd5 100644
--- a/code/_globalvars/bitfields.dm
+++ b/code/_globalvars/bitfields.dm
@@ -142,8 +142,7 @@ GLOBAL_LIST_INIT(bitfields, list(
"THICKMATERIAL" = THICKMATERIAL,
"VOICEBOX_TOGGLABLE" = VOICEBOX_TOGGLABLE,
"VOICEBOX_DISABLED" = VOICEBOX_DISABLED,
- "SNUG_FIT" = SNUG_FIT,
- "ANTI_TINFOIL_MANEUVER" = ANTI_TINFOIL_MANEUVER,
+ "IGNORE_HAT_TOSS" = IGNORE_HAT_TOSS,
),
"tesla_flags" = list(
"TESLA_MOB_DAMAGE" = TESLA_MOB_DAMAGE,
diff --git a/code/controllers/subsystem/dcs.dm b/code/controllers/subsystem/dcs.dm
index c1e101a0e7..e94f233f04 100644
--- a/code/controllers/subsystem/dcs.dm
+++ b/code/controllers/subsystem/dcs.dm
@@ -1,6 +1,15 @@
-SUBSYSTEM_DEF(dcs)
+PROCESSING_SUBSYSTEM_DEF(dcs)
name = "Datum Component System"
- flags = SS_NO_INIT | SS_NO_FIRE
+ flags = SS_NO_INIT
+ var/list/elements_by_type = list()
-/datum/controller/subsystem/dcs/Recover()
+/datum/controller/subsystem/processing/dcs/Recover()
comp_lookup = SSdcs.comp_lookup
+
+/datum/controller/subsystem/processing/dcs/proc/GetElement(eletype)
+ . = elements_by_type[eletype]
+ if(.)
+ return
+ if(!ispath(eletype, /datum/element))
+ CRASH("Attempted to instantiate [eletype] as a /datum/element")
+ . = elements_by_type[eletype] = new eletype
\ No newline at end of file
diff --git a/code/controllers/subsystem/garbage.dm b/code/controllers/subsystem/garbage.dm
index eec9f63a12..f8ca1e7eae 100644
--- a/code/controllers/subsystem/garbage.dm
+++ b/code/controllers/subsystem/garbage.dm
@@ -98,7 +98,7 @@ SUBSYSTEM_DEF(garbage)
state = SS_RUNNING
break
-
+
/datum/controller/subsystem/garbage/proc/HandleQueue(level = GC_QUEUE_CHECK)
@@ -266,8 +266,8 @@ SUBSYSTEM_DEF(garbage)
D.gc_destroyed = GC_CURRENTLY_BEING_QDELETED
var/start_time = world.time
var/start_tick = world.tick_usage
+ SEND_SIGNAL(D, COMSIG_PARENT_QDELETING, force) // Let the (remaining) components know about the result of Destroy
var/hint = D.Destroy(arglist(args.Copy(2))) // Let our friend know they're about to get fucked up.
- SEND_SIGNAL(D, COMSIG_PARENT_QDELETED, force, hint) // Let the (remaining) components know about the result of Destroy
if(world.time != start_time)
I.slept_destroy++
else
diff --git a/code/datums/components/earhealing.dm b/code/datums/components/earhealing.dm
deleted file mode 100644
index bd3d57480d..0000000000
--- a/code/datums/components/earhealing.dm
+++ /dev/null
@@ -1,30 +0,0 @@
-// An item worn in the ear slot with this component will heal your ears each
-// Life() tick, even if normally your ears would be too damaged to heal.
-
-/datum/component/earhealing
- var/mob/living/carbon/wearer
-
-/datum/component/earhealing/Initialize()
- if(!isitem(parent))
- return COMPONENT_INCOMPATIBLE
- RegisterSignal(parent, list(COMSIG_ITEM_EQUIPPED, COMSIG_ITEM_DROPPED), .proc/equippedChanged)
-
-/datum/component/earhealing/proc/equippedChanged(datum/source, mob/living/carbon/user, slot)
- if (slot == SLOT_EARS && istype(user))
- if (!wearer)
- START_PROCESSING(SSobj, src)
- wearer = user
- else
- if (wearer)
- STOP_PROCESSING(SSobj, src)
- wearer = null
-
-/datum/component/earhealing/process()
- if (!wearer)
- STOP_PROCESSING(SSobj, src)
- return
- if(!HAS_TRAIT(wearer, TRAIT_DEAF))
- var/obj/item/organ/ears/ears = wearer.getorganslot(ORGAN_SLOT_EARS)
- if (ears)
- ears.deaf = max(ears.deaf - 1, (ears.damage < ears.maxHealth ? 0 : 1)) // Do not clear deafness if our ears are too damaged
- ears.damage = max(ears.damage - 0.1, 0)
diff --git a/code/datums/components/mood.dm b/code/datums/components/mood.dm
index b46919a6c6..a0e6f97de0 100644
--- a/code/datums/components/mood.dm
+++ b/code/datums/components/mood.dm
@@ -248,7 +248,7 @@
var/datum/hud/hud = owner.hud_used
screen_obj = new
hud.infodisplay += screen_obj
- RegisterSignal(hud, COMSIG_PARENT_QDELETED, .proc/unmodify_hud)
+ RegisterSignal(hud, COMSIG_PARENT_QDELETING, .proc/unmodify_hud)
RegisterSignal(screen_obj, COMSIG_CLICK, .proc/hud_click)
/datum/component/mood/proc/unmodify_hud(datum/source)
diff --git a/code/datums/components/virtual_reality.dm b/code/datums/components/virtual_reality.dm
index f8f0679e9b..7bad836e47 100644
--- a/code/datums/components/virtual_reality.dm
+++ b/code/datums/components/virtual_reality.dm
@@ -12,7 +12,7 @@
return COMPONENT_INCOMPATIBLE
var/mob/vr_M = parent
mastermind = M.mind
- RegisterSignal(M, list(COMSIG_MOB_DEATH, COMSIG_PARENT_QDELETED), .proc/game_over)
+ RegisterSignal(M, list(COMSIG_MOB_DEATH, COMSIG_PARENT_QDELETING), .proc/game_over)
RegisterSignal(M, COMSIG_MOB_KEY_CHANGE, .proc/switch_player)
RegisterSignal(mastermind, COMSIG_MIND_TRANSFER, .proc/switch_player)
you_die_in_the_game_you_die_for_real = yolo
@@ -32,7 +32,7 @@
current_mind = M.mind
quit_action.Grant(M)
RegisterSignal(quit_action, COMSIG_ACTION_TRIGGER, .proc/revert_to_reality)
- RegisterSignal(M, list(COMSIG_MOB_DEATH, COMSIG_PARENT_QDELETED), .proc/game_over)
+ RegisterSignal(M, list(COMSIG_MOB_DEATH, COMSIG_PARENT_QDELETING), .proc/game_over)
RegisterSignal(M, COMSIG_MOB_GHOSTIZE, .proc/be_a_quitter)
RegisterSignal(M, COMSIG_MOB_KEY_CHANGE, .proc/pass_me_the_remote)
RegisterSignal(current_mind, COMSIG_MIND_TRANSFER, .proc/pass_me_the_remote)
@@ -42,7 +42,7 @@
/datum/component/virtual_reality/UnregisterFromParent()
quit_action.Remove(parent)
- UnregisterSignal(parent, list(COMSIG_MOB_DEATH, COMSIG_PARENT_QDELETED, COMSIG_MOB_KEY_CHANGE, COMSIG_MOB_GHOSTIZE))
+ UnregisterSignal(parent, list(COMSIG_MOB_DEATH, COMSIG_PARENT_QDELETING, COMSIG_MOB_KEY_CHANGE, COMSIG_MOB_GHOSTIZE))
UnregisterSignal(current_mind, COMSIG_MIND_TRANSFER)
UnregisterSignal(quit_action, COMSIG_ACTION_TRIGGER)
current_mind = null
diff --git a/code/datums/elements/_element.dm b/code/datums/elements/_element.dm
new file mode 100644
index 0000000000..f12835d2e2
--- /dev/null
+++ b/code/datums/elements/_element.dm
@@ -0,0 +1,29 @@
+/datum/element
+ var/element_flags = NONE
+
+/datum/element/proc/Attach(datum/target)
+ if(type == /datum/element)
+ return ELEMENT_INCOMPATIBLE
+ if(element_flags & ELEMENT_DETACH)
+ RegisterSignal(target, COMSIG_PARENT_QDELETING, .proc/Detach)
+
+/datum/element/proc/Detach(datum/source, force)
+ UnregisterSignal(source, COMSIG_PARENT_QDELETING)
+
+/datum/element/Destroy(force)
+ if(!force)
+ return QDEL_HINT_LETMELIVE
+ SSdcs.elements_by_type -= type
+ return ..()
+
+//DATUM PROCS
+
+/datum/proc/AddElement(eletype, ...)
+ var/datum/element/ele = SSdcs.GetElement(eletype)
+ args[1] = src
+ if(ele.Attach(arglist(args)) == ELEMENT_INCOMPATIBLE)
+ CRASH("Incompatible [eletype] assigned to a [type]! args: [json_encode(args)]")
+
+/datum/proc/RemoveElement(eletype)
+ var/datum/element/ele = SSdcs.GetElement(eletype)
+ ele.Detach(src)
diff --git a/code/datums/components/cleaning.dm b/code/datums/elements/cleaning.dm
similarity index 79%
rename from code/datums/components/cleaning.dm
rename to code/datums/elements/cleaning.dm
index 5324a87fee..e4fb3edd48 100644
--- a/code/datums/components/cleaning.dm
+++ b/code/datums/elements/cleaning.dm
@@ -1,13 +1,15 @@
-/datum/component/cleaning
- dupe_mode = COMPONENT_DUPE_UNIQUE_PASSARGS
+/datum/element/cleaning/Attach(datum/target)
+ . = ..()
+ if(!ismovableatom(target))
+ return ELEMENT_INCOMPATIBLE
+ RegisterSignal(target, COMSIG_MOVABLE_MOVED, .proc/Clean)
-/datum/component/cleaning/Initialize()
- if(!ismovableatom(parent))
- return COMPONENT_INCOMPATIBLE
- RegisterSignal(parent, list(COMSIG_MOVABLE_MOVED), .proc/Clean)
+/datum/element/cleaning/Detach(datum/target)
+ . = ..()
+ UnregisterSignal(target, COMSIG_MOVABLE_MOVED)
-/datum/component/cleaning/proc/Clean()
- var/atom/movable/AM = parent
+/datum/element/cleaning/proc/Clean(datum/source)
+ var/atom/movable/AM = source
var/turf/T = AM.loc
SEND_SIGNAL(T, COMSIG_COMPONENT_CLEAN_ACT, CLEAN_WEAK)
for(var/A in T)
@@ -43,4 +45,4 @@
cleaned_human.clean_blood()
cleaned_human.wash_cream()
cleaned_human.regenerate_icons()
- to_chat(cleaned_human, "[src] cleans your face!")
\ No newline at end of file
+ to_chat(cleaned_human, "[src] cleans your face!")
diff --git a/code/datums/elements/earhealing.dm b/code/datums/elements/earhealing.dm
new file mode 100644
index 0000000000..7477742673
--- /dev/null
+++ b/code/datums/elements/earhealing.dm
@@ -0,0 +1,37 @@
+
+/datum/element/earhealing
+ element_flags = ELEMENT_DETACH
+ var/list/user_by_item = list()
+
+/datum/element/earhealing/New()
+ START_PROCESSING(SSdcs, src)
+
+/datum/element/earhealing/Attach(datum/target)
+ . = ..()
+ if(!isitem(target))
+ return ELEMENT_INCOMPATIBLE
+
+ RegisterSignal(target, list(COMSIG_ITEM_EQUIPPED, COMSIG_ITEM_DROPPED), .proc/equippedChanged)
+
+/datum/element/earhealing/Detach(datum/target)
+ . = ..()
+ UnregisterSignal(target, list(COMSIG_ITEM_EQUIPPED, COMSIG_ITEM_DROPPED))
+ user_by_item -= target
+
+/datum/element/earhealing/proc/equippedChanged(datum/source, mob/living/carbon/user, slot)
+ if(slot == SLOT_EARS && istype(user))
+ user_by_item[source] = user
+ else
+ user_by_item -= source
+
+/datum/element/earhealing/process()
+ for(var/i in user_by_item)
+ var/mob/living/carbon/user = user_by_item[i]
+ if(HAS_TRAIT(user, TRAIT_DEAF))
+ continue
+ var/obj/item/organ/ears/ears = user.getorganslot(ORGAN_SLOT_EARS)
+ if(!ears)
+ continue
+ ears.deaf = max(ears.deaf - 0.25, (ears.damage < ears.maxHealth ? 0 : 1)) // Do not clear deafness if our ears are too damaged
+ ears.damage = max(ears.damage - 0.025, 0)
+ CHECK_TICK
diff --git a/code/datums/mind.dm b/code/datums/mind.dm
index 5cf03e2684..0ded5f9912 100644
--- a/code/datums/mind.dm
+++ b/code/datums/mind.dm
@@ -91,7 +91,10 @@
if(current) // remove ourself from our old body's mind variable
current.mind = null
SStgui.on_transfer(current, new_character)
-
+ if(iscarbon(current))
+ var/mob/living/carbon/C = current
+ if(C.combatmode)
+ C.toggle_combat_mode(TRUE, TRUE)
if(!language_holder)
var/datum/language_holder/mob_holder = new_character.get_language_holder(shadow = FALSE)
language_holder = mob_holder.copy(src)
diff --git a/code/game/machinery/computer/communications.dm b/code/game/machinery/computer/communications.dm
index b5cb066b3a..a8b4608b36 100755
--- a/code/game/machinery/computer/communications.dm
+++ b/code/game/machinery/computer/communications.dm
@@ -42,12 +42,6 @@
. = ..()
GLOB.shuttle_caller_list += src
-/obj/machinery/computer/communications/process()
- if(..())
- var/ai_autoupdate = aistate != STATE_STATUSDISPLAY && aistate != STATE_CALLSHUTTLE && aistate != STATE_PURCHASE && aistate != STATE_VIEWMESSAGE
- var/machine_user_autoupdate = state != STATE_STATUSDISPLAY && state != STATE_CALLSHUTTLE && state != STATE_PURCHASE && state != STATE_VIEWMESSAGE
- updateDialog(machine_user_autoupdate,ai_autoupdate)
-
/obj/machinery/computer/communications/Topic(href, href_list)
if(..())
return
@@ -586,8 +580,6 @@
popup.set_content(dat)
popup.open()
- popup.set_content(dat)
- popup.open()
/obj/machinery/computer/communications/proc/get_javascript_header(form_id)
var/dat = {"