diff --git a/code/__defines/dcs/flags.dm b/code/__defines/dcs/flags.dm
index 8d3aab2aa7..b69d74571c 100644
--- a/code/__defines/dcs/flags.dm
+++ b/code/__defines/dcs/flags.dm
@@ -1,4 +1,4 @@
-/// Return this from `/datum/component/Initialize` or `datum/component/OnTransfer` to have the component be deleted if it's applied to an incorrect type.
+/// Return this from `/datum/component/Initialize` or `/datum/component/OnTransfer` or `/datum/component/on_source_add` to have the component be deleted if it's applied to an incorrect type.
/// `parent` must not be modified if this is to be returned.
/// This will be noted in the runtime logs
#define COMPONENT_INCOMPATIBLE 1
@@ -9,35 +9,56 @@
#define ELEMENT_INCOMPATIBLE 1
// /datum/element flags
-/// Causes the detach proc to be called when the host object is being deleted
-#define ELEMENT_DETACH (1 << 0)
+/// Causes the detach proc to be called when the host object is being deleted.
+/// Should only be used if you need to perform cleanup not related to the host object.
+/// You do not need this if you are only unregistering signals, for instance.
+/// You would need it if you are doing something like removing the target from a processing list.
+#define ELEMENT_DETACH_ON_HOST_DESTROY (1 << 0)
/**
- * Only elements created with the same arguments given after `id_arg_index` share an element instance
- * The arguments are the same when the text and number values are the same and all other values have the same ref
- */
-#define ELEMENT_BESPOKE (1 << 1)
+ * Only elements created with the same arguments given after `argument_hash_start_idx` share an element instance
+ * The arguments are the same when the text and number values are the same and all other values have the same ref
+ */
+#define ELEMENT_BESPOKE (1 << 1)
/// Causes all detach arguments to be passed to detach instead of only being used to identify the element
/// When this is used your Detach proc should have the same signature as your Attach proc
#define ELEMENT_COMPLEX_DETACH (1 << 2)
+/**
+ * Elements with this flag will have their datum lists arguments compared as is,
+ * without the contents being sorted alpha-numerically first.
+ * This is good for those elements where the position of the keys matter, like in the case of color matrices.
+ */
+#define ELEMENT_DONT_SORT_LIST_ARGS (1<<3)
+/**
+ * Elements with this flag will be ignored by the dcs_check_list_arguments test.
+ * A good example is connect_loc, for which it's pratically undoable unless we force every signal proc to have a different name.
+ */
+#define ELEMENT_NO_LIST_UNIT_TEST (1<<4)
// How multiple components of the exact same type are handled in the same datum
/// old component is deleted (default)
-#define COMPONENT_DUPE_HIGHLANDER 0
+#define COMPONENT_DUPE_HIGHLANDER 0
/// duplicates allowed
-#define COMPONENT_DUPE_ALLOWED 1
+#define COMPONENT_DUPE_ALLOWED 1
/// new component is deleted
-#define COMPONENT_DUPE_UNIQUE 2
+#define COMPONENT_DUPE_UNIQUE 2
+/**
+ * Component uses source tracking to manage adding and removal logic.
+ * Add a source/spawn to/the component by using AddComponentFrom(source, component_type, args...)
+ * Removing the last source will automatically remove the component from the parent.
+ * Arguments will be passed to on_source_add(source, args...); ensure that Initialize and on_source_add have the same signature.
+ */
+#define COMPONENT_DUPE_SOURCES 3
/// old component is given the initialization args of the new
-#define COMPONENT_DUPE_UNIQUE_PASSARGS 4
+#define COMPONENT_DUPE_UNIQUE_PASSARGS 4
/// each component of the same type is consulted as to whether the duplicate should be allowed
-#define COMPONENT_DUPE_SELECTIVE 5
+#define COMPONENT_DUPE_SELECTIVE 5
//Redirection component init flags
#define REDIRECT_TRANSFER_WITH_TURF 1
//Arch
-#define ARCH_PROB "probability" //Probability for each item
-#define ARCH_MAXDROP "max_drop_amount" //each item's max drop amount
+#define ARCH_PROB "probability" //Probability for each item
+#define ARCH_MAXDROP "max_drop_amount" //each item's max drop amount
//Ouch my toes!
#define CALTROP_BYPASS_SHOES 1
@@ -45,4 +66,4 @@
// Conflict element IDs
#define CONFLICT_ELEMENT_CRUSHER "crusher"
-#define CONFLICT_ELEMENT_KA "kinetic_accelerator"
\ No newline at end of file
+#define CONFLICT_ELEMENT_KA "kinetic_accelerator"
diff --git a/code/__defines/dcs/helpers.dm b/code/__defines/dcs/helpers.dm
index a7925329fd..c3f73cec12 100644
--- a/code/__defines/dcs/helpers.dm
+++ b/code/__defines/dcs/helpers.dm
@@ -2,14 +2,14 @@
/// The datum hosting the signal is automaticaly added as the first argument
/// Returns a bitfield gathered from all registered procs
/// Arguments given here are packaged in a list and given to _SendSignal
-#define SEND_SIGNAL(target, sigtype, arguments...) ( !target.comp_lookup || !target.comp_lookup[sigtype] ? NONE : target._SendSignal(sigtype, list(target, ##arguments)) )
+#define SEND_SIGNAL(target, sigtype, arguments...) ( !target._listen_lookup?[sigtype] ? NONE : target._SendSignal(sigtype, list(target, ##arguments)) )
#define SEND_GLOBAL_SIGNAL(sigtype, arguments...) ( SEND_SIGNAL(SSdcs, sigtype, ##arguments) )
/// Signifies that this proc is used to handle signals.
/// Every proc you pass to RegisterSignal must have this.
-//#define SIGNAL_HANDLER SHOULD_NOT_SLEEP(TRUE)
-#define SIGNAL_HANDLER // Sigh
+// #define SIGNAL_HANDLER SHOULD_NOT_SLEEP(TRUE) FIXME: FIXME: Causing some big issues still
+#define SIGNAL_HANDLER
/// A wrapper for _AddElement that allows us to pretend we're using normal named arguments
#define AddElement(arguments...) _AddElement(list(##arguments))
@@ -18,3 +18,10 @@
/// A wrapper for _AddComponent that allows us to pretend we're using normal named arguments
#define AddComponent(arguments...) _AddComponent(list(##arguments))
+
+/// A wrapper for _AddComonent that passes in a source.
+/// Necessary if dupe_mode is set to COMPONENT_DUPE_SOURCES.
+#define AddComponentFrom(source, arguments...) _AddComponent(list(##arguments), source)
+
+/// A wrapper for _LoadComponent that allows us to pretend we're using normal named arguments
+#define LoadComponent(arguments...) _LoadComponent(list(##arguments))
diff --git a/code/__defines/dcs/signals/signals_turf.dm b/code/__defines/dcs/signals/signals_turf.dm
new file mode 100644
index 0000000000..fae8092b22
--- /dev/null
+++ b/code/__defines/dcs/signals/signals_turf.dm
@@ -0,0 +1,2 @@
+#define COMSIG_TURF_PREPARE_STEP_SOUND "turf_prepare_step_sound"
+ #define FOOTSTEP_OVERRIDEN (1<<0)
diff --git a/code/__defines/footsteps.dm b/code/__defines/footsteps.dm
new file mode 100644
index 0000000000..d467d8f99e
--- /dev/null
+++ b/code/__defines/footsteps.dm
@@ -0,0 +1,252 @@
+#define FOOTSTEP_WOOD "wood"
+#define FOOTSTEP_FLOOR "floor"
+#define FOOTSTEP_PLATING "plating"
+#define FOOTSTEP_CARPET "carpet"
+#define FOOTSTEP_SAND "sand"
+#define FOOTSTEP_GRASS "grass"
+#define FOOTSTEP_WATER "water"
+#define FOOTSTEP_LAVA "lava"
+#define FOOTSTEP_MEAT "meat"
+#define FOOTSTEP_CATWALK "catwalk"
+//barefoot sounds
+#define FOOTSTEP_WOOD_BAREFOOT "woodbarefoot"
+#define FOOTSTEP_WOOD_CLAW "woodclaw"
+#define FOOTSTEP_WOOD_LIGHTCLAW "woodlightclaw"
+#define FOOTSTEP_HARD_BAREFOOT "hardbarefoot"
+#define FOOTSTEP_HARD_CLAW "hardclaw"
+#define FOOTSTEP_HARD_LIGHTCLAW "hardlightclaw"
+#define FOOTSTEP_CARPET_BAREFOOT "carpetbarefoot"
+//misc footstep sounds
+#define FOOTSTEP_GENERIC_HEAVY "heavy"
+
+
+//footstep mob defines
+#define FOOTSTEP_MOB_CLAW "footstep_claw"
+#define FOOTSTEP_MOB_TESHARI "footstep_lightclaw"
+#define FOOTSTEP_MOB_BAREFOOT "footstep_barefoot"
+#define FOOTSTEP_MOB_HEAVY "footstep_heavy"
+#define FOOTSTEP_MOB_SHOE "footstep_shoe"
+#define FOOTSTEP_MOB_HUMAN "footstep_human"
+#define FOOTSTEP_MOB_SLIME "footstep_slime"
+#define FOOTSTEP_MOB_SLITHER "foostep_slither"
+#define FOOTSTEP_OBJ_MACHINE "footstep_machine"
+#define FOOTSTEP_OBJ_ROBOT "footstep_robot"
+
+//priority defines for the footstep_override element
+#define STEP_SOUND_NO_PRIORITY 0
+#define STEP_SOUND_CONVEYOR_PRIORITY 1
+#define STEP_SOUND_TABLE_PRIORITY 2
+
+///the name of the index key for priority
+#define STEP_SOUND_PRIORITY "step_sound_priority"
+
+/*
+Below is how the following lists are defined
+
+id = list(
+list(sounds),
+base volume,
+extra range addition
+)
+*/
+
+GLOBAL_LIST_INIT(footstep, list(
+ FOOTSTEP_WOOD = list(list(
+ 'sound/effects/footstep/wood1.ogg',
+ 'sound/effects/footstep/wood2.ogg',
+ 'sound/effects/footstep/wood3.ogg',
+ 'sound/effects/footstep/wood4.ogg',
+ 'sound/effects/footstep/wood5.ogg'), 100, 0),
+ FOOTSTEP_FLOOR = list(list(
+ 'sound/effects/footstep/floor1.ogg',
+ 'sound/effects/footstep/floor2.ogg',
+ 'sound/effects/footstep/floor3.ogg',
+ 'sound/effects/footstep/floor4.ogg',
+ 'sound/effects/footstep/floor5.ogg'), 75, -1),
+ FOOTSTEP_PLATING = list(list(
+ 'sound/effects/footstep/plating1.ogg',
+ 'sound/effects/footstep/plating2.ogg',
+ 'sound/effects/footstep/plating3.ogg',
+ 'sound/effects/footstep/plating4.ogg',
+ 'sound/effects/footstep/plating5.ogg'), 100, 1),
+ FOOTSTEP_CARPET = list(list(
+ 'sound/effects/footstep/carpet1.ogg',
+ 'sound/effects/footstep/carpet2.ogg',
+ 'sound/effects/footstep/carpet3.ogg',
+ 'sound/effects/footstep/carpet4.ogg',
+ 'sound/effects/footstep/carpet5.ogg'), 75, -1),
+ FOOTSTEP_SAND = list(list(
+ 'sound/effects/footstep/asteroid1.ogg',
+ 'sound/effects/footstep/asteroid2.ogg',
+ 'sound/effects/footstep/asteroid3.ogg',
+ 'sound/effects/footstep/asteroid4.ogg',
+ 'sound/effects/footstep/asteroid5.ogg'), 75, 0),
+ FOOTSTEP_GRASS = list(list(
+ 'sound/effects/footstep/grass1.ogg',
+ 'sound/effects/footstep/grass2.ogg',
+ 'sound/effects/footstep/grass3.ogg',
+ 'sound/effects/footstep/grass4.ogg'), 75, 0),
+ FOOTSTEP_WATER = list(list(
+ 'sound/effects/footstep/water1.ogg',
+ 'sound/effects/footstep/water2.ogg',
+ 'sound/effects/footstep/water3.ogg',
+ 'sound/effects/footstep/water4.ogg'), 100, 1),
+ FOOTSTEP_LAVA = list(list(
+ 'sound/effects/footstep/lava1.ogg',
+ 'sound/effects/footstep/lava2.ogg',
+ 'sound/effects/footstep/lava3.ogg'), 100, 0),
+ FOOTSTEP_MEAT = list(list(
+ 'sound/effects/meatslap.ogg'), 100, 0),
+ FOOTSTEP_CATWALK = list(list(
+ 'sound/effects/footstep/catwalk1.ogg',
+ 'sound/effects/footstep/catwalk2.ogg',
+ 'sound/effects/footstep/catwalk3.ogg',
+ 'sound/effects/footstep/catwalk4.ogg',
+ 'sound/effects/footstep/catwalk5.ogg'), 100, 1),
+))
+
+//bare footsteps lists
+GLOBAL_LIST_INIT(barefootstep, list(
+ FOOTSTEP_WOOD_BAREFOOT = list(list(
+ 'sound/effects/footstep/woodbarefoot1.ogg',
+ 'sound/effects/footstep/woodbarefoot2.ogg',
+ 'sound/effects/footstep/woodbarefoot3.ogg',
+ 'sound/effects/footstep/woodbarefoot4.ogg',
+ 'sound/effects/footstep/woodbarefoot5.ogg'), 80, -1),
+ FOOTSTEP_HARD_BAREFOOT = list(list(
+ 'sound/effects/footstep/hardbarefoot1.ogg',
+ 'sound/effects/footstep/hardbarefoot2.ogg',
+ 'sound/effects/footstep/hardbarefoot3.ogg',
+ 'sound/effects/footstep/hardbarefoot4.ogg',
+ 'sound/effects/footstep/hardbarefoot5.ogg'), 80, -1),
+ FOOTSTEP_CARPET_BAREFOOT = list(list(
+ 'sound/effects/footstep/carpetbarefoot1.ogg',
+ 'sound/effects/footstep/carpetbarefoot2.ogg',
+ 'sound/effects/footstep/carpetbarefoot3.ogg',
+ 'sound/effects/footstep/carpetbarefoot4.ogg',
+ 'sound/effects/footstep/carpetbarefoot5.ogg'), 75, -1),
+ FOOTSTEP_SAND = list(list(
+ 'sound/effects/footstep/asteroid1.ogg',
+ 'sound/effects/footstep/asteroid2.ogg',
+ 'sound/effects/footstep/asteroid3.ogg',
+ 'sound/effects/footstep/asteroid4.ogg',
+ 'sound/effects/footstep/asteroid5.ogg'), 75, 0),
+ FOOTSTEP_GRASS = list(list(
+ 'sound/effects/footstep/grass1.ogg',
+ 'sound/effects/footstep/grass2.ogg',
+ 'sound/effects/footstep/grass3.ogg',
+ 'sound/effects/footstep/grass4.ogg'), 75, 0),
+ FOOTSTEP_WATER = list(list(
+ 'sound/effects/footstep/water1.ogg',
+ 'sound/effects/footstep/water2.ogg',
+ 'sound/effects/footstep/water3.ogg',
+ 'sound/effects/footstep/water4.ogg'), 100, 1),
+ FOOTSTEP_LAVA = list(list(
+ 'sound/effects/footstep/lava1.ogg',
+ 'sound/effects/footstep/lava2.ogg',
+ 'sound/effects/footstep/lava3.ogg'), 100, 0),
+ FOOTSTEP_MEAT = list(list(
+ 'sound/effects/meatslap.ogg'), 100, 0),
+))
+
+//claw footsteps lists
+GLOBAL_LIST_INIT(clawfootstep, list(
+ FOOTSTEP_WOOD_BAREFOOT = list(list(
+ 'sound/effects/footstep/woodclaw1.ogg',
+ 'sound/effects/footstep/woodclaw2.ogg',
+ 'sound/effects/footstep/woodclaw3.ogg',
+ 'sound/effects/footstep/woodclaw2.ogg',
+ 'sound/effects/footstep/woodclaw1.ogg'), 90, 1),
+ FOOTSTEP_HARD_BAREFOOT = list(list(
+ 'sound/effects/footstep/hardclaw1.ogg',
+ 'sound/effects/footstep/hardclaw2.ogg',
+ 'sound/effects/footstep/hardclaw3.ogg',
+ 'sound/effects/footstep/hardclaw4.ogg',
+ 'sound/effects/footstep/hardclaw1.ogg'), 90, 1),
+ FOOTSTEP_CARPET_BAREFOOT = list(list(
+ 'sound/effects/footstep/carpetbarefoot1.ogg',
+ 'sound/effects/footstep/carpetbarefoot2.ogg',
+ 'sound/effects/footstep/carpetbarefoot3.ogg',
+ 'sound/effects/footstep/carpetbarefoot4.ogg',
+ 'sound/effects/footstep/carpetbarefoot5.ogg'), 75, -2),
+ FOOTSTEP_SAND = list(list(
+ 'sound/effects/footstep/asteroid1.ogg',
+ 'sound/effects/footstep/asteroid2.ogg',
+ 'sound/effects/footstep/asteroid3.ogg',
+ 'sound/effects/footstep/asteroid4.ogg',
+ 'sound/effects/footstep/asteroid5.ogg'), 75, 0),
+ FOOTSTEP_GRASS = list(list(
+ 'sound/effects/footstep/grass1.ogg',
+ 'sound/effects/footstep/grass2.ogg',
+ 'sound/effects/footstep/grass3.ogg',
+ 'sound/effects/footstep/grass4.ogg'), 75, 0),
+ FOOTSTEP_WATER = list(list(
+ 'sound/effects/footstep/water1.ogg',
+ 'sound/effects/footstep/water2.ogg',
+ 'sound/effects/footstep/water3.ogg',
+ 'sound/effects/footstep/water4.ogg'), 100, 1),
+ FOOTSTEP_LAVA = list(list(
+ 'sound/effects/footstep/lava1.ogg',
+ 'sound/effects/footstep/lava2.ogg',
+ 'sound/effects/footstep/lava3.ogg'), 100, 0),
+ FOOTSTEP_MEAT = list(list(
+ 'sound/effects/meatslap.ogg'), 100, 0),
+))
+
+//light claw footsteps list
+GLOBAL_LIST_INIT(lightclawfootstep, list(
+ FOOTSTEP_WOOD_BAREFOOT = list(list(
+ 'sound/effects/footstep/BudgieStep1.ogg',
+ 'sound/effects/footstep/BudgieStep2.ogg',
+ 'sound/effects/footstep/BudgieStep3.ogg',
+ 'sound/effects/footstep/BudgieStep4.ogg',
+ 'sound/effects/footstep/BudgieStep5.ogg',
+ 'sound/effects/footstep/BudgieStep6.ogg'), 90, 1),
+ FOOTSTEP_HARD_BAREFOOT = list(list(
+ 'sound/effects/footstep/BudgieStep1.ogg',
+ 'sound/effects/footstep/BudgieStep2.ogg',
+ 'sound/effects/footstep/BudgieStep3.ogg',
+ 'sound/effects/footstep/BudgieStep4.ogg',
+ 'sound/effects/footstep/BudgieStep5.ogg',
+ 'sound/effects/footstep/BudgieStep6.ogg'), 90, 1),
+ FOOTSTEP_CARPET_BAREFOOT = list(list(
+ 'sound/effects/footstep/asteroid1.ogg',
+ 'sound/effects/footstep/asteroid2.ogg',
+ 'sound/effects/footstep/asteroid3.ogg',
+ 'sound/effects/footstep/asteroid4.ogg',
+ 'sound/effects/footstep/asteroid5.ogg'), 75, -2),
+ FOOTSTEP_GRASS = list(list(
+ 'sound/effects/footstep/grass1.ogg',
+ 'sound/effects/footstep/grass2.ogg',
+ 'sound/effects/footstep/grass3.ogg',
+ 'sound/effects/footstep/grass4.ogg'), 75, 0),
+ FOOTSTEP_WATER = list(list(
+ 'sound/effects/footstep/water1.ogg',
+ 'sound/effects/footstep/water2.ogg',
+ 'sound/effects/footstep/water3.ogg',
+ 'sound/effects/footstep/water4.ogg'), 100, 1),
+ FOOTSTEP_LAVA = list(list(
+ 'sound/effects/footstep/lava1.ogg',
+ 'sound/effects/footstep/lava2.ogg',
+ 'sound/effects/footstep/lava3.ogg'), 100, 0),
+ FOOTSTEP_MEAT = list(list(
+ 'sound/effects/meatslap.ogg'), 100, 0),
+))
+
+//heavy footsteps list
+GLOBAL_LIST_INIT(heavyfootstep, list(
+ FOOTSTEP_GENERIC_HEAVY = list(list(
+ 'sound/effects/footstep/heavy1.ogg',
+ 'sound/effects/footstep/heavy2.ogg'), 100, 2),
+ FOOTSTEP_WATER = list(list(
+ 'sound/effects/footstep/water1.ogg',
+ 'sound/effects/footstep/water2.ogg',
+ 'sound/effects/footstep/water3.ogg',
+ 'sound/effects/footstep/water4.ogg'), 100, 2),
+ FOOTSTEP_LAVA = list(list(
+ 'sound/effects/footstep/lava1.ogg',
+ 'sound/effects/footstep/lava2.ogg',
+ 'sound/effects/footstep/lava3.ogg'), 100, 0),
+ FOOTSTEP_MEAT = list(list(
+ 'sound/effects/meatslap.ogg'), 100, 0),
+))
diff --git a/code/__defines/slosh.dm b/code/__defines/slosh.dm
new file mode 100644
index 0000000000..b501f8ffe2
--- /dev/null
+++ b/code/__defines/slosh.dm
@@ -0,0 +1,11 @@
+GLOBAL_LIST_INIT(slosh, list(
+ 'sound/vore/walkslosh2.ogg',
+ 'sound/vore/walkslosh3.ogg',
+ 'sound/vore/walkslosh4.ogg',
+ 'sound/vore/walkslosh5.ogg',
+ 'sound/vore/walkslosh6.ogg',
+ 'sound/vore/walkslosh7.ogg',
+ 'sound/vore/walkslosh8.ogg',
+ 'sound/vore/walkslosh9.ogg',
+ 'sound/vore/walkslosh10.ogg'
+))
diff --git a/code/__defines/traits.dm b/code/__defines/traits.dm
index 994f1a3247..4a3fa947c7 100644
--- a/code/__defines/traits.dm
+++ b/code/__defines/traits.dm
@@ -1,2 +1,213 @@
+/*
+Remember to update _globalvars/traits.dm if you're adding/removing/renaming traits.
+*/
+
+/*
+//mob traits
+#define TRAIT_BLIND "blind"
+*/
+#define TRAIT_MUTE "mute"
+/*
+#define TRAIT_EMOTEMUTE "emotemute"
+#define TRAIT_DEAF "deaf"
+#define TRAIT_NEARSIGHT "nearsighted"
+#define TRAIT_FAT "fat"
+#define TRAIT_HUSK "husk"
+#define TRAIT_BADDNA "baddna"
+#define TRAIT_CLUMSY "clumsy"
+#define TRAIT_CHUNKYFINGERS "chunkyfingers" //means that you can't use weapons with normal trigger guards.
+#define TRAIT_DUMB "dumb"
+#define TRAIT_MONKEYLIKE "monkeylike" //sets IsAdvancedToolUser to FALSE
+#define TRAIT_PACIFISM "pacifism"
+#define TRAIT_IGNORESLOWDOWN "ignoreslow"
+#define TRAIT_IGNOREDAMAGESLOWDOWN "ignoredamageslowdown"
+#define TRAIT_DEATHCOMA "deathcoma" //Causes death-like unconsciousness
+#define TRAIT_FAKEDEATH "fakedeath" //Makes the owner appear as dead to most forms of medical examination
+#define TRAIT_DISFIGURED "disfigured"
+*/
+#define TRAIT_XENO_HOST "xeno_host" //Tracks whether we're gonna be a baby alien's mummy.
+#define TRAIT_MIMING "miming" //Tracks whether you're a mime or not.
+/*
+#define TRAIT_STUNIMMUNE "stun_immunity"
+#define TRAIT_STUNRESISTANCE "stun_resistance"
+#define TRAIT_SLEEPIMMUNE "sleep_immunity"
+#define TRAIT_PUSHIMMUNE "push_immunity"
+#define TRAIT_SHOCKIMMUNE "shock_immunity"
+#define TRAIT_STABLEHEART "stable_heart"
+#define TRAIT_STABLELIVER "stable_liver"
+#define TRAIT_RESISTHEAT "resist_heat"
+#define TRAIT_RESISTHEATHANDS "resist_heat_handsonly" //For when you want to be able to touch hot things, but still want fire to be an issue.
+#define TRAIT_RESISTCOLD "resist_cold"
+#define TRAIT_RESISTHIGHPRESSURE "resist_high_pressure"
+#define TRAIT_RESISTLOWPRESSURE "resist_low_pressure"
+#define TRAIT_RADIMMUNE "rad_immunity"
+#define TRAIT_VIRUSIMMUNE "virus_immunity"
+#define TRAIT_PIERCEIMMUNE "pierce_immunity"
+#define TRAIT_NODISMEMBER "dismember_immunity"
+#define TRAIT_NOFIRE "nonflammable"
+#define TRAIT_NOGUNS "no_guns"
+#define TRAIT_NOHUNGER "no_hunger"
+#define TRAIT_NOMETABOLISM "no_metabolism"
+#define TRAIT_TOXIMMUNE "toxin_immune"
+#define TRAIT_EASYDISMEMBER "easy_dismember"
+#define TRAIT_LIMBATTACHMENT "limb_attach"
+#define TRAIT_NOLIMBDISABLE "no_limb_disable"
+#define TRAIT_EASYLIMBDISABLE "easy_limb_disable"
+#define TRAIT_TOXINLOVER "toxinlover"
+#define TRAIT_NOBREATH "no_breath"
+*/
+#define TRAIT_ANTIMAGIC "anti_magic"
+#define TRAIT_HOLY "holy"
+/*
+#define TRAIT_DEPRESSION "depression"
+#define TRAIT_JOLLY "jolly"
+#define TRAIT_NOCRITDAMAGE "no_crit"
+#define TRAIT_NOSLIPWATER "noslip_water"
+#define TRAIT_NOSLIPALL "noslip_all"
+#define TRAIT_NODEATH "nodeath"
+#define TRAIT_NOHARDCRIT "nohardcrit"
+#define TRAIT_NOSOFTCRIT "nosoftcrit"
+#define TRAIT_MINDSHIELD "mindshield"
+#define TRAIT_DISSECTED "dissected"
+#define TRAIT_SIXTHSENSE "sixth_sense" //I can hear dead people
+#define TRAIT_FEARLESS "fearless"
+#define TRAIT_PARALYSIS_L_ARM "para-l-arm" //These are used for brain-based paralysis, where replacing the limb won't fix it
+#define TRAIT_PARALYSIS_R_ARM "para-r-arm"
+#define TRAIT_PARALYSIS_L_LEG "para-l-leg"
+#define TRAIT_PARALYSIS_R_LEG "para-r-leg"
+#define TRAIT_CANNOT_OPEN_PRESENTS "cannot-open-presents"
+#define TRAIT_PRESENT_VISION "present-vision"
+#define TRAIT_DISK_VERIFIER "disk-verifier"
+#define TRAIT_NOMOBSWAP "no-mob-swap"
+#define TRAIT_XRAY_VISION "xray_vision"
+#define TRAIT_THERMAL_VISION "thermal_vision"
+#define TRAIT_ABDUCTOR_TRAINING "abductor-training"
+#define TRAIT_ABDUCTOR_SCIENTIST_TRAINING "abductor-scientist-training"
+#define TRAIT_SURGEON "surgeon"
+#define TRAIT_STRONG_GRABBER "strong_grabber"
+#define TRAIT_MAGIC_CHOKE "magic_choke"
+#define TRAIT_SOOTHED_THROAT "soothed-throat"
+#define TRAIT_LAW_ENFORCEMENT_METABOLISM "law-enforcement-metabolism"
+#define TRAIT_ALWAYS_CLEAN "always-clean"
+#define TRAIT_BOOZE_SLIDER "booze-slider"
+#define TRAIT_UNINTELLIGIBLE_SPEECH "unintelligible-speech"
+#define TRAIT_UNSTABLE "unstable"
+#define TRAIT_OIL_FRIED "oil_fried"
+#define TRAIT_MEDICAL_HUD "med_hud"
+#define TRAIT_SECURITY_HUD "sec_hud"
+#define TRAIT_MEDIBOTCOMINGTHROUGH "medibot" //Is a medibot healing you
+#define TRAIT_PASSTABLE "passtable"
+
+//non-mob traits
+#define TRAIT_PARALYSIS "paralysis" //Used for limb-based paralysis, where replacing the limb will fix it
+
+// item traits
+*/
+#define TRAIT_NODROP "nodrop"
+#define TRAIT_DISRUPTED "disrupted"
+/*
+#define TRAIT_T_RAY_VISIBLE "t-ray-visible" // Visible on t-ray scanners if the atom/var/level == 1
+#define TRAIT_NO_TELEPORT "no-teleport" //you just can't
+
+//quirk traits
+#define TRAIT_ALCOHOL_TOLERANCE "alcohol_tolerance"
+#define TRAIT_AGEUSIA "ageusia"
+#define TRAIT_HEAVY_SLEEPER "heavy_sleeper"
+#define TRAIT_NIGHT_VISION "night_vision"
+#define TRAIT_LIGHT_STEP "light_step"
+#define TRAIT_SPIRITUAL "spiritual"
+#define TRAIT_VORACIOUS "voracious"
+#define TRAIT_SELF_AWARE "self_aware"
+#define TRAIT_FREERUNNING "freerunning"
+#define TRAIT_SKITTISH "skittish"
+#define TRAIT_POOR_AIM "poor_aim"
+#define TRAIT_PROSOPAGNOSIA "prosopagnosia"
+#define TRAIT_DRUNK_HEALING "drunk_healing"
+#define TRAIT_TAGGER "tagger"
+#define TRAIT_PHOTOGRAPHER "photographer"
+#define TRAIT_MUSICIAN "musician"
+#define TRAIT_LIGHT_DRINKER "light_drinker"
+#define TRAIT_EMPATH "empath"
+#define TRAIT_FRIENDLY "friendly"
+#define TRAIT_GRABWEAKNESS "grab_weakness"
+
+// common trait sources
+#define TRAIT_GENERIC "generic"
+#define EYE_DAMAGE "eye_damage"
+#define GENETIC_MUTATION "genetic"
+#define OBESITY "obesity"
+*/
+#define MAGIC_TRAIT "magic"
+/*
+#define TRAUMA_TRAIT "trauma"
+#define DISEASE_TRAIT "disease"
+#define SPECIES_TRAIT "species"
+#define ORGAN_TRAIT "organ"
+*/
+#define ROUNDSTART_TRAIT "roundstart" //cannot be removed without admin intervention
+#define JOB_TRAIT "job"
+#define TRAIT_MIME "mime" //Mime trait.
+/*
+#define CYBORG_ITEM_TRAIT "cyborg-item"
+*/
+#define ADMIN_TRAIT "admin" // (B)admins only.
+/*
+#define CHANGELING_TRAIT "changeling"
+#define CULT_TRAIT "cult"
+#define CURSED_ITEM_TRAIT "cursed-item" // The item is magically cursed
+#define ABSTRACT_ITEM_TRAIT "abstract-item"
+#define STATUS_EFFECT_TRAIT "status-effect"
+*/
+#define CLOTHING_TRAIT "clothing"
+/*
+#define GLASSES_TRAIT "glasses"
+#define VEHICLE_TRAIT "vehicle" // inherited from riding vehicles
+#define INNATE_TRAIT "innate"
+
+// unique trait sources, still defines
+#define CLONING_POD_TRAIT "cloning-pod"
+#define STATUE_MUTE "statue"
+#define CHANGELING_DRAIN "drain"
+#define CHANGELING_HIVEMIND_MUTE "ling_mute"
+#define ABYSSAL_GAZE_BLIND "abyssal_gaze"
+#define HIGHLANDER "highlander"
+#define TRAIT_HULK "hulk"
+#define STASIS_MUTE "stasis"
+#define GENETICS_SPELL "genetics_spell"
+#define EYES_COVERED "eyes_covered"
+#define CULT_EYES "cult_eyes"
+#define TRAIT_SANTA "santa"
+#define SCRYING_ORB "scrying-orb"
+#define ABDUCTOR_ANTAGONIST "abductor-antagonist"
+#define NUKEOP_TRAIT "nuke-op"
+#define DEATHSQUAD_TRAIT "deathsquad"
+#define MEGAFAUNA_TRAIT "megafauna"
+#define CLOWN_NUKE_TRAIT "clown-nuke"
+#define STICKY_MOUSTACHE_TRAIT "sticky-moustache"
+#define CHAINSAW_FRENZY_TRAIT "chainsaw-frenzy"
+#define CHRONO_GUN_TRAIT "chrono-gun"
+#define REVERSE_BEAR_TRAP_TRAIT "reverse-bear-trap"
+#define CURSED_MASK_TRAIT "cursed-mask"
+#define HIS_GRACE_TRAIT "his-grace"
+*/
+#define HAND_REPLACEMENT_TRAIT "magic-hand"
+/*
+#define HOT_POTATO_TRAIT "hot-potato"
+#define SABRE_SUICIDE_TRAIT "sabre-suicide"
+#define ABDUCTOR_VEST_TRAIT "abductor-vest"
+#define CAPTURE_THE_FLAG_TRAIT "capture-the-flag"
+#define EYE_OF_GOD_TRAIT "eye-of-god"
+#define SHAMEBRERO_TRAIT "shamebrero"
+#define CHRONOSUIT_TRAIT "chronosuit"
+#define LOCKED_HELMET_TRAIT "locked-helmet"
+#define NINJA_SUIT_TRAIT "ninja-suit"
+#define ANTI_DROP_IMPLANT_TRAIT "anti-drop-implant"
+#define VR_ZONE_TRAIT "vr_zone_trait"
+#define SLEEPING_CARP_TRAIT "sleeping_carp"
+#define SANGUIOSE_TRAIT "sanguiose"
+#define FROGENITE_TRAIT "frogenite"
+#define FERVEATIUM_TRAIT "ferveatium"
+*/
+
#define ORGANICS 1
#define SYNTHETICS 2
diff --git a/code/__defines/traits/_traits.dm b/code/__defines/traits/_traits.dm
index 46fef90160..3258db96f2 100644
--- a/code/__defines/traits/_traits.dm
+++ b/code/__defines/traits/_traits.dm
@@ -5,118 +5,59 @@
#define ADD_TRAIT(target, trait, source) \
do { \
var/list/_L; \
- if (!target._status_traits) { \
- target._status_traits = list(); \
- _L = target._status_traits; \
+ if (!target.status_traits) { \
+ target.status_traits = list(); \
+ _L = target.status_traits; \
_L[trait] = list(source); \
- SEND_SIGNAL(target, SIGNAL_ADDTRAIT(trait), trait); \
} else { \
- _L = target._status_traits; \
+ _L = target.status_traits; \
if (_L[trait]) { \
_L[trait] |= list(source); \
} else { \
_L[trait] = list(source); \
- SEND_SIGNAL(target, SIGNAL_ADDTRAIT(trait), trait); \
} \
} \
} while (0)
#define REMOVE_TRAIT(target, trait, sources) \
do { \
- var/list/_L = target._status_traits; \
+ var/list/_L = target.status_traits; \
var/list/_S; \
if (sources && !islist(sources)) { \
_S = list(sources); \
} else { \
_S = sources\
}; \
- if (_L?[trait]) { \
+ if (_L && _L[trait]) { \
for (var/_T in _L[trait]) { \
if ((!_S && (_T != ROUNDSTART_TRAIT)) || (_T in _S)) { \
_L[trait] -= _T \
} \
};\
if (!length(_L[trait])) { \
- _L -= trait; \
- SEND_SIGNAL(target, SIGNAL_REMOVETRAIT(trait), trait); \
+ _L -= trait \
}; \
if (!length(_L)) { \
- target._status_traits = null \
- }; \
- } \
- } while (0)
-#define REMOVE_TRAIT_NOT_FROM(target, trait, sources) \
- do { \
- var/list/_traits_list = target._status_traits; \
- var/list/_sources_list; \
- if (sources && !islist(sources)) { \
- _sources_list = list(sources); \
- } else { \
- _sources_list = sources\
- }; \
- if (_traits_list?[trait]) { \
- for (var/_trait_source in _traits_list[trait]) { \
- if (!(_trait_source in _sources_list)) { \
- _traits_list[trait] -= _trait_source \
- } \
- };\
- if (!length(_traits_list[trait])) { \
- _traits_list -= trait; \
- SEND_SIGNAL(target, SIGNAL_REMOVETRAIT(trait), trait); \
- }; \
- if (!length(_traits_list)) { \
- target._status_traits = null \
+ target.status_traits = null \
}; \
} \
} while (0)
#define REMOVE_TRAITS_NOT_IN(target, sources) \
do { \
- var/list/_L = target._status_traits; \
+ var/list/_L = target.status_traits; \
var/list/_S = sources; \
if (_L) { \
for (var/_T in _L) { \
_L[_T] &= _S;\
if (!length(_L[_T])) { \
- _L -= _T; \
- SEND_SIGNAL(target, SIGNAL_REMOVETRAIT(_T), _T); \
- }; \
+ _L -= _T } \
+ };\
+ if (!length(_L)) { \
+ target.status_traits = null\
};\
- if (!length(_L)) { \
- target._status_traits = null\
- };\
}\
} while (0)
-#define REMOVE_TRAITS_IN(target, sources) \
- do { \
- var/list/_L = target._status_traits; \
- var/list/_S = sources; \
- if (sources && !islist(sources)) { \
- _S = list(sources); \
- } else { \
- _S = sources\
- }; \
- if (_L) { \
- for (var/_T in _L) { \
- _L[_T] -= _S;\
- if (!length(_L[_T])) { \
- _L -= _T; \
- SEND_SIGNAL(target, SIGNAL_REMOVETRAIT(_T)); \
- }; \
- };\
- if (!length(_L)) { \
- target._status_traits = null\
- };\
- }\
- } while (0)
-
-#define HAS_TRAIT(target, trait) (target._status_traits?[trait] ? TRUE : FALSE)
-#define HAS_TRAIT_FROM(target, trait, source) (HAS_TRAIT(target, trait) && (source in target._status_traits[trait]))
-#define HAS_TRAIT_FROM_ONLY(target, trait, source) (HAS_TRAIT(target, trait) && (source in target._status_traits[trait]) && (length(target._status_traits[trait]) == 1))
-#define HAS_TRAIT_NOT_FROM(target, trait, source) (HAS_TRAIT(target, trait) && (length(target._status_traits[trait] - source) > 0))
-/// Returns a list of trait sources for this trait. Only useful for wacko cases and internal futzing
-/// You should not be using this
-#define GET_TRAIT_SOURCES(target, trait) (target._status_traits?[trait] || list())
-/// Returns the amount of sources for a trait. useful if you don't want to have a "thing counter" stuck around all the time
-#define COUNT_TRAIT_SOURCES(target, trait) length(GET_TRAIT_SOURCES(target, trait))
-/// A simple helper for checking traits in a mob's mind
-#define HAS_MIND_TRAIT(target, trait) (HAS_TRAIT(target, trait) || (target.mind ? HAS_TRAIT(target.mind, trait) : FALSE))
+#define HAS_TRAIT(target, trait) (target.status_traits ? (target.status_traits[trait] ? TRUE : FALSE) : FALSE)
+#define HAS_TRAIT_FROM(target, trait, source) (target.status_traits ? (target.status_traits[trait] ? (source in target.status_traits[trait]) : FALSE) : FALSE)
+#define HAS_TRAIT_FROM_ONLY(target, trait, source) (HAS_TRAIT(target, trait) && (source in target.status_traits[trait]) && (length(target.status_traits[trait]) == 1))
+#define HAS_TRAIT_NOT_FROM(target, trait, source) (HAS_TRAIT(target, trait) && (length(target.status_traits[trait] - source) > 0))
diff --git a/code/__defines/traits/sources.dm b/code/__defines/traits/sources.dm
index 9e282a693d..ff5bb187cc 100644
--- a/code/__defines/traits/sources.dm
+++ b/code/__defines/traits/sources.dm
@@ -2,6 +2,6 @@
// Several things such as `type` or `REF(src)` may be used in the ADD_TRAIT() macro as the "source", but this file contains all of the defines for immutable static strings.
/// cannot be removed without admin intervention
-#define ROUNDSTART_TRAIT "roundstart"
+// #define ROUNDSTART_TRAIT "roundstart"
/// This trait comes from when a mob is currently typing.
#define CURRENTLY_TYPING_TRAIT "currently_typing"
diff --git a/code/_helpers/global_lists.dm b/code/_helpers/global_lists.dm
index a687776f88..a0c910a089 100644
--- a/code/_helpers/global_lists.dm
+++ b/code/_helpers/global_lists.dm
@@ -358,3 +358,10 @@ GLOBAL_LIST_EMPTY(legacy_globals)
GLOB.legacy_globals["cameranet"] = cameranet
GLOB.legacy_globals["cultnet"] = cultnet
GLOB.legacy_globals["existing_solargrubs"] = existing_solargrubs
+
+var/global/list/selectable_footstep = list(
+ "Default" = FOOTSTEP_MOB_HUMAN,
+ "Claw" = FOOTSTEP_MOB_CLAW,
+ "Light Claw" = FOOTSTEP_MOB_TESHARI,
+ "Slither" = FOOTSTEP_MOB_SLITHER,
+)
diff --git a/code/_helpers/sorts/comparators.dm b/code/_helpers/sorts/comparators.dm
index 2f1b69191c..01127df1d4 100644
--- a/code/_helpers/sorts/comparators.dm
+++ b/code/_helpers/sorts/comparators.dm
@@ -58,8 +58,8 @@
. = B[STAT_ENTRY_COUNT] - A[STAT_ENTRY_COUNT]
/proc/cmp_typepaths_asc(A, B)
- return sorttext("[B]","[A]")
-
+ return sorttext("[B]","[A]")
+
/**
* Sorts crafting recipe requirements before the crafting recipe is inserted into GLOB.crafting_recipes
*
@@ -83,7 +83,7 @@
/proc/cmp_media_track_asc(datum/track/A, datum/track/B)
var/genre_sort = sorttext(B.genre || "Uncategorized", A.genre || "Uncategorized")
return genre_sort || sorttext(B.title, A.title)
-
+
///Filters have a numerical priority.
/proc/cmp_filter_data_priority(list/A, list/B)
return A["priority"] - B["priority"]
@@ -97,4 +97,18 @@
return A.sort_hint == B.sort_hint ? sorttext("[B.name]","[A.name]") : A.sort_hint - B.sort_hint
/proc/cmp_stored_item_name(datum/stored_item/A, datum/stored_item/B)
- return sorttext(B.item_name, A.item_name)
\ No newline at end of file
+ return sorttext(B.item_name, A.item_name)
+
+/proc/cmp_embed_text_asc(a,b)
+ if(isdatum(a))
+ a = REF(a)
+ if(isdatum(b))
+ b = REF(b)
+ return sorttext("[b]", "[a]")
+
+/proc/cmp_embed_text_dsc(a,b)
+ if(isdatum(a))
+ a = REF(a)
+ if(isdatum(b))
+ b = REF(b)
+ return sorttext("[a]", "[b]")
diff --git a/code/_onclick/hud/action/action_item_overlay.dm b/code/_onclick/hud/action/action_item_overlay.dm
index 7d1af7309e..99931ff3e7 100644
--- a/code/_onclick/hud/action/action_item_overlay.dm
+++ b/code/_onclick/hud/action/action_item_overlay.dm
@@ -22,7 +22,7 @@
src.item_ref = WEAKREF(item)
src.item_callback = item_callback
-/datum/component/action_item_overlay/Destroy(force, silent)
+/datum/component/action_item_overlay/Destroy(force)
item_ref = null
QDEL_NULL(item_callback)
item_appearance = null
diff --git a/code/controllers/subsystems/dcs.dm b/code/controllers/subsystems/dcs.dm
index 104c3eef31..6cd377329c 100644
--- a/code/controllers/subsystems/dcs.dm
+++ b/code/controllers/subsystems/dcs.dm
@@ -5,10 +5,34 @@ PROCESSING_SUBSYSTEM_DEF(dcs)
var/list/elements_by_type = list()
-/datum/controller/subsystem/processing/dcs/Recover()
- comp_lookup = SSdcs.comp_lookup
+ /**
+ * A nested assoc list of bespoke element types (keys) and superlists containing all lists used as arguments (values).
+ * Inside the superlists, lists that've been sorted alphabetically are keys, while the original unsorted lists are values.
+ *
+ * e.g. list(
+ * /datum/element/first = list(list(A, B, C) = list(B, A, C), list(A, B) = list(A, B)),
+ * /datum/element/second = list(list(B, C) = list(C, B), list(D) = list(D)),
+ * )
+ *
+ * Used by the dcs_check_list_arguments unit test.
+ */
+ var/list/arguments_that_are_lists_by_element = list()
+ /**
+ * An assoc list of list instances and their sorted counterparts.
+ *
+ * e.g. list(
+ * list(B, A, C) = list(A, B, C),
+ * list(C, B) = list(B, C),
+ * )
+ *
+ * Used to make sure each list instance is sorted no more than once, or the unit test won't work.
+ */
+ var/list/sorted_arguments_that_are_lists = list()
-/datum/controller/subsystem/processing/dcs/proc/GetElement(list/arguments)
+/datum/controller/subsystem/processing/dcs/Recover()
+ _listen_lookup = SSdcs._listen_lookup
+
+/datum/controller/subsystem/processing/dcs/proc/GetElement(list/arguments, init_element = TRUE)
var/datum/element/eletype = arguments[1]
var/element_id = eletype
@@ -16,10 +40,10 @@ PROCESSING_SUBSYSTEM_DEF(dcs)
CRASH("Attempted to instantiate [eletype] as a /datum/element")
if(initial(eletype.element_flags) & ELEMENT_BESPOKE)
- element_id = GetIdFromArguments(arguments)
+ element_id = length(arguments) == 1 ? "[arguments[1]]" : GetIdFromArguments(arguments)
. = elements_by_type[element_id]
- if(.)
+ if(. || !init_element)
return
. = elements_by_type[element_id] = new eletype
@@ -31,24 +55,55 @@ PROCESSING_SUBSYSTEM_DEF(dcs)
**/
/datum/controller/subsystem/processing/dcs/proc/GetIdFromArguments(list/arguments)
var/datum/element/eletype = arguments[1]
- var/list/fullid = list("[eletype]")
- var/list/named_arguments = list()
- for(var/i in initial(eletype.id_arg_index) to length(arguments))
+ var/list/fullid = list(eletype)
+ var/list/named_arguments
+ for(var/i in initial(eletype.argument_hash_start_idx) to length(arguments))
var/key = arguments[i]
- var/value
- if(istext(key))
- value = arguments[key]
- if(!(istext(key) || isnum(key)))
- key = REF(key)
- key = "[key]" // Key is stringified so numbers dont break things
- if(!isnull(value))
- if(!(istext(value) || isnum(value)))
- value = REF(value)
- named_arguments["[key]"] = value
- else
- fullid += "[key]"
- if(length(named_arguments))
- named_arguments = sortList(named_arguments)
+ if(istext(key))
+ var/value = arguments[key]
+ if (isnull(value))
+ fullid += key
+ else
+ if (!istext(value) && !isnum(value))
+ //if(PERFORM_ALL_TESTS(dcs_check_list_arguments) && islist(value)) // Unit test stuff we dont have
+ //add_to_arguments_that_are_lists(value, eletype) // Unit test stuff we dont have
+ value = REF(value)
+
+ if (!named_arguments)
+ named_arguments = list()
+
+ named_arguments[key] = value
+ continue
+
+ if (isnum(key))
+ fullid += key
+ else
+ //if(PERFORM_ALL_TESTS(dcs_check_list_arguments) && islist(key)) // Unit test stuff we dont have
+ //add_to_arguments_that_are_lists(key, eletype) // Unit test stuff we dont have
+ fullid += REF(key)
+
+ if(named_arguments)
+ named_arguments = sortTim(named_arguments, GLOBAL_PROC_REF(cmp_text_asc))
fullid += named_arguments
+
return list2params(fullid)
+
+/**
+ * Offloading the first half of the dcs_check_list_arguments here, which is populating the superlist
+ * with sublists that will be later compared with each other by the dcs_check_list_arguments unit test.
+ */
+/datum/controller/subsystem/processing/dcs/proc/add_to_arguments_that_are_lists(list/argument, datum/element/element_type)
+ if(initial(element_type.element_flags) & ELEMENT_NO_LIST_UNIT_TEST)
+ return
+ var/list/element_type_superlist = arguments_that_are_lists_by_element[element_type]
+ if(!element_type_superlist)
+ arguments_that_are_lists_by_element[element_type] = element_type_superlist = list()
+
+ var/list/sorted_argument = argument
+ if(!(initial(element_type.element_flags) & ELEMENT_DONT_SORT_LIST_ARGS))
+ sorted_argument = sorted_arguments_that_are_lists[argument]
+ if(!sorted_argument)
+ sorted_arguments_that_are_lists[argument] = sorted_argument = sortTim(argument.Copy(), GLOBAL_PROC_REF(cmp_embed_text_asc))
+
+ element_type_superlist[sorted_argument] = argument
diff --git a/code/controllers/subsystems/tgui.dm b/code/controllers/subsystems/tgui.dm
index 9f0baf12e6..65cdd51407 100644
--- a/code/controllers/subsystems/tgui.dm
+++ b/code/controllers/subsystems/tgui.dm
@@ -171,9 +171,9 @@ SUBSYSTEM_DEF(tgui)
*/
/datum/controller/subsystem/tgui/proc/get_open_ui(mob/user, datum/src_object)
// No UIs opened for this src_object
- if(!LAZYLEN(src_object?.open_uis))
+ if(!LAZYLEN(src_object?.open_tguis))
return null
- for(var/datum/tgui/ui in src_object.open_uis)
+ for(var/datum/tgui/ui in src_object.open_tguis)
// Make sure we have the right user
if(ui.user == user)
return ui
@@ -190,10 +190,10 @@ SUBSYSTEM_DEF(tgui)
*/
/datum/controller/subsystem/tgui/proc/update_uis(datum/src_object)
// No UIs opened for this src_object
- if(!LAZYLEN(src_object?.open_uis))
+ if(!LAZYLEN(src_object?.open_tguis))
return 0
var/count = 0
- for(var/datum/tgui/ui in src_object.open_uis)
+ for(var/datum/tgui/ui in src_object.open_tguis)
// Check if UI is valid.
if(ui?.src_object && ui.user && ui.src_object.tgui_host(ui.user))
INVOKE_ASYNC(ui, TYPE_PROC_REF(/datum/tgui, process), wait * 0.1, TRUE)
@@ -211,10 +211,10 @@ SUBSYSTEM_DEF(tgui)
*/
/datum/controller/subsystem/tgui/proc/close_uis(datum/src_object)
// No UIs opened for this src_object
- if(!LAZYLEN(src_object?.open_uis))
+ if(!LAZYLEN(src_object?.open_tguis))
return 0
var/count = 0
- for(var/datum/tgui/ui in src_object.open_uis)
+ for(var/datum/tgui/ui in src_object.open_tguis)
// Check if UI is valid.
if(ui?.src_object && ui.user && ui.src_object.tgui_host(ui.user))
ui.close()
@@ -286,7 +286,7 @@ SUBSYSTEM_DEF(tgui)
*/
/datum/controller/subsystem/tgui/proc/on_open(datum/tgui/ui)
ui.user?.tgui_open_uis |= ui
- LAZYOR(ui.src_object.open_uis, ui)
+ LAZYOR(ui.src_object.open_tguis, ui)
all_uis |= ui
/**
@@ -306,7 +306,7 @@ SUBSYSTEM_DEF(tgui)
if(ui.user)
ui.user.tgui_open_uis -= ui
if(ui.src_object)
- LAZYREMOVE(ui.src_object.open_uis, ui)
+ LAZYREMOVE(ui.src_object.open_tguis, ui)
return TRUE
/**
diff --git a/code/datums/components/COMPONENT_TEMPLATE.md b/code/datums/components/COMPONENT_TEMPLATE.md
new file mode 100644
index 0000000000..7b08205888
--- /dev/null
+++ b/code/datums/components/COMPONENT_TEMPLATE.md
@@ -0,0 +1,55 @@
+
+# Template file for your new component
+
+See _component.dm for detailed explanations
+
+```dm
+/datum/component/mycomponent
+ //can_transfer = TRUE // Must have PostTransfer
+ //dupe_mode = COMPONENT_DUPE_ALLOWED // code/__DEFINES/dcs/flags.dm
+ var/myvar
+
+/datum/component/mycomponent/Initialize(myargone, myargtwo)
+ if(myargone)
+ myvar = myargone
+ if(myargtwo)
+ send_to_playing_players(myargtwo)
+
+/datum/component/mycomponent/RegisterWithParent()
+ RegisterSignal(parent, COMSIG_NOT_REAL, PROC_REF(signalproc)) // RegisterSignal can take a signal name by itself,
+ RegisterSignal(parent, list(COMSIG_NOT_REAL_EITHER, COMSIG_ALMOST_REAL), PROC_REF(otherproc)) // or a list of them to assign to the same proc
+
+/datum/component/mycomponent/UnregisterFromParent()
+ UnregisterSignal(parent, COMSIG_NOT_REAL) // UnregisterSignal has similar behavior
+ UnregisterSignal(parent, list( // But you can just include all registered signals in one call
+ COMSIG_NOT_REAL,
+ COMSIG_NOT_REAL_EITHER,
+ COMSIG_ALMOST_REAL,
+ ))
+
+/datum/component/mycomponent/proc/signalproc(datum/source)
+ SIGNAL_HANDLER
+ send_to_playing_players("[source] signaled [src]!")
+
+/*
+/datum/component/mycomponent/InheritComponent(datum/component/mycomponent/old, i_am_original, list/arguments)
+ myvar = old.myvar
+
+ if(i_am_original)
+ send_to_playing_players("No parent should have to bury their child")
+*/
+
+/*
+/datum/component/mycomponent/PreTransfer()
+ send_to_playing_players("Goodbye [parent], I'm getting adopted")
+
+/datum/component/mycomponent/PostTransfer()
+ send_to_playing_players("Hello my new parent, [parent]! It's nice to meet you!")
+*/
+
+/*
+/datum/component/mycomponent/CheckDupeComponent(datum/mycomponent/new, myargone, myargtwo)
+ if(myargone == myvar)
+ return TRUE
+*/
+```
diff --git a/code/datums/components/README.md b/code/datums/components/README.md
index 03f7d3a587..db8bf10a32 100644
--- a/code/datums/components/README.md
+++ b/code/datums/components/README.md
@@ -4,6 +4,6 @@
Loosely adapted from /vg/. This is an entity component system for adding behaviours to datums when inheritance doesn't quite cut it. By using signals and events instead of direct inheritance, you can inject behaviours without hacky overloads. It requires a different method of thinking, but is not hard to use correctly. If a behaviour can have application across more than one thing. Make it generic, make it a component. Atom/mob/obj event? Give it a signal, and forward it's arguments with a `SendSignal()` call. Now every component that want's to can also know about this happening.
-See [this thread](https://tgstation13.org/phpBB/viewtopic.php?f=5&t=22674) for an introduction to the system as a whole.
+### [HackMD page for an introduction to the system as a whole.](https://hackmd.io/@tgstation/SignalsComponentsElements)
-### See/Define signals and their arguments in [__DEFINES\dcs\signals.dm](../../__DEFINES/dcs/signals.dm)
+### See/Define signals and their arguments in [__DEFINES\components.dm](../../__DEFINES/components.dm)
diff --git a/code/datums/components/_component.dm b/code/datums/components/_component.dm
index 08fb75ead2..e52d917b48 100644
--- a/code/datums/components/_component.dm
+++ b/code/datums/components/_component.dm
@@ -1,14 +1,14 @@
/**
- * # Component
- *
- * The component datum
- *
- * A component should be a single standalone unit
- * of functionality, that works by receiving signals from it's parent
- * object to provide some single functionality (i.e a slippery component)
- * that makes the object it's attached to cause people to slip over.
- * Useful when you want shared behaviour independent of type inheritance
- */
+ * # Component
+ *
+ * The component datum
+ *
+ * A component should be a single standalone unit
+ * of functionality, that works by receiving signals from it's parent
+ * object to provide some single functionality (i.e a slippery component)
+ * that makes the object it's attached to cause people to slip over.
+ * Useful when you want shared behaviour independent of type inheritance
+ */
/datum/component
/**
* Defines how duplicate existing components are handled when added to a datum
@@ -38,14 +38,17 @@
*/
var/can_transfer = FALSE
+ /// A lazy list of the sources for this component
+ var/list/sources
+
/**
- * Create a new component.
- *
- * Additional arguments are passed to [Initialize()][/datum/component/proc/Initialize]
- *
- * Arguments:
- * * datum/P the parent datum this component reacts to signals from
- */
+ * Create a new component.
+ *
+ * Additional arguments are passed to [Initialize()][/datum/component/proc/Initialize]
+ *
+ * Arguments:
+ * * datum/P the parent datum this component reacts to signals from
+ */
/datum/component/New(list/raw_args)
parent = raw_args[1]
var/list/arguments = raw_args.Copy(2)
@@ -57,50 +60,50 @@
_JoinParent(parent)
/**
- * Called during component creation with the same arguments as in new excluding parent.
- *
- * Do not call `qdel(src)` from this function, `return COMPONENT_INCOMPATIBLE` instead
- */
+ * Called during component creation with the same arguments as in new excluding parent.
+ *
+ * Do not call `qdel(src)` from this function, `return COMPONENT_INCOMPATIBLE` instead
+ */
/datum/component/proc/Initialize(...)
return
/**
- * Properly removes the component from `parent` and cleans up references
- *
- * Arguments:
- * * force - makes it not check for and remove the component from the parent
- * * silent - deletes the component without sending a [COMSIG_COMPONENT_REMOVING] signal
- */
-/datum/component/Destroy(force=FALSE, silent=FALSE)
- if(!force && parent)
+ * Properly removes the component from `parent` and cleans up references
+ *
+ * Arguments:
+ * * force - makes it not check for and remove the component from the parent
+ */
+/datum/component/Destroy(force = FALSE)
+ if(!parent)
+ return ..()
+ if(!force)
_RemoveFromParent()
- if(!silent)
- SEND_SIGNAL(parent, COMSIG_COMPONENT_REMOVING, src)
+ SEND_SIGNAL(parent, COMSIG_COMPONENT_REMOVING, src)
parent = null
return ..()
/**
- * Internal proc to handle behaviour of components when joining a parent
- */
+ * Internal proc to handle behaviour of components when joining a parent
+ */
/datum/component/proc/_JoinParent()
var/datum/P = parent
//lazy init the parent's dc list
- var/list/dc = P.datum_components
+ var/list/dc = P._datum_components
if(!dc)
- P.datum_components = dc = list()
+ P._datum_components = dc = list()
//set up the typecache
var/our_type = type
for(var/I in _GetInverseTypeList(our_type))
var/test = dc[I]
- if(test) //already another component of this type here
+ if(test) //already another component of this type here
var/list/components_of_type
if(!length(test))
components_of_type = list(test)
dc[I] = components_of_type
else
components_of_type = test
- if(I == our_type) //exact match, take priority
+ if(I == our_type) //exact match, take priority
var/inserted = FALSE
for(var/J in 1 to components_of_type.len)
var/datum/component/C = components_of_type[J]
@@ -110,191 +113,126 @@
break
if(!inserted)
components_of_type += src
- else //indirect match, back of the line with ya
+ else //indirect match, back of the line with ya
components_of_type += src
- else //only component of this type, no list
+ else //only component of this type, no list
dc[I] = src
RegisterWithParent()
/**
- * Internal proc to handle behaviour when being removed from a parent
- */
+ * Internal proc to handle behaviour when being removed from a parent
+ */
/datum/component/proc/_RemoveFromParent()
- var/datum/P = parent
- var/list/dc = P.datum_components
+ var/datum/parent = src.parent
+ var/list/parents_components = parent._datum_components
for(var/I in _GetInverseTypeList())
- var/list/components_of_type = dc[I]
- if(length(components_of_type)) //
+ var/list/components_of_type = parents_components[I]
+
+ if(length(components_of_type)) //
var/list/subtracted = components_of_type - src
- if(subtracted.len == 1) //only 1 guy left
- dc[I] = subtracted[1] //make him special
+
+ if(subtracted.len == 1) //only 1 guy left
+ parents_components[I] = subtracted[1] //make him special
else
- dc[I] = subtracted
- else //just us
- dc -= I
- if(!dc.len)
- P.datum_components = null
+ parents_components[I] = subtracted
+
+ else //just us
+ parents_components -= I
+
+ if(!parents_components.len)
+ parent._datum_components = null
UnregisterFromParent()
/**
- * Register the component with the parent object
- *
- * Use this proc to register with your parent object
- *
- * Overridable proc that's called when added to a new parent
- */
+ * Register the component with the parent object
+ *
+ * Use this proc to register with your parent object
+ *
+ * Overridable proc that's called when added to a new parent
+ */
/datum/component/proc/RegisterWithParent()
return
/**
- * Unregister from our parent object
- *
- * Use this proc to unregister from your parent object
- *
- * Overridable proc that's called when removed from a parent
- * *
- */
+ * Unregister from our parent object
+ *
+ * Use this proc to unregister from your parent object
+ *
+ * Overridable proc that's called when removed from a parent
+ * *
+ */
/datum/component/proc/UnregisterFromParent()
return
/**
- * Register to listen for a signal from the passed in target
- *
- * This sets up a listening relationship such that when the target object emits a signal
- * the source datum this proc is called upon, will recieve a callback to the given proctype
- * Return values from procs registered must be a bitfield
- *
- * Arguments:
- * * datum/target The target to listen for signals from
- * * sig_type_or_types Either a string signal name, or a list of signal names (strings)
- * * proctype The proc to call back when the signal is emitted
- * * override If a previous registration exists you must explicitly set this
- */
-/datum/proc/RegisterSignal(datum/target, sig_type_or_types, proctype, override = FALSE)
- if(QDELETED(src) || QDELETED(target))
- return
-
- var/list/procs = signal_procs
- if(!procs)
- signal_procs = procs = list()
- if(!procs[target])
- procs[target] = list()
- var/list/lookup = target.comp_lookup
- if(!lookup)
- target.comp_lookup = lookup = list()
-
- var/list/sig_types = islist(sig_type_or_types) ? sig_type_or_types : list(sig_type_or_types)
- for(var/sig_type in sig_types)
- if(!override && procs[target][sig_type])
- var/trace_msg = "[sig_type] overridden. Use override = TRUE to suppress this warning."
- if(isatom(target))
- var/atom/A = target
- trace_msg += " [A.x],[A.y],[A.z]"
- stack_trace(trace_msg)
-
- procs[target][sig_type] = proctype
-
- if(!lookup[sig_type]) // Nothing has registered here yet
- lookup[sig_type] = src
- else if(lookup[sig_type] == src) // We already registered here
- continue
- else if(!length(lookup[sig_type])) // One other thing registered here
- lookup[sig_type] = list(lookup[sig_type]=TRUE)
- lookup[sig_type][src] = TRUE
- else // Many other things have registered here
- lookup[sig_type][src] = TRUE
-
- signal_enabled = TRUE
+ * Called when the component has a new source registered.
+ * Return COMPONENT_INCOMPATIBLE to signal that the source is incompatible and should not be added
+ */
+/datum/component/proc/on_source_add(source, ...)
+ SHOULD_CALL_PARENT(TRUE)
+ if(dupe_mode != COMPONENT_DUPE_SOURCES)
+ return COMPONENT_INCOMPATIBLE
+ LAZYOR(sources, source)
/**
- * Stop listening to a given signal from target
- *
- * Breaks the relationship between target and source datum, removing the callback when the signal fires
- *
- * Doesn't care if a registration exists or not
- *
- * Arguments:
- * * datum/target Datum to stop listening to signals from
- * * sig_type_or_types Signal string key or list of signal keys to stop listening to specifically
- */
-/datum/proc/UnregisterSignal(datum/target, sig_type_or_types)
- var/list/lookup = target?.comp_lookup
- if(!signal_procs || !signal_procs[target] || !lookup)
- return
- if(!islist(sig_type_or_types))
- sig_type_or_types = list(sig_type_or_types)
- for(var/sig in sig_type_or_types)
- if(!signal_procs[target][sig])
- continue
- switch(length(lookup[sig]))
- if(2)
- lookup[sig] = (lookup[sig]-src)[1]
- if(1)
- stack_trace("[target] ([target.type]) somehow has single length list inside comp_lookup")
- if(src in lookup[sig])
- lookup -= sig
- if(!length(lookup))
- target.comp_lookup = null
- break
- if(0)
- lookup -= sig
- if(!length(lookup))
- target.comp_lookup = null
- break
- else
- lookup[sig] -= src
-
- signal_procs[target] -= sig_type_or_types
- if(!signal_procs[target].len)
- signal_procs -= target
+ * Called when the component has a source removed.
+ * You probably want to call parent after you do your logic because at the end of this we qdel if we have no sources remaining!
+ */
+/datum/component/proc/on_source_remove(source)
+ SHOULD_CALL_PARENT(TRUE)
+ if(dupe_mode != COMPONENT_DUPE_SOURCES)
+ CRASH("Component '[type]' does not use sources but is trying to remove a source")
+ LAZYREMOVE(sources, source)
+ if(!LAZYLEN(sources))
+ qdel(src)
/**
- * Called on a component when a component of the same type was added to the same parent
- *
- * See [/datum/component/var/dupe_mode]
- *
- * `C`'s type will always be the same of the called component
- */
+ * Called on a component when a component of the same type was added to the same parent
+ *
+ * See [/datum/component/var/dupe_mode]
+ *
+ * `C`'s type will always be the same of the called component
+ */
/datum/component/proc/InheritComponent(datum/component/C, i_am_original)
return
/**
- * Called on a component when a component of the same type was added to the same parent with [COMPONENT_DUPE_SELECTIVE]
- *
- * See [/datum/component/var/dupe_mode]
- *
- * `C`'s type will always be the same of the called component
- *
- * return TRUE if you are absorbing the component, otherwise FALSE if you are fine having it exist as a duplicate component
- */
+ * Called on a component when a component of the same type was added to the same parent with [COMPONENT_DUPE_SELECTIVE]
+ *
+ * See [/datum/component/var/dupe_mode]
+ *
+ * `C`'s type will always be the same of the called component
+ *
+ * return TRUE if you are absorbing the component, otherwise FALSE if you are fine having it exist as a duplicate component
+ */
/datum/component/proc/CheckDupeComponent(datum/component/C, ...)
return
/**
- * Callback Just before this component is transferred
- *
- * Use this to do any special cleanup you might need to do before being deregged from an object
- */
+ * Callback Just before this component is transferred
+ *
+ * Use this to do any special cleanup you might need to do before being deregged from an object
+ */
/datum/component/proc/PreTransfer()
return
/**
- * Callback Just after a component is transferred
- *
- * Use this to do any special setup you need to do after being moved to a new object
- *
- * Do not call `qdel(src)` from this function, `return COMPONENT_INCOMPATIBLE` instead
- */
+ * Callback Just after a component is transferred
+ *
+ * Use this to do any special setup you need to do after being moved to a new object
+ *
+ * Do not call `qdel(src)` from this function, `return COMPONENT_INCOMPATIBLE` instead
+ */
/datum/component/proc/PostTransfer()
return COMPONENT_INCOMPATIBLE //Do not support transfer by default as you must properly support it
/**
- * Internal proc to create a list of our type and all parent types
- */
+ * Internal proc to create a list of our type and all parent types
+ */
/datum/component/proc/_GetInverseTypeList(our_type = type)
//we can do this one simple trick
. = list(our_type)
@@ -304,42 +242,20 @@
. += current_type
current_type = type2parent(current_type)
-/**
- * Internal proc to handle most all of the signaling procedure
- *
- * Will runtime if used on datums with an empty component list
- *
- * Use the [SEND_SIGNAL] define instead
- */
-/datum/proc/_SendSignal(sigtype, list/arguments)
- var/target = comp_lookup[sigtype]
- if(!length(target))
- var/datum/C = target
- if(!C.signal_enabled)
- return NONE
- var/proctype = C.signal_procs[src][sigtype]
- return NONE | CallAsync(C, proctype, arguments)
- . = NONE
- for(var/datum/C as anything in target)
- if(!C.signal_enabled)
- continue
- var/proctype = C.signal_procs[src][sigtype]
- . |= CallAsync(C, proctype, arguments)
-
// The type arg is casted so initial works, you shouldn't be passing a real instance into this
/**
- * Return any component assigned to this datum of the given type
- *
- * This will throw an error if it's possible to have more than one component of that type on the parent
- *
- * Arguments:
- * * datum/component/c_type The typepath of the component you want to get a reference to
- */
+ * Return any component assigned to this datum of the given type
+ *
+ * This will throw an error if it's possible to have more than one component of that type on the parent
+ *
+ * Arguments:
+ * * datum/component/c_type The typepath of the component you want to get a reference to
+ */
/datum/proc/GetComponent(datum/component/c_type)
RETURN_TYPE(c_type)
if(initial(c_type.dupe_mode) == COMPONENT_DUPE_ALLOWED || initial(c_type.dupe_mode) == COMPONENT_DUPE_SELECTIVE)
stack_trace("GetComponent was called to get a component of which multiple copies could be on an object. This can easily break and should be changed. Type: \[[c_type]\]")
- var/list/dc = datum_components
+ var/list/dc = _datum_components
if(!dc)
return null
. = dc[c_type]
@@ -348,18 +264,18 @@
// The type arg is casted so initial works, you shouldn't be passing a real instance into this
/**
- * Return any component assigned to this datum of the exact given type
- *
- * This will throw an error if it's possible to have more than one component of that type on the parent
- *
- * Arguments:
- * * datum/component/c_type The typepath of the component you want to get a reference to
- */
+ * Return any component assigned to this datum of the exact given type
+ *
+ * This will throw an error if it's possible to have more than one component of that type on the parent
+ *
+ * Arguments:
+ * * datum/component/c_type The typepath of the component you want to get a reference to
+ */
/datum/proc/GetExactComponent(datum/component/c_type)
RETURN_TYPE(c_type)
if(initial(c_type.dupe_mode) == COMPONENT_DUPE_ALLOWED || initial(c_type.dupe_mode) == COMPONENT_DUPE_SELECTIVE)
stack_trace("GetComponent was called to get a component of which multiple copies could be on an object. This can easily break and should be changed. Type: \[[c_type]\]")
- var/list/dc = datum_components
+ var/list/dc = _datum_components
if(!dc)
return null
var/datum/component/C = dc[c_type]
@@ -371,109 +287,148 @@
return null
/**
- * Get all components of a given type that are attached to this datum
- *
- * Arguments:
- * * c_type The component type path
- */
+ * Get all components of a given type that are attached to this datum
+ *
+ * Arguments:
+ * * c_type The component type path
+ */
/datum/proc/GetComponents(c_type)
- var/list/dc = datum_components
- if(!dc)
- return null
- . = dc[c_type]
- if(!length(.))
- return list(.)
+ var/list/components = _datum_components?[c_type]
+ if(!components)
+ return list()
+ return islist(components) ? components : list(components)
/**
- * Creates an instance of `new_type` in the datum and attaches to it as parent
- *
- * Sends the [COMSIG_COMPONENT_ADDED] signal to the datum
- *
- * Returns the component that was created. Or the old component in a dupe situation where [COMPONENT_DUPE_UNIQUE] was set
- *
- * If this tries to add a component to an incompatible type, the component will be deleted and the result will be `null`. This is very unperformant, try not to do it
- *
- * Properly handles duplicate situations based on the `dupe_mode` var
- */
-/datum/proc/_AddComponent(list/raw_args)
- var/new_type = raw_args[1]
- var/datum/component/nt = new_type
- var/dm = initial(nt.dupe_mode)
- var/dt = initial(nt.dupe_type)
+ * Creates an instance of `new_type` in the datum and attaches to it as parent
+ *
+ * Sends the [COMSIG_COMPONENT_ADDED] signal to the datum
+ *
+ * Returns the component that was created. Or the old component in a dupe situation where [COMPONENT_DUPE_UNIQUE] was set
+ *
+ * If this tries to add a component to an incompatible type, the component will be deleted and the result will be `null`. This is very unperformant, try not to do it
+ *
+ * Properly handles duplicate situations based on the `dupe_mode` var
+ */
+/datum/proc/_AddComponent(list/raw_args, source)
+ var/original_type = raw_args[1]
+ var/datum/component/component_type = original_type
- var/datum/component/old_comp
- var/datum/component/new_comp
+ if(QDELING(src))
+ CRASH("Attempted to add a new component of type \[[component_type]\] to a qdeleting parent of type \[[type]\]!")
- if(ispath(nt))
- if(nt == /datum/component)
- CRASH("[nt] attempted instantiation!")
- else
- new_comp = nt
- nt = new_comp.type
+ var/datum/component/new_component
+
+ if(!ispath(component_type, /datum/component))
+ if(!istype(component_type, /datum/component))
+ CRASH("Attempted to instantiate \[[component_type]\] as a component added to parent of type \[[type]\]!")
+ else
+ new_component = component_type
+ component_type = new_component.type
+ else if(component_type == /datum/component)
+ CRASH("[component_type] attempted instantiation!")
+
+ var/dupe_mode = initial(component_type.dupe_mode)
+ var/dupe_type = initial(component_type.dupe_type)
+ var/uses_sources = (dupe_mode == COMPONENT_DUPE_SOURCES)
+ if(uses_sources && !source)
+ CRASH("Attempted to add a sourced component of type '[component_type]' to '[type]' without a source!")
+ else if(!uses_sources && source)
+ CRASH("Attempted to add a normal component of type '[component_type]' to '[type]' with a source!")
+
+ var/datum/component/old_component
raw_args[1] = src
-
- if(dm != COMPONENT_DUPE_ALLOWED)
- if(!dt)
- old_comp = GetExactComponent(nt)
+ if(dupe_mode != COMPONENT_DUPE_ALLOWED && dupe_mode != COMPONENT_DUPE_SELECTIVE && dupe_mode != COMPONENT_DUPE_SOURCES)
+ if(!dupe_type)
+ old_component = GetExactComponent(component_type)
else
- old_comp = GetComponent(dt)
- if(old_comp)
- switch(dm)
+ old_component = GetComponent(dupe_type)
+
+ if(old_component)
+ switch(dupe_mode)
if(COMPONENT_DUPE_UNIQUE)
- if(!new_comp)
- new_comp = new nt(raw_args)
- if(!QDELETED(new_comp))
- old_comp.InheritComponent(new_comp, TRUE)
- QDEL_NULL(new_comp)
+ if(!new_component)
+ new_component = new component_type(raw_args)
+ if(!QDELETED(new_component))
+ old_component.InheritComponent(new_component, TRUE)
+ QDEL_NULL(new_component)
+
if(COMPONENT_DUPE_HIGHLANDER)
- if(!new_comp)
- new_comp = new nt(raw_args)
- if(!QDELETED(new_comp))
- new_comp.InheritComponent(old_comp, FALSE)
- QDEL_NULL(old_comp)
+ if(!new_component)
+ new_component = new component_type(raw_args)
+ if(!QDELETED(new_component))
+ new_component.InheritComponent(old_component, FALSE)
+ QDEL_NULL(old_component)
+
if(COMPONENT_DUPE_UNIQUE_PASSARGS)
- if(!new_comp)
+ if(!new_component)
var/list/arguments = raw_args.Copy(2)
arguments.Insert(1, null, TRUE)
- old_comp.InheritComponent(arglist(arguments))
+ old_component.InheritComponent(arglist(arguments))
else
- old_comp.InheritComponent(new_comp, TRUE)
- if(COMPONENT_DUPE_SELECTIVE)
- var/list/arguments = raw_args.Copy()
- arguments[1] = new_comp
- var/make_new_component = TRUE
- for(var/datum/component/C as anything in GetComponents(new_type))
- if(C.CheckDupeComponent(arglist(arguments)))
- make_new_component = FALSE
- QDEL_NULL(new_comp)
- break
- if(!new_comp && make_new_component)
- new_comp = new nt(raw_args)
- else if(!new_comp)
- new_comp = new nt(raw_args) // There's a valid dupe mode but there's no old component, act like normal
- else if(!new_comp)
- new_comp = new nt(raw_args) // Dupes are allowed, act like normal
+ old_component.InheritComponent(new_component, TRUE)
- if(!old_comp && !QDELETED(new_comp)) // Nothing related to duplicate components happened and the new component is healthy
- SEND_SIGNAL(src, COMSIG_COMPONENT_ADDED, new_comp)
- return new_comp
- return old_comp
+ if(COMPONENT_DUPE_SOURCES)
+ if(source in old_component.sources)
+ return old_component // source already registered, no work to do
+
+ if(old_component.on_source_add(arglist(list(source) + raw_args.Copy(2))) == COMPONENT_INCOMPATIBLE)
+ stack_trace("incompatible source added to a [old_component.type]. Args: [json_encode(raw_args)]")
+ return null
+
+ else if(!new_component)
+ new_component = new component_type(raw_args) // There's a valid dupe mode but there's no old component, act like normal
+
+ else if(dupe_mode == COMPONENT_DUPE_SELECTIVE)
+ var/list/arguments = raw_args.Copy()
+ arguments[1] = new_component
+ var/make_new_component = TRUE
+ for(var/datum/component/existing_component as anything in GetComponents(original_type))
+ if(existing_component.CheckDupeComponent(arglist(arguments)))
+ make_new_component = FALSE
+ QDEL_NULL(new_component)
+ break
+ if(!new_component && make_new_component)
+ new_component = new component_type(raw_args)
+
+ else if(dupe_mode == COMPONENT_DUPE_SOURCES)
+ new_component = new component_type(raw_args)
+ if(new_component.on_source_add(arglist(list(source) + raw_args.Copy(2))) == COMPONENT_INCOMPATIBLE)
+ stack_trace("incompatible source added to a [new_component.type]. Args: [json_encode(raw_args)]")
+ return null
+
+ else if(!new_component)
+ new_component = new component_type(raw_args) // Dupes are allowed, act like normal
+
+ if(!old_component && !QDELETED(new_component)) // Nothing related to duplicate components happened and the new component is healthy
+ SEND_SIGNAL(src, COMSIG_COMPONENT_ADDED, new_component)
+ return new_component
+
+ return old_component
/**
- * Get existing component of type, or create it and return a reference to it
- *
- * Use this if the item needs to exist at the time of this call, but may not have been created before now
- *
- * Arguments:
- * * component_type The typepath of the component to create or return
- * * ... additional arguments to be passed when creating the component if it does not exist
- */
-/datum/proc/LoadComponent(component_type, ...)
- . = GetComponent(component_type)
- if(!.)
- return _AddComponent(args)
+ * Removes a component source from this datum
+ */
+/datum/proc/RemoveComponentSource(source, datum/component/component_type)
+ if(ispath(component_type))
+ component_type = GetExactComponent(component_type)
+ if(!component_type)
+ return
+ component_type.on_source_remove(source)
+/**
+ * Get existing component of type, or create it and return a reference to it
+ *
+ * Use this if the item needs to exist at the time of this call, but may not have been created before now
+ *
+ * Arguments:
+ * * component_type The typepath of the component to create or return
+ * * ... additional arguments to be passed when creating the component if it does not exist
+ */
+/datum/proc/_LoadComponent(list/arguments)
+ . = GetComponent(arguments[1])
+ if(!.)
+ return _AddComponent(arguments)
/**
* Removes the component from parent, ends up with a null parent
* Used as a helper proc by the component transfer proc, does not clean up the component like Destroy does
@@ -488,13 +443,13 @@
SEND_SIGNAL(old_parent, COMSIG_COMPONENT_REMOVING, src)
/**
- * Transfer this component to another parent
- *
- * Component is taken from source datum
- *
- * Arguments:
- * * datum/component/target Target datum to transfer to
- */
+ * Transfer this component to another parent
+ *
+ * Component is taken from source datum
+ *
+ * Arguments:
+ * * datum/component/target Target datum to transfer to
+ */
/datum/proc/TakeComponent(datum/component/target)
if(!target || target.parent == src)
return
@@ -512,29 +467,30 @@
target._JoinParent()
/**
- * Transfer all components to target
- *
- * All components from source datum are taken
- *
- * Arguments:
- * * /datum/target the target to move the components to
- */
+ * Transfer all components to target
+ *
+ * All components from source datum are taken
+ *
+ * Arguments:
+ * * /datum/target the target to move the components to
+ */
/datum/proc/TransferComponents(datum/target)
- var/list/dc = datum_components
+ var/list/dc = _datum_components
if(!dc)
return
- var/comps = dc[/datum/component]
- if(islist(comps))
- for(var/datum/component/I in comps)
- if(I.can_transfer)
- target.TakeComponent(I)
- else
- var/datum/component/C = comps
- if(C.can_transfer)
- target.TakeComponent(comps)
+ for(var/component_key in dc)
+ var/component_or_list = dc[component_key]
+ if(islist(component_or_list))
+ for(var/datum/component/I in component_or_list)
+ if(I.can_transfer)
+ target.TakeComponent(I)
+ else
+ var/datum/component/C = component_or_list
+ if(C.can_transfer)
+ target.TakeComponent(C)
/**
- * Return the object that is the host of any UI's that this component has
- */
+ * Return the object that is the host of any UI's that this component has
+ */
/datum/component/tgui_host()
return parent
diff --git a/code/datums/components/material_container.dm b/code/datums/components/material_container.dm
index bbd2b7fd12..43f8f7b711 100644
--- a/code/datums/components/material_container.dm
+++ b/code/datums/components/material_container.dm
@@ -60,7 +60,7 @@
mat_amt = 0
materials[mat_ref] += mat_amt
-/datum/component/material_container/Destroy(force, silent)
+/datum/component/material_container/Destroy(force)
materials = null
allowed_materials = null
if(insertion_check)
diff --git a/code/datums/datum.dm b/code/datums/datum.dm
index 95e77fa9a3..8813e074f9 100644
--- a/code/datums/datum.dm
+++ b/code/datums/datum.dm
@@ -19,7 +19,7 @@
/// Open uis owned by this datum
/// Lazy, since this case is semi rare
- var/list/open_uis
+ var/list/open_tguis // FIXME: open_uis
/// Active timers with this datum as the target
var/list/_active_timers
@@ -29,20 +29,22 @@
/**
* Components attached to this datum
*
- * Lazy associated list in the structure of `type:component/list of components`
+ * Lazy associated list in the structure of `type -> component/list of components`
*/
- var/list/datum_components
+ var/list/_datum_components
/**
* Any datum registered to receive signals from this datum is in this list
*
- * Lazy associated list in the structure of `signal:registree/list of registrees`
+ * Lazy associated list in the structure of `signal -> registree/list of registrees`
*/
- var/list/comp_lookup
- var/list/list/signal_procs // List of lists
- var/signal_enabled = FALSE
+ var/list/_listen_lookup
+ /// Lazy associated list in the structure of `target -> list(signal -> proctype)` that are run when the datum receives that signal
+ var/list/list/_signal_procs
/// Datum level flags
var/datum_flags = NONE
+ var/trigger_uid
+ var/status_traits
/// A weak reference to another datum
var/datum/weakref/weak_reference
@@ -91,6 +93,7 @@
tag = null
weak_reference = null //ensure prompt GCing of weakref.
+ //clear timers
if(_active_timers)
var/list/timers = _active_timers
_active_timers = null
@@ -99,34 +102,26 @@
continue
qdel(timer)
- //BEGIN: ECS SHIT
- signal_enabled = FALSE
+ #ifdef REFERENCE_TRACKING
+ #ifdef REFERENCE_TRACKING_DEBUG
+ found_refs = null
+ #endif
+ #endif
- var/list/dc = datum_components
+ //BEGIN: ECS SHIT
+ var/list/dc = _datum_components
if(dc)
- var/all_components = dc[/datum/component]
- if(length(all_components))
- for(var/datum/component/C as anything in all_components)
- qdel(C, FALSE, TRUE)
- else
- var/datum/component/C = all_components
- qdel(C, FALSE, TRUE)
+ for(var/component_key in dc)
+ var/component_or_list = dc[component_key]
+ if(islist(component_or_list))
+ for(var/datum/component/component as anything in component_or_list)
+ qdel(component, FALSE)
+ else
+ var/datum/component/C = component_or_list
+ qdel(C, FALSE)
dc.Cut()
- var/list/lookup = comp_lookup
- if(lookup)
- for(var/sig in lookup)
- var/list/comps = lookup[sig]
- if(length(comps))
- for(var/datum/component/comp as anything in comps)
- comp.UnregisterSignal(src, sig)
- else
- var/datum/component/comp = comps
- comp.UnregisterSignal(src, sig)
- comp_lookup = lookup = null
-
- for(var/target in signal_procs)
- UnregisterSignal(target, signal_procs[target])
+ _clear_signal_refs()
//END: ECS SHIT
SStgui.close_uis(src)
@@ -140,6 +135,24 @@
return QDEL_HINT_QUEUE
+///Only override this if you know what you're doing. You do not know what you're doing
+///This is a threat
+/datum/proc/_clear_signal_refs()
+ var/list/lookup = _listen_lookup
+ if(lookup)
+ for(var/sig in lookup)
+ var/list/comps = lookup[sig]
+ if(length(comps))
+ for(var/datum/component/comp as anything in comps)
+ comp.UnregisterSignal(src, sig)
+ else
+ var/datum/component/comp = comps
+ comp.UnregisterSignal(src, sig)
+ _listen_lookup = lookup = null
+
+ for(var/target in _signal_procs)
+ UnregisterSignal(target, _signal_procs[target])
+
/**
* Callback called by a timer to end an associative-list-indexed cooldown.
*
diff --git a/code/datums/elements/ELEMENT_TEMPLATE.md b/code/datums/elements/ELEMENT_TEMPLATE.md
new file mode 100644
index 0000000000..4bc1f72f2d
--- /dev/null
+++ b/code/datums/elements/ELEMENT_TEMPLATE.md
@@ -0,0 +1,25 @@
+
+# Template file for your new element
+
+See _element.dm for detailed explanations
+
+```dm
+/datum/element/myelement
+ element_flags = ELEMENT_BESPOKE | ELEMENT_COMPLEX_DETACH | ELEMENT_DETACH_ON_HOST_DESTROY | ELEMENT_NOTAREALFLAG // code/__DEFINES/dcs/flags.dm
+ //argument_hash_start_idx = 2 // Use with ELEMENT_BESPOKE
+ var/list/myvar = list()
+
+/datum/element/myelement/Attach(datum/target)
+ if(!ismovable(target))
+ return COMPONENT_INCOMPATIBLE
+ RegisterSignal(target, COMSIG_MOVABLE_MOVED, myproc)
+ to_chat(target, "Hey, you're in your element.")
+
+/datum/element/myelement/Detach(datum/source)
+ UnregisterSignal(source, COMSIG_MOVABLE_MOVED)
+ to_chat(source, "You feel way out of your element.")
+
+/datum/element/myelement/proc/myproc(datum/source)
+ SIGNAL_HANDLER
+ playsound(source, 'sound/effects/gong.ogg', 50, TRUE)
+```
diff --git a/code/datums/elements/_element.dm b/code/datums/elements/_element.dm
index 82b5139522..7f019508a3 100644
--- a/code/datums/elements/_element.dm
+++ b/code/datums/elements/_element.dm
@@ -10,11 +10,14 @@
/**
* The index of the first attach argument to consider for duplicate elements
*
+ * All arguments from this index onwards (1 based) are hashed into the key to determine
+ * if this is a new unique element or one already exists
+ *
* Is only used when flags contains [ELEMENT_BESPOKE]
*
* This is infinity so you must explicitly set this
*/
- var/id_arg_index = INFINITY
+ var/argument_hash_start_idx = INFINITY
/// Activates the functionality defined by the element on the given target datum
/datum/element/proc/Attach(datum/target)
@@ -22,19 +25,19 @@
if(type == /datum/element)
return ELEMENT_INCOMPATIBLE
SEND_SIGNAL(target, COMSIG_ELEMENT_ATTACH, src)
- if(element_flags & ELEMENT_DETACH)
+ if(element_flags & ELEMENT_DETACH_ON_HOST_DESTROY)
RegisterSignal(target, COMSIG_PARENT_QDELETING, PROC_REF(OnTargetDelete), override = TRUE)
-/datum/element/proc/OnTargetDelete(datum/source, force)
+/datum/element/proc/OnTargetDelete(datum/source)
SIGNAL_HANDLER
Detach(source)
/// Deactivates the functionality defines by the element on the given datum
/datum/element/proc/Detach(datum/source, ...)
SIGNAL_HANDLER
+ SHOULD_CALL_PARENT(TRUE)
SEND_SIGNAL(source, COMSIG_ELEMENT_DETACH, src)
- SHOULD_CALL_PARENT(TRUE)
UnregisterSignal(source, COMSIG_PARENT_QDELETING)
/datum/element/Destroy(force)
@@ -48,20 +51,53 @@
/// Finds the singleton for the element type given and attaches it to src
/datum/proc/_AddElement(list/arguments)
if(QDELING(src))
- CRASH("We just tried to add an element to a qdeleted datum, something is fucked")
+ var/datum/element/element_type = arguments[1]
+ stack_trace("We just tried to add the element [element_type] to a qdeleted datum, something is fucked")
+ return
+
var/datum/element/ele = SSdcs.GetElement(arguments)
+ if(!ele) // We couldn't fetch the element, likely because it was not an element.
+ return // the crash message has already been sent
arguments[1] = src
if(ele.Attach(arglist(arguments)) == ELEMENT_INCOMPATIBLE)
- CRASH("Incompatible [arguments[1]] assigned to a [type]! args: [json_encode(args)]")
+ CRASH("Incompatible element [ele.type] was assigned to a [type]! args: [json_encode(args)]")
/**
* Finds the singleton for the element type given and detaches it from src
* You only need additional arguments beyond the type if you're using [ELEMENT_BESPOKE]
*/
/datum/proc/_RemoveElement(list/arguments)
- var/datum/element/ele = SSdcs.GetElement(arguments)
+ var/datum/element/ele = SSdcs.GetElement(arguments, FALSE)
+ if(!ele) // We couldn't fetch the element, likely because it didn't exist.
+ return
if(ele.element_flags & ELEMENT_COMPLEX_DETACH)
arguments[1] = src
ele.Detach(arglist(arguments))
else
ele.Detach(src)
+
+/**
+ * Used to manage (typically non_bespoke) elements with multiple sources through traits
+ * so we don't have to make them a components again.
+ * The element will be later removed once all trait sources are gone, there's no need of a
+ * "RemoveElementTrait" counterpart.
+ */
+/datum/proc/AddElementTrait(trait, source, datum/element/eletype, ...)
+ if(!ispath(eletype, /datum/element))
+ CRASH("AddElementTrait called, but [eletype] is not of a /datum/element path")
+ ADD_TRAIT(src, trait, source)
+ if(HAS_TRAIT_NOT_FROM(src, trait, source))
+ return
+ var/list/arguments = list(eletype)
+ /// 3 is the length of fixed args of this proc, any further one is passed down to AddElement.
+ if(length(args) > 3)
+ arguments += args.Copy(4)
+ /// We actually pass down a copy of the arguments since it's manipulated by the end of the proc.
+ _AddElement(arguments.Copy())
+ var/datum/ele = SSdcs.GetElement(arguments)
+ ele.RegisterSignal(src, SIGNAL_REMOVETRAIT(trait), TYPE_PROC_REF(/datum/element, _detach_on_trait_removed))
+
+/datum/element/proc/_detach_on_trait_removed(datum/source, trait)
+ SIGNAL_HANDLER
+ Detach(source)
+ UnregisterSignal(source, SIGNAL_REMOVETRAIT(trait))
diff --git a/code/datums/elements/conflict_checking.dm b/code/datums/elements/conflict_checking.dm
index eea61f8f89..f05a0b1706 100644
--- a/code/datums/elements/conflict_checking.dm
+++ b/code/datums/elements/conflict_checking.dm
@@ -2,8 +2,8 @@
* Simple conflict checking for getting number of conflicting things on someone with the same ID.
*/
/datum/element/conflict_checking
- element_flags = ELEMENT_BESPOKE | ELEMENT_DETACH
- id_arg_index = 1
+ element_flags = ELEMENT_BESPOKE | ELEMENT_DETACH_ON_HOST_DESTROY
+ argument_hash_start_idx = 1
/// we don't need to KNOW who has us, only our ID.
var/id
diff --git a/code/datums/elements/footstep.dm b/code/datums/elements/footstep.dm
new file mode 100644
index 0000000000..eab5965d2d
--- /dev/null
+++ b/code/datums/elements/footstep.dm
@@ -0,0 +1,187 @@
+#define SHOULD_DISABLE_FOOTSTEPS(source)
+
+///Footstep element. Plays footsteps at parents location when it is appropriate.
+/datum/element/footstep
+ element_flags = ELEMENT_DETACH_ON_HOST_DESTROY|ELEMENT_BESPOKE
+ argument_hash_start_idx = 2
+ ///A list containing living mobs and the number of steps they have taken since the last time their footsteps were played.
+ var/list/steps_for_living = list()
+ ///volume determines the extra volume of the footstep. This is multiplied by the base volume, should there be one.
+ var/volume
+ ///e_range stands for extra range - aka how far the sound can be heard. This is added to the base value and ignored if there isn't a base value.
+ var/e_range
+ ///footstep_type is a define which determines what kind of sounds should get chosen.
+ var/footstep_type
+ ///This can be a list OR a soundfile OR null. Determines whatever sound gets played.
+ var/footstep_sounds
+ ///Whether or not to add variation to the sounds played
+ var/sound_vary = FALSE
+
+/datum/element/footstep/Attach(datum/target, footstep_type = FOOTSTEP_MOB_BAREFOOT, volume = 0.1, e_range = -8, sound_vary = FALSE)
+ . = ..()
+ if(!ismovable(target))
+ return ELEMENT_INCOMPATIBLE
+ src.volume = volume
+ src.e_range = e_range
+ src.footstep_type = footstep_type
+ src.sound_vary = sound_vary
+
+ if(ishuman(target))
+ RegisterSignal(target, COMSIG_MOVABLE_MOVED, PROC_REF(play_humanstep))
+ steps_for_living[target] = 0
+ return
+
+ footstep_sounds = check_footstep_type(footstep_type)
+
+ RegisterSignal(target, COMSIG_MOVABLE_MOVED, PROC_REF(play_simplestep))
+ steps_for_living[target] = 0
+
+/datum/element/footstep/proc/check_footstep_type(footstep_type)
+ var/footstep_ret
+ switch(footstep_type)
+ if(FOOTSTEP_MOB_TESHARI)
+ footstep_ret = GLOB.lightclawfootstep
+ if(FOOTSTEP_MOB_CLAW)
+ footstep_ret = GLOB.clawfootstep
+ if(FOOTSTEP_MOB_HEAVY)
+ footstep_ret = GLOB.heavyfootstep
+ if(FOOTSTEP_MOB_SHOE)
+ footstep_ret = GLOB.footstep
+ if(FOOTSTEP_MOB_SLIME)
+ footstep_ret = 'sound/effects/footstep/slime1.ogg'
+ if(FOOTSTEP_MOB_SLITHER)
+ footstep_ret = 'sound/effects/footstep/crawl1.ogg'
+ else
+ footstep_ret = GLOB.barefootstep
+ return footstep_ret
+
+/datum/element/footstep/Detach(atom/movable/source)
+ UnregisterSignal(source, COMSIG_MOVABLE_MOVED)
+ steps_for_living -= source
+ return ..()
+
+///Prepares a footstep for living mobs. Determines if it should get played. Returns the turf it should get played on. Note that it is always a /turf/simulated
+/datum/element/footstep/proc/prepare_step(mob/living/source)
+ var/turf/simulated/turf = get_turf(source)
+ if(!istype(turf))
+ return
+
+ if(source.is_incorporeal())
+ return
+
+ if(source.buckled || source.throwing || source.movement_type & (source.is_ventcrawling | source.flying))
+ return
+
+ if(source.lying) //play crawling sound if we're lying
+ if(turf.footstep)
+ playsound(turf, 'sound/effects/footstep/crawl1.ogg', 15 * volume, falloff = 1, vary = sound_vary)
+ return
+
+ if(iscarbon(source))
+ var/mob/living/carbon/carbon_source = source
+ if(!carbon_source.get_organ(BP_L_LEG) && !carbon_source.get_organ(BP_R_LEG))
+ return
+ if(carbon_source.m_intent == I_WALK)
+ return// stealth
+ steps_for_living[source] += 1
+ var/steps = steps_for_living[source]
+
+ if(steps >= 6)
+ steps_for_living[source] = 0
+ steps = 0
+
+ if(steps % 2)
+ return
+
+ if(steps != 0 && !get_gravity(source)) // don't need to step as often when you hop around
+ return
+
+ . = list(
+ FOOTSTEP_MOB_SHOE = turf.footstep,
+ FOOTSTEP_MOB_BAREFOOT = turf.barefootstep,
+ FOOTSTEP_MOB_HEAVY = turf.heavyfootstep,
+ FOOTSTEP_MOB_CLAW = turf.clawfootstep,
+ STEP_SOUND_PRIORITY = STEP_SOUND_NO_PRIORITY
+ )
+
+ var/overriden = SEND_SIGNAL(turf, COMSIG_TURF_PREPARE_STEP_SOUND, .) & FOOTSTEP_OVERRIDEN
+ //The turf has no footstep sound (e.g. open space) and none of the objects on that turf (e.g. catwalks) overrides it
+ if(!overriden && isnull(turf.footstep))
+ return null
+ return .
+
+/datum/element/footstep/proc/play_simplestep(mob/living/source, atom/oldloc, direction, forced, list/old_locs, momentum_change)
+ SIGNAL_HANDLER
+
+ var/volume_multiplier = 0.3
+
+ if(!isturf(source.loc))
+ return
+
+ var/list/prepared_steps = prepare_step(source)
+ if(isnull(prepared_steps))
+ return
+
+ if(isfile(footstep_sounds) || istext(footstep_sounds))
+ playsound(source.loc, footstep_sounds, volume * volume_multiplier, falloff = 1, vary = sound_vary)
+ return
+
+ var/turf_footstep = prepared_steps[footstep_type]
+ if(isnull(turf_footstep) || !footstep_sounds[turf_footstep])
+ return
+ playsound(source.loc, pick(footstep_sounds[turf_footstep][1]), footstep_sounds[turf_footstep][2] * volume, TRUE, footstep_sounds[turf_footstep][3] + e_range, falloff = 1, vary = sound_vary)
+
+/datum/element/footstep/proc/play_humanstep(mob/living/carbon/human/source, atom/oldloc, direction, forced, list/old_locs, momentum_change)
+ SIGNAL_HANDLER
+
+ var/volume_multiplier = 0.3
+ var/range_adjustment = 0
+
+ var/list/prepared_steps = prepare_step(source)
+ if(isnull(prepared_steps))
+ return
+
+ //cache for sanic speed (lists are references anyways)
+ var/footstep_sounds = GLOB.footstep
+
+ if( source.shoes || ( source.wear_suit && (source.wear_suit.body_parts_covered & FEET) ) )
+ // we are wearing shoes
+
+ var/shoestep_type = prepared_steps[FOOTSTEP_MOB_SHOE]
+ if(!isnull(shoestep_type) && footstep_sounds[shoestep_type]) // shoestep type can be null
+ playsound(source.loc, pick(footstep_sounds[shoestep_type][1]),
+ footstep_sounds[shoestep_type][2] * volume * volume_multiplier,
+ TRUE,
+ footstep_sounds[shoestep_type][3] + e_range + range_adjustment, falloff = 1, vary = sound_vary)
+ else
+ // we are barefoot
+
+ if(source.species.special_step_sounds)
+ playsound(source.loc, pick(source.species.special_step_sounds), volume, TRUE, falloff = 1, vary = sound_vary)
+ else if (istype(source.species, /datum/species/shapeshifter/promethean))
+ playsound(source.loc, 'sound/effects/footstep/slime1.ogg', volume, TRUE, falloff = 1)
+ else if (source.custom_footstep == FOOTSTEP_MOB_SLITHER)
+ playsound(source.loc, 'sound/effects/footstep/crawl1.ogg', 15 * volume, falloff = 1, vary = sound_vary)
+ else
+ var/barefoot_type = prepared_steps[FOOTSTEP_MOB_BAREFOOT]
+ var/bare_footstep_sounds
+ if(source.custom_footstep != FOOTSTEP_MOB_HUMAN)
+ bare_footstep_sounds = check_footstep_type(source.custom_footstep)
+ else
+ bare_footstep_sounds = GLOB.barefootstep
+ if(!isnull(barefoot_type) && bare_footstep_sounds[barefoot_type]) // barefoot_type can be null
+ playsound(source.loc, pick(bare_footstep_sounds[barefoot_type][1]),
+ bare_footstep_sounds[barefoot_type][2] * volume * volume_multiplier,
+ TRUE,
+ bare_footstep_sounds[barefoot_type][3] + e_range + range_adjustment, falloff = 1, vary = sound_vary)
+
+///Prepares a footstep for machine walking
+/datum/element/footstep/proc/play_simplestep_machine(atom/movable/source, atom/oldloc, direction, forced, list/old_locs, momentum_change)
+ SIGNAL_HANDLER
+
+ var/turf/simulated/source_loc = get_turf(source)
+ if(!istype(source_loc))
+ return
+
+ playsound(source_loc, footstep_sounds, 50, falloff = 1, vary = sound_vary)
+#undef SHOULD_DISABLE_FOOTSTEPS
diff --git a/code/datums/elements/footstep_override.dm b/code/datums/elements/footstep_override.dm
new file mode 100644
index 0000000000..43d7311328
--- /dev/null
+++ b/code/datums/elements/footstep_override.dm
@@ -0,0 +1,81 @@
+///When attached, the footstep sound played by the footstep element will be replaced by this one's
+/datum/element/footstep_override
+ element_flags = ELEMENT_BESPOKE|ELEMENT_DETACH_ON_HOST_DESTROY
+ argument_hash_start_idx = 2
+ ///The sound played for movables with claw step sound type.
+ var/clawfootstep
+ ///The sound played for movables with barefoot step sound type.
+ var/barefootstep
+ ///The sound played for movables with heavy step sound type.
+ var/heavyfootstep
+ ///The sound played for movables with shoed step sound type.
+ var/footstep
+ ///The priority this element has in relation to other elements of the same type attached to other movables on the same turf.
+ var/priority
+ /**
+ * A list of turfs occupied by the movables this element is attached to.
+ * Needed so it stops listening the turf's signals ONLY when it has no movable with the element.
+ */
+ var/list/occupied_turfs = list()
+
+/datum/element/footstep_override/Attach(atom/movable/target, clawfootstep = FOOTSTEP_HARD_CLAW, barefootstep = FOOTSTEP_HARD_BAREFOOT, heavyfootstep = FOOTSTEP_GENERIC_HEAVY, footstep = FOOTSTEP_FLOOR, priority = STEP_SOUND_NO_PRIORITY)
+ . = ..()
+ if(!ismovable(target))
+ return ELEMENT_INCOMPATIBLE
+
+ src.clawfootstep = clawfootstep
+ src.barefootstep = barefootstep
+ src.heavyfootstep = heavyfootstep
+ src.footstep = footstep
+ src.priority = priority
+
+ RegisterSignal(target, COMSIG_MOVABLE_MOVED, PROC_REF(on_moved))
+ if(isturf(target.loc))
+ occupy_turf(target, target.loc)
+
+/datum/element/footstep_override/Detach(atom/movable/source)
+ if(isturf(source.loc))
+ vacate_turf(source, source.loc)
+ return ..()
+
+/datum/element/footstep_override/proc/on_moved(atom/movable/source, atom/oldloc)
+ SIGNAL_HANDLER
+ if(isturf(oldloc))
+ vacate_turf(source, oldloc)
+ if(isturf(source.loc))
+ occupy_turf(source, source.loc)
+
+/**
+ * Adds the movable to the list of movables with the element occupying the turf.
+ * If the turf was not on the list of occupied turfs before, a signal will be registered
+ * to it.
+ */
+/datum/element/footstep_override/proc/occupy_turf(atom/movable/movable, turf/location)
+ if(occupied_turfs[location])
+ occupied_turfs[location] |= movable
+ return
+ occupied_turfs[location] = list(movable)
+ RegisterSignal(location, COMSIG_TURF_PREPARE_STEP_SOUND, PROC_REF(prepare_steps))
+
+/**
+ * Removes the movable from the list of movables with the element occupying the turf.
+ * If the turf is no longer occupied, it'll be removed from the list, and the signal
+ * unregistered from it
+ */
+/datum/element/footstep_override/proc/vacate_turf(atom/movable/movable, turf/location)
+ LAZYREMOVE(occupied_turfs[location], movable)
+ if(!occupied_turfs[location])
+ occupied_turfs -= location
+ UnregisterSignal(location, COMSIG_TURF_PREPARE_STEP_SOUND)
+
+///Changes the sound types to be played if the element priority is higher than the one in the steps list.
+/datum/element/footstep_override/proc/prepare_steps(turf/source, list/steps)
+ SIGNAL_HANDLER
+ if(steps[STEP_SOUND_PRIORITY] > priority)
+ return
+ steps[FOOTSTEP_MOB_SHOE] = footstep
+ steps[FOOTSTEP_MOB_BAREFOOT] = barefootstep
+ steps[FOOTSTEP_MOB_HEAVY] = heavyfootstep
+ steps[FOOTSTEP_MOB_CLAW] = clawfootstep
+ steps[STEP_SOUND_PRIORITY] = priority
+ return FOOTSTEP_OVERRIDEN
diff --git a/code/datums/elements/light_blocking.dm b/code/datums/elements/light_blocking.dm
index f8e5cd82df..4d1d9e1ddc 100644
--- a/code/datums/elements/light_blocking.dm
+++ b/code/datums/elements/light_blocking.dm
@@ -2,7 +2,7 @@
* Attached to movable atoms with opacity. Listens to them move and updates their old and new turf loc's opacity accordingly.
*/
/datum/element/light_blocking
- element_flags = ELEMENT_DETACH
+ element_flags = ELEMENT_DETACH_ON_HOST_DESTROY
/datum/element/light_blocking/Attach(datum/target)
diff --git a/code/datums/elements/slosh.dm b/code/datums/elements/slosh.dm
new file mode 100644
index 0000000000..8e58536f02
--- /dev/null
+++ b/code/datums/elements/slosh.dm
@@ -0,0 +1,94 @@
+/datum/element/slosh
+ element_flags = ELEMENT_DETACH_ON_HOST_DESTROY|ELEMENT_BESPOKE
+ var/step_count
+ var/vore_organs_reagents
+ var/vore_footstep_volume
+ var/vore_footstep_chance
+
+/datum/element/slosh/Attach(datum/target)
+ . = ..()
+ if(!isliving(target))
+ return ELEMENT_INCOMPATIBLE
+
+ RegisterSignal(target, COMSIG_MOVABLE_MOVED, PROC_REF(handle_sloshstep), override = TRUE)
+ step_count = 0
+ vore_organs_reagents = list()
+ vore_footstep_volume = 0
+ vore_footstep_chance = 0
+ return
+
+/datum/element/slosh/Detach(datum/source)
+ UnregisterSignal(source, COMSIG_MOVABLE_MOVED)
+ step_count -= source
+ return ..()
+
+/datum/element/slosh/proc/handle_sloshstep(mob/living/source)
+ SIGNAL_HANDLER
+
+ if(ishuman(source))
+ var/mob/living/carbon/human/source_human = source
+ if(source_human.m_intent == "walk" && step_count++ % 20 == 0)
+ return
+ if(source_human.m_intent == "run" && step_count++ % 2 != 0)
+ return
+ choose_vorefootstep(source)
+ if(issilicon(source))
+ if(step_count++ % 2)
+ choose_vorefootstep(source)
+
+
+/datum/element/slosh/proc/choose_vorefootstep(mob/living/source)
+ if(step_count++ >= 5)
+
+ vore_organs_reagents = list()
+ var/highest_vol = 0
+
+ for(var/obj/belly/B in source.vore_organs)
+ var/total_volume = B.reagents.total_volume
+ vore_organs_reagents += total_volume
+
+ if(B.show_liquids && B.vorefootsteps_sounds && highest_vol < total_volume)
+ highest_vol = total_volume
+
+ if(highest_vol < 20)
+ vore_footstep_volume = 0
+ vore_footstep_chance = 0
+ else
+ vore_footstep_volume = 20 + highest_vol * 4/5
+ vore_footstep_chance = highest_vol/4
+
+ step_count = 0
+
+ if(!vore_footstep_volume || !vore_footstep_chance)
+ return
+
+ if(prob(vore_footstep_chance))
+ handle_vorefootstep(source)
+
+/datum/element/slosh/proc/handle_vorefootstep(mob/living/source)
+ if(!CONFIG_GET(number/vorefootstep_volume) || !vore_footstep_volume)
+ return
+
+ var/S = pick(GLOB.slosh)
+ if(!S) return
+ var/volume = CONFIG_GET(number/vorefootstep_volume) * (vore_footstep_volume/100)
+
+ if(ishuman(source))
+ var/mob/living/carbon/human/human_source = source
+
+ if(!human_source.shoes || human_source.m_intent == "walk")
+ volume = CONFIG_GET(number/vorefootstep_volume) * (vore_footstep_volume/100) * 0.75
+ else if(human_source.shoes)
+ var/obj/item/clothing/shoes/feet = human_source.shoes
+ if(istype(feet))
+ volume = feet.step_volume_mod * CONFIG_GET(number/vorefootstep_volume) * (vore_footstep_volume/100) * 0.75
+ if(!human_source.has_organ(BP_L_FOOT) && !human_source.has_organ(BP_R_FOOT))
+ return
+
+ if(source.buckled || source.lying || source.throwing)
+ return
+ if(!has_gravity(source) && prob(75))
+ return
+
+ playsound(source.loc, S, volume, FALSE, preference = /datum/client_preference/digestion_noises)
+ return
diff --git a/code/datums/signals.dm b/code/datums/signals.dm
new file mode 100644
index 0000000000..47815339d4
--- /dev/null
+++ b/code/datums/signals.dm
@@ -0,0 +1,127 @@
+/**
+ * Register to listen for a signal from the passed in target
+ *
+ * This sets up a listening relationship such that when the target object emits a signal
+ * the source datum this proc is called upon, will receive a callback to the given proctype
+ * Use PROC_REF(procname), TYPE_PROC_REF(type,procname) or GLOBAL_PROC_REF(procname) macros to validate the passed in proc at compile time.
+ * PROC_REF for procs defined on current type or it's ancestors, TYPE_PROC_REF for procs defined on unrelated type and GLOBAL_PROC_REF for global procs.
+ * Return values from procs registered must be a bitfield
+ *
+ * Arguments:
+ * * datum/target The target to listen for signals from
+ * * signal_type A signal name
+ * * proctype The proc to call back when the signal is emitted
+ * * override If a previous registration exists you must explicitly set this
+ */
+/datum/proc/RegisterSignal(datum/target, signal_type, proctype, override = FALSE)
+ if(QDELETED(src) || QDELETED(target))
+ return
+
+ if (islist(signal_type))
+ var/static/list/known_failures = list()
+ var/list/signal_type_list = signal_type
+ var/message = "([target.type]) is registering [signal_type_list.Join(", ")] as a list, the older method. Change it to RegisterSignals."
+
+ if (!(message in known_failures))
+ known_failures[message] = TRUE
+ stack_trace("[target] [message]")
+
+ RegisterSignals(target, signal_type, proctype, override)
+ return
+
+ var/list/procs = (_signal_procs ||= list())
+ var/list/target_procs = (procs[target] ||= list())
+ var/list/lookup = (target._listen_lookup ||= list())
+
+ var/exists = target_procs[signal_type]
+ target_procs[signal_type] = proctype
+
+ if(exists)
+ if(!override)
+ var/override_message = "[signal_type] overridden. Use override = TRUE to suppress this warning.\nTarget: [target] ([target.type]) Proc: [proctype]"
+ //log_signal(override_message) // We don't have log_signal
+ log_world(override_message)
+ stack_trace(override_message)
+ return
+
+ var/list/looked_up = lookup[signal_type]
+
+ if(isnull(looked_up)) // Nothing has registered here yet
+ lookup[signal_type] = src
+ else if(!islist(looked_up)) // One other thing registered here
+ lookup[signal_type] = list(looked_up, src)
+ else // Many other things have registered here
+ looked_up += src
+
+/// Registers multiple signals to the same proc.
+/datum/proc/RegisterSignals(datum/target, list/signal_types, proctype, override = FALSE)
+ for (var/signal_type in signal_types)
+ RegisterSignal(target, signal_type, proctype, override)
+
+/**
+ * Stop listening to a given signal from target
+ *
+ * Breaks the relationship between target and source datum, removing the callback when the signal fires
+ *
+ * Doesn't care if a registration exists or not
+ *
+ * Arguments:
+ * * datum/target Datum to stop listening to signals from
+ * * sig_typeor_types Signal string key or list of signal keys to stop listening to specifically
+ */
+/datum/proc/UnregisterSignal(datum/target, sig_type_or_types)
+ var/list/lookup = target._listen_lookup
+ if(!_signal_procs || !_signal_procs[target] || !lookup)
+ return
+ if(!islist(sig_type_or_types))
+ sig_type_or_types = list(sig_type_or_types)
+ for(var/sig in sig_type_or_types)
+ if(!_signal_procs[target][sig])
+ if(!istext(sig))
+ stack_trace("We're unregistering with something that isn't a valid signal \[[sig]\], you fucked up")
+ continue
+ switch(length(lookup[sig]))
+ if(2)
+ lookup[sig] = (lookup[sig]-src)[1]
+ if(1)
+ stack_trace("[target] ([target.type]) somehow has single length list inside _listen_lookup")
+ if(src in lookup[sig])
+ lookup -= sig
+ if(!length(lookup))
+ target._listen_lookup = null
+ break
+ if(0)
+ if(lookup[sig] != src)
+ continue
+ lookup -= sig
+ if(!length(lookup))
+ target._listen_lookup = null
+ break
+ else
+ lookup[sig] -= src
+
+ _signal_procs[target] -= sig_type_or_types
+ if(!_signal_procs[target].len)
+ _signal_procs -= target
+
+/**
+ * Internal proc to handle most all of the signaling procedure
+ *
+ * Will runtime if used on datums with an empty lookup list
+ *
+ * Use the [SEND_SIGNAL] define instead
+ */
+/datum/proc/_SendSignal(sigtype, list/arguments)
+ var/target = _listen_lookup[sigtype]
+ if(!length(target))
+ var/datum/listening_datum = target
+ return NONE | call(listening_datum, listening_datum._signal_procs[src][sigtype])(arglist(arguments))
+ . = NONE
+ // This exists so that even if one of the signal receivers unregisters the signal,
+ // all the objects that are receiving the signal get the signal this final time.
+ // AKA: No you can't cancel the signal reception of another object by doing an unregister in the same signal.
+ var/list/queued_calls = list()
+ for(var/datum/listening_datum as anything in target)
+ queued_calls[listening_datum] = listening_datum._signal_procs[src][sigtype]
+ for(var/datum/listening_datum as anything in queued_calls)
+ . |= call(listening_datum, queued_calls[listening_datum])(arglist(arguments))
diff --git a/code/game/turfs/flooring/flooring_premade.dm b/code/game/turfs/flooring/flooring_premade.dm
index 927b382b10..d521302302 100644
--- a/code/game/turfs/flooring/flooring_premade.dm
+++ b/code/game/turfs/flooring/flooring_premade.dm
@@ -192,6 +192,9 @@
icon_state = "grass0"
can_dirty = FALSE //VOREStation Edit
initial_flooring = /decl/flooring/grass
+ footstep = FOOTSTEP_GRASS
+ barefootstep = FOOTSTEP_GRASS
+ clawfootstep = FOOTSTEP_GRASS
/turf/simulated/floor/tiled
name = "floor"
diff --git a/code/game/turfs/simulated/floor.dm b/code/game/turfs/simulated/floor.dm
index a13648fd9f..f0150ed393 100644
--- a/code/game/turfs/simulated/floor.dm
+++ b/code/game/turfs/simulated/floor.dm
@@ -13,12 +13,6 @@
var/base_desc = "The naked hull."
var/base_icon = 'icons/turf/flooring/plating_vr.dmi'
var/base_icon_state = "plating"
- var/static/list/base_footstep_sounds = list("human" = list(
- 'sound/effects/footstep/plating1.ogg',
- 'sound/effects/footstep/plating2.ogg',
- 'sound/effects/footstep/plating3.ogg',
- 'sound/effects/footstep/plating4.ogg',
- 'sound/effects/footstep/plating5.ogg'))
var/list/old_decals = null
@@ -42,8 +36,6 @@
if(floortype)
set_flooring(get_flooring_data(floortype), TRUE)
. = INITIALIZE_HINT_LATELOAD // We'll update our icons after everyone is ready
- else
- footstep_sounds = base_footstep_sounds
if(can_dirty && can_start_dirty)
if(prob(dirty_prob))
dirt += rand(50,100)
@@ -63,7 +55,6 @@
if(is_plating() && !initializing) // Plating -> Flooring
swap_decals()
flooring = newflooring
- footstep_sounds = newflooring.footstep_sounds
if(!initializing)
update_icon(1)
levelupdate()
@@ -80,7 +71,6 @@
desc = base_desc
icon = base_icon
icon_state = base_icon_state
- footstep_sounds = base_footstep_sounds
if(!is_plating()) // Flooring -> Plating
swap_decals()
diff --git a/code/game/turfs/simulated/outdoors/outdoors.dm b/code/game/turfs/simulated/outdoors/outdoors.dm
index 74a08a7c46..3503f8c783 100644
--- a/code/game/turfs/simulated/outdoors/outdoors.dm
+++ b/code/game/turfs/simulated/outdoors/outdoors.dm
@@ -221,16 +221,6 @@ var/list/turf_edge_cache = list()
desc = "Looks dirty."
icon = 'icons/turf/outdoors_vr.dmi'
icon_base = "dirt0"
- footstep_sounds = list("human" = list(
- 'sound/effects/footstep/asteroid1.ogg',
- 'sound/effects/footstep/asteroid2.ogg',
- 'sound/effects/footstep/asteroid3.ogg',
- 'sound/effects/footstep/asteroid4.ogg',
- 'sound/effects/footstep/asteroid5.ogg',
- 'sound/effects/footstep/MedDirt1.ogg',
- 'sound/effects/footstep/MedDirt2.ogg',
- 'sound/effects/footstep/MedDirt3.ogg',
- 'sound/effects/footstep/MedDirt4.ogg'))
/turf/simulated/floor/outdoors/newdirt/Initialize(mapload)
var/possibledirts = list(
@@ -290,12 +280,6 @@ var/list/turf_edge_cache = list()
can_paint = 1
can_engrave = FALSE
- footstep_sounds = list("human" = list(
- 'sound/effects/footstep/LightStone1.ogg',
- 'sound/effects/footstep/LightStone2.ogg',
- 'sound/effects/footstep/LightStone3.ogg',
- 'sound/effects/footstep/LightStone4.ogg',))
-
/obj/item/stack/tile/floor/sidewalk
name = "sidewalk tile"
singular_name = "floor tile"
diff --git a/code/game/turfs/simulated/water.dm b/code/game/turfs/simulated/water.dm
index 3f004451d1..655e8f02dd 100644
--- a/code/game/turfs/simulated/water.dm
+++ b/code/game/turfs/simulated/water.dm
@@ -23,8 +23,6 @@
/turf/simulated/floor/water/Initialize()
. = ..()
- var/decl/flooring/F = get_flooring_data(/decl/flooring/water)
- footstep_sounds = F?.footstep_sounds
update_icon()
handle_fish()
diff --git a/code/game/turfs/turf.dm b/code/game/turfs/turf.dm
index 4f0d6be739..ebf0c54b15 100644
--- a/code/game/turfs/turf.dm
+++ b/code/game/turfs/turf.dm
@@ -29,13 +29,62 @@
var/movement_cost = 0 // How much the turf slows down movement, if any.
- var/list/footstep_sounds = null
-
var/block_tele = FALSE // If true, most forms of teleporting to or from this turf tile will fail.
var/can_build_into_floor = FALSE // Used for things like RCDs (and maybe lattices/floor tiles in the future), to see if a floor should replace it.
var/list/dangerous_objects // List of 'dangerous' objs that the turf holds that can cause something bad to happen when stepped on, used for AI mobs.
var/tmp/changing_turf
+ var/footstep
+ var/barefootstep
+ var/heavyfootstep
+ var/clawfootstep
+
+/turf/simulated/floor
+ footstep = FOOTSTEP_FLOOR
+ barefootstep = FOOTSTEP_HARD_BAREFOOT
+ heavyfootstep = FOOTSTEP_GENERIC_HEAVY
+ clawfootstep = FOOTSTEP_HARD_CLAW
+
+/turf/simulated/floor/wood
+ footstep = FOOTSTEP_WOOD
+ barefootstep = FOOTSTEP_WOOD_BAREFOOT
+ clawfootstep = FOOTSTEP_WOOD_CLAW
+
+/turf/simulated/floor/carpet
+ footstep = FOOTSTEP_CARPET
+ barefootstep = FOOTSTEP_CARPET_BAREFOOT
+ clawfootstep = FOOTSTEP_CARPET_BAREFOOT
+
+/turf/simulated/floor/plating
+ footstep = FOOTSTEP_PLATING
+ barefootstep = FOOTSTEP_HARD_BAREFOOT
+ clawfootstep = FOOTSTEP_HARD_CLAW
+
+/turf/simulated/mineral
+ footstep = FOOTSTEP_SAND
+ barefootstep = FOOTSTEP_SAND
+ clawfootstep = FOOTSTEP_SAND
+
+/turf/simulated/floor/outdoors
+ footstep = FOOTSTEP_SAND
+ barefootstep = FOOTSTEP_SAND
+ clawfootstep = FOOTSTEP_SAND
+
+/turf/simulated/floor/outdoors/grass
+ footstep = FOOTSTEP_GRASS
+ barefootstep = FOOTSTEP_GRASS
+ clawfootstep = FOOTSTEP_GRASS
+
+/turf/simulated/floor/water
+ footstep = FOOTSTEP_WATER
+ barefootstep = FOOTSTEP_WATER
+ clawfootstep = FOOTSTEP_WATER
+
+/turf/simulated/floor/lava
+ footstep = FOOTSTEP_LAVA
+ barefootstep = FOOTSTEP_LAVA
+ clawfootstep = FOOTSTEP_LAVA
+
/turf/Initialize(mapload)
. = ..()
for(var/atom/movable/AM in src)
diff --git a/code/modules/client/preference_setup/vore/02_size.dm b/code/modules/client/preference_setup/vore/02_size.dm
index 843819e16d..cbe0c9ded0 100644
--- a/code/modules/client/preference_setup/vore/02_size.dm
+++ b/code/modules/client/preference_setup/vore/02_size.dm
@@ -14,6 +14,7 @@
var/voice_freq = 0
var/voice_sound = "beep-boop"
var/custom_speech_bubble = "default"
+ var/custom_footstep = "Default"
// Definition of the stuff for Sizing
/datum/category_item/player_setup_item/vore/size
@@ -30,6 +31,7 @@
pref.voice_freq = save_data["voice_freq"]
pref.voice_sound = save_data["voice_sound"]
pref.custom_speech_bubble = save_data["custom_speech_bubble"]
+ pref.custom_footstep = save_data["custom_footstep"]
/datum/category_item/player_setup_item/vore/size/save_character(list/save_data)
save_data["size_multiplier"] = pref.size_multiplier
@@ -41,6 +43,7 @@
save_data["voice_freq"] = pref.voice_freq
save_data["voice_sound"] = pref.voice_sound
save_data["custom_speech_bubble"] = pref.custom_speech_bubble
+ save_data["custom_footstep"] = pref.custom_footstep
/datum/category_item/player_setup_item/vore/size/sanitize_character()
pref.weight_vr = sanitize_integer(pref.weight_vr, WEIGHT_MIN, WEIGHT_MAX, initial(pref.weight_vr))
@@ -54,6 +57,8 @@
pref.size_multiplier = initial(pref.size_multiplier)
if(!(pref.custom_speech_bubble in selectable_speech_bubbles))
pref.custom_speech_bubble = "default"
+ if(!(pref.custom_footstep))
+ pref.custom_footstep = "Default"
/datum/category_item/player_setup_item/vore/size/copy_to_mob(var/mob/living/carbon/human/character)
character.weight = pref.weight_vr
@@ -68,6 +73,7 @@
else
character.voice_sounds_list = get_talk_sound(pref.voice_sound)
character.custom_speech_bubble = pref.custom_speech_bubble
+ character.custom_footstep = pref.custom_footstep
/datum/category_item/player_setup_item/vore/size/content(var/mob/user)
. += "
"
@@ -78,6 +84,7 @@
. += span_bold("Voice Sounds:") + " [pref.voice_sound]
"
. += "Test Selected Voice
"
. += span_bold("Custom Speech Bubble:") + " [pref.custom_speech_bubble]
"
+ . += span_bold("Custom Footstep Sounds:") + "[pref.custom_footstep]
"
. += "
"
. += span_bold("Relative Weight:") + " [pref.weight_vr]
"
. += span_bold("Weight Gain Rate:") + " [pref.weight_gain]
"
@@ -185,6 +192,13 @@
pref.custom_speech_bubble = choice
return TOPIC_REFRESH
+ else if(href_list["customize_footsteps"])
+ var/list/footstep_choice = selectable_footstep
+ var/choice = tgui_input_list(user, "What footstep sounds would your character make?", "Custom Foostep Sounds", footstep_choice)
+ if(choice)
+ pref.custom_footstep = footstep_choice[choice]
+ return TOPIC_REFRESH
+
else if(href_list["voice_test"])
var/sound/S
switch(pref.voice_sound)
diff --git a/code/modules/mining/mine_turfs.dm b/code/modules/mining/mine_turfs.dm
index 165974bb3c..a4243aecdd 100644
--- a/code/modules/mining/mine_turfs.dm
+++ b/code/modules/mining/mine_turfs.dm
@@ -205,8 +205,6 @@ var/list/mining_overlay_cache = list()
if(random_icon)
dir = pick(alldirs)
. = INITIALIZE_HINT_LATELOAD
- var/decl/flooring/F = get_flooring_data(/decl/flooring/sand)
- footstep_sounds = F?.footstep_sounds
/turf/simulated/mineral/LateInitialize()
if(density && mineral)
diff --git a/code/modules/mob/living/bot/secbot.dm b/code/modules/mob/living/bot/secbot.dm
index c440ad9c1a..3fa50ac351 100644
--- a/code/modules/mob/living/bot/secbot.dm
+++ b/code/modules/mob/living/bot/secbot.dm
@@ -224,7 +224,8 @@
/mob/living/bot/secbot/resetTarget()
..()
- UnregisterSignal(target, COMSIG_OBSERVER_MOVED)
+ if(target)
+ UnregisterSignal(target, COMSIG_OBSERVER_MOVED)
awaiting_surrender = 0
attacked = FALSE
walk_to(src, 0)
diff --git a/code/modules/mob/living/carbon/carbon.dm b/code/modules/mob/living/carbon/carbon.dm
index 9f900ccb9f..a89956eeea 100644
--- a/code/modules/mob/living/carbon/carbon.dm
+++ b/code/modules/mob/living/carbon/carbon.dm
@@ -8,6 +8,8 @@
if (!default_language && species_language)
default_language = GLOB.all_languages[species_language]
+ AddElement(/datum/element/footstep, custom_footstep, 1, -6)
+
/mob/living/carbon/Life()
..()
diff --git a/code/modules/mob/living/carbon/human/human_movement.dm b/code/modules/mob/living/carbon/human/human_movement.dm
index 83a942425a..af9036e108 100644
--- a/code/modules/mob/living/carbon/human/human_movement.dm
+++ b/code/modules/mob/living/carbon/human/human_movement.dm
@@ -294,49 +294,9 @@
// Handle footstep sounds
/mob/living/carbon/human/handle_footstep(var/turf/T)
- if(!istype(T))
- return
- if(is_incorporeal())
- return
- if(!CONFIG_GET(number/footstep_volume) || !T.footstep_sounds || !T.footstep_sounds.len)
- return
- // Future Upgrades - Multi species support
- var/list/footstep_sounds = T.footstep_sounds["human"]
- if(!footstep_sounds)
- return
-
- var/S = pick(footstep_sounds)
- GLOB.step_taken_shift_roundstat++
- if(!S) return
-
- // Play every 20 steps while walking, for the sneak
- if(m_intent == I_WALK && step_count++ % 20 != 0)
- return
-
- // Play every other step while running
- if(m_intent == I_RUN && step_count++ % 2 != 0)
- return
-
- var/volume = CONFIG_GET(number/footstep_volume)
-
- // Reduce volume while walking or barefoot
- if(!shoes || m_intent == I_WALK)
- volume *= 0.5
- else if(shoes)
- var/obj/item/clothing/shoes/feet = shoes
- if(istype(feet))
- volume *= feet.step_volume_mod
-
- if(!has_organ(BP_L_FOOT) && !has_organ(BP_R_FOOT))
- return // no feet = no footsteps
-
- if(buckled || lying || throwing)
- return // people flying, lying down or sitting do not step
-
- if(!get_gravity(src) && prob(75))
- return // Far less likely to make noise in no gravity
-
- playsound(T, S, volume, FALSE)
+ if(shoes && loc == T && get_gravity(loc) && !flying)
+ if(SEND_SIGNAL(shoes, COMSIG_SHOES_STEP_ACTION, m_intent))
+ return
return
/mob/living/carbon/human/set_dir(var/new_dir)
diff --git a/code/modules/mob/living/carbon/human/species/species.dm b/code/modules/mob/living/carbon/human/species/species.dm
index 61102a0dd9..2f75a753d8 100644
--- a/code/modules/mob/living/carbon/human/species/species.dm
+++ b/code/modules/mob/living/carbon/human/species/species.dm
@@ -88,6 +88,9 @@
var/male_sneeze_sound = 'sound/effects/mob_effects/sneeze.ogg'
var/female_sneeze_sound = 'sound/effects/mob_effects/f_sneeze.ogg'
+ var/footstep = FOOTSTEP_MOB_HUMAN
+ var/list/special_step_sounds = null
+
// Combat/health/chem/etc. vars.
var/total_health = 100 // How much damage the mob can take before entering crit.
var/list/unarmed_types = list( // Possible unarmed attacks that the mob will use in combat,
@@ -332,6 +335,9 @@
update_sort_hint()
+/datum/species/proc/get_footsep_sounds()
+ return footstep
+
/datum/species/proc/update_sort_hint()
if(spawn_flags & SPECIES_IS_RESTRICTED)
sort_hint = SPECIES_SORT_RESTRICTED
diff --git a/code/modules/mob/living/carbon/human/species/station/prometheans.dm b/code/modules/mob/living/carbon/human/species/station/prometheans.dm
index 4334d89fab..84b792a941 100644
--- a/code/modules/mob/living/carbon/human/species/station/prometheans.dm
+++ b/code/modules/mob/living/carbon/human/species/station/prometheans.dm
@@ -133,6 +133,8 @@ var/datum/species/shapeshifter/promethean/prometheans
/decl/emote/visible/vibrate
)
+ footstep = FOOTSTEP_MOB_SLIME
+
/datum/species/shapeshifter/promethean/New()
..()
prometheans = src
diff --git a/code/modules/mob/living/carbon/human/species/station/station.dm b/code/modules/mob/living/carbon/human/species/station/station.dm
index 4b00ed832b..34c5e03298 100644
--- a/code/modules/mob/living/carbon/human/species/station/station.dm
+++ b/code/modules/mob/living/carbon/human/species/station/station.dm
@@ -173,6 +173,8 @@
/decl/emote/human/stopsway
)
+ footstep = FOOTSTEP_MOB_CLAW
+
/datum/species/unathi/equip_survival_gear(var/mob/living/carbon/human/H)
..()
H.equip_to_slot_or_del(new /obj/item/clothing/shoes/sandal(H),slot_shoes)
diff --git a/code/modules/mob/living/carbon/human/species/station/teshari.dm b/code/modules/mob/living/carbon/human/species/station/teshari.dm
index 9a7f71c86e..ad163ab68d 100644
--- a/code/modules/mob/living/carbon/human/species/station/teshari.dm
+++ b/code/modules/mob/living/carbon/human/species/station/teshari.dm
@@ -160,6 +160,8 @@
/decl/emote/audible/teshtrill
)
+ footstep = FOOTSTEP_MOB_TESHARI
+
/datum/species/teshari/equip_survival_gear(var/mob/living/carbon/human/H)
..()
if(!(H.client?.prefs?.shoe_hater))
diff --git a/code/modules/mob/living/silicon/silicon.dm b/code/modules/mob/living/silicon/silicon.dm
index 011b3ba217..cb80e2af88 100644
--- a/code/modules/mob/living/silicon/silicon.dm
+++ b/code/modules/mob/living/silicon/silicon.dm
@@ -37,6 +37,8 @@
init_id()
init_subsystems()
+ AddElement(/datum/element/footstep, FOOTSTEP_MOB_SHOE, 0.75, -6)
+
/mob/living/silicon/Destroy()
silicon_mob_list -= src
for(var/datum/alarm_handler/AH in SSalarm.all_handlers)
diff --git a/code/modules/mob/living/simple_mob/simple_mob.dm b/code/modules/mob/living/simple_mob/simple_mob.dm
index 55923db0b5..b096d1b062 100644
--- a/code/modules/mob/living/simple_mob/simple_mob.dm
+++ b/code/modules/mob/living/simple_mob/simple_mob.dm
@@ -205,6 +205,7 @@
if(CONFIG_GET(flag/allow_simple_mob_recolor))
add_verb(src, /mob/living/simple_mob/proc/ColorMate)
+ AddElement(/datum/element/footstep, FOOTSTEP_MOB_SHOE, 0.5, -6) // Need to go through all of the mobs to give them proper footsteps...
return ..()
diff --git a/code/modules/mob/mob_defines.dm b/code/modules/mob/mob_defines.dm
index 8bd7700d14..6d47f60731 100644
--- a/code/modules/mob/mob_defines.dm
+++ b/code/modules/mob/mob_defines.dm
@@ -241,3 +241,5 @@
var/list/viruses
var/list/resistances
+
+ var/custom_footstep = FOOTSTEP_MOB_SHOE
diff --git a/code/modules/tgui/external.dm b/code/modules/tgui/external.dm
index 42c8241292..64c5b5c051 100644
--- a/code/modules/tgui/external.dm
+++ b/code/modules/tgui/external.dm
@@ -74,7 +74,7 @@
* change static data.
*/
/datum/proc/update_static_data_for_all_viewers()
- for (var/datum/tgui/window as anything in open_uis)
+ for (var/datum/tgui/window as anything in open_tguis)
window.send_full_update()
/**
diff --git a/code/modules/xenoarcheaology/effect_master.dm b/code/modules/xenoarcheaology/effect_master.dm
index 1b00bc53c9..b3f185fd98 100644
--- a/code/modules/xenoarcheaology/effect_master.dm
+++ b/code/modules/xenoarcheaology/effect_master.dm
@@ -167,7 +167,7 @@ var/list/toxic_reagents = list(TOXIN_PATH)
STOP_PROCESSING(SSobj,src)
- . = ..(silent=TRUE)
+ . = ..()
/datum/component/artifact_master/proc/do_setup()
if(LAZYLEN(make_effects))
diff --git a/sound/effects/footstep/BudgieStep1.ogg b/sound/effects/footstep/BudgieStep1.ogg
new file mode 100644
index 0000000000..fb8f01367b
Binary files /dev/null and b/sound/effects/footstep/BudgieStep1.ogg differ
diff --git a/sound/effects/footstep/BudgieStep2.ogg b/sound/effects/footstep/BudgieStep2.ogg
new file mode 100644
index 0000000000..78a2a5bd3c
Binary files /dev/null and b/sound/effects/footstep/BudgieStep2.ogg differ
diff --git a/sound/effects/footstep/BudgieStep3.ogg b/sound/effects/footstep/BudgieStep3.ogg
new file mode 100644
index 0000000000..d8199cae78
Binary files /dev/null and b/sound/effects/footstep/BudgieStep3.ogg differ
diff --git a/sound/effects/footstep/BudgieStep4.ogg b/sound/effects/footstep/BudgieStep4.ogg
new file mode 100644
index 0000000000..2e176b380a
Binary files /dev/null and b/sound/effects/footstep/BudgieStep4.ogg differ
diff --git a/sound/effects/footstep/BudgieStep5.ogg b/sound/effects/footstep/BudgieStep5.ogg
new file mode 100644
index 0000000000..8d79d45fe6
Binary files /dev/null and b/sound/effects/footstep/BudgieStep5.ogg differ
diff --git a/sound/effects/footstep/BudgieStep6.ogg b/sound/effects/footstep/BudgieStep6.ogg
new file mode 100644
index 0000000000..112fa7051c
Binary files /dev/null and b/sound/effects/footstep/BudgieStep6.ogg differ
diff --git a/sound/effects/footstep/carpetbarefoot1.ogg b/sound/effects/footstep/carpetbarefoot1.ogg
new file mode 100644
index 0000000000..81615d2970
Binary files /dev/null and b/sound/effects/footstep/carpetbarefoot1.ogg differ
diff --git a/sound/effects/footstep/carpetbarefoot2.ogg b/sound/effects/footstep/carpetbarefoot2.ogg
new file mode 100644
index 0000000000..d1c7e1627e
Binary files /dev/null and b/sound/effects/footstep/carpetbarefoot2.ogg differ
diff --git a/sound/effects/footstep/carpetbarefoot3.ogg b/sound/effects/footstep/carpetbarefoot3.ogg
new file mode 100644
index 0000000000..13ecb3398b
Binary files /dev/null and b/sound/effects/footstep/carpetbarefoot3.ogg differ
diff --git a/sound/effects/footstep/carpetbarefoot4.ogg b/sound/effects/footstep/carpetbarefoot4.ogg
new file mode 100644
index 0000000000..31850250be
Binary files /dev/null and b/sound/effects/footstep/carpetbarefoot4.ogg differ
diff --git a/sound/effects/footstep/carpetbarefoot5.ogg b/sound/effects/footstep/carpetbarefoot5.ogg
new file mode 100644
index 0000000000..e9a44765b1
Binary files /dev/null and b/sound/effects/footstep/carpetbarefoot5.ogg differ
diff --git a/sound/effects/footstep/crawl1.ogg b/sound/effects/footstep/crawl1.ogg
new file mode 100644
index 0000000000..61a73a58d0
Binary files /dev/null and b/sound/effects/footstep/crawl1.ogg differ
diff --git a/sound/effects/footstep/hardbarefoot1.ogg b/sound/effects/footstep/hardbarefoot1.ogg
new file mode 100644
index 0000000000..2614872191
Binary files /dev/null and b/sound/effects/footstep/hardbarefoot1.ogg differ
diff --git a/sound/effects/footstep/hardbarefoot2.ogg b/sound/effects/footstep/hardbarefoot2.ogg
new file mode 100644
index 0000000000..7d89d96105
Binary files /dev/null and b/sound/effects/footstep/hardbarefoot2.ogg differ
diff --git a/sound/effects/footstep/hardbarefoot3.ogg b/sound/effects/footstep/hardbarefoot3.ogg
new file mode 100644
index 0000000000..639751fab0
Binary files /dev/null and b/sound/effects/footstep/hardbarefoot3.ogg differ
diff --git a/sound/effects/footstep/hardbarefoot4.ogg b/sound/effects/footstep/hardbarefoot4.ogg
new file mode 100644
index 0000000000..9cf363a18c
Binary files /dev/null and b/sound/effects/footstep/hardbarefoot4.ogg differ
diff --git a/sound/effects/footstep/hardbarefoot5.ogg b/sound/effects/footstep/hardbarefoot5.ogg
new file mode 100644
index 0000000000..72ebeca84d
Binary files /dev/null and b/sound/effects/footstep/hardbarefoot5.ogg differ
diff --git a/sound/effects/footstep/hardclaw1.ogg b/sound/effects/footstep/hardclaw1.ogg
new file mode 100644
index 0000000000..1d66eb4d49
Binary files /dev/null and b/sound/effects/footstep/hardclaw1.ogg differ
diff --git a/sound/effects/footstep/hardclaw2.ogg b/sound/effects/footstep/hardclaw2.ogg
new file mode 100644
index 0000000000..a6a7951d77
Binary files /dev/null and b/sound/effects/footstep/hardclaw2.ogg differ
diff --git a/sound/effects/footstep/hardclaw3.ogg b/sound/effects/footstep/hardclaw3.ogg
new file mode 100644
index 0000000000..a2e5462199
Binary files /dev/null and b/sound/effects/footstep/hardclaw3.ogg differ
diff --git a/sound/effects/footstep/hardclaw4.ogg b/sound/effects/footstep/hardclaw4.ogg
new file mode 100644
index 0000000000..bd845a8782
Binary files /dev/null and b/sound/effects/footstep/hardclaw4.ogg differ
diff --git a/sound/effects/footstep/heavy1.ogg b/sound/effects/footstep/heavy1.ogg
new file mode 100644
index 0000000000..bfc80a4270
Binary files /dev/null and b/sound/effects/footstep/heavy1.ogg differ
diff --git a/sound/effects/footstep/heavy2.ogg b/sound/effects/footstep/heavy2.ogg
new file mode 100644
index 0000000000..514e3ac3e2
Binary files /dev/null and b/sound/effects/footstep/heavy2.ogg differ
diff --git a/sound/effects/footstep/slime1.ogg b/sound/effects/footstep/slime1.ogg
new file mode 100644
index 0000000000..a83b7646f1
Binary files /dev/null and b/sound/effects/footstep/slime1.ogg differ
diff --git a/sound/effects/footstep/woodbarefoot1.ogg b/sound/effects/footstep/woodbarefoot1.ogg
new file mode 100644
index 0000000000..bb66da770e
Binary files /dev/null and b/sound/effects/footstep/woodbarefoot1.ogg differ
diff --git a/sound/effects/footstep/woodbarefoot2.ogg b/sound/effects/footstep/woodbarefoot2.ogg
new file mode 100644
index 0000000000..67397d868e
Binary files /dev/null and b/sound/effects/footstep/woodbarefoot2.ogg differ
diff --git a/sound/effects/footstep/woodbarefoot3.ogg b/sound/effects/footstep/woodbarefoot3.ogg
new file mode 100644
index 0000000000..113a89003a
Binary files /dev/null and b/sound/effects/footstep/woodbarefoot3.ogg differ
diff --git a/sound/effects/footstep/woodbarefoot4.ogg b/sound/effects/footstep/woodbarefoot4.ogg
new file mode 100644
index 0000000000..ccc2e82075
Binary files /dev/null and b/sound/effects/footstep/woodbarefoot4.ogg differ
diff --git a/sound/effects/footstep/woodbarefoot5.ogg b/sound/effects/footstep/woodbarefoot5.ogg
new file mode 100644
index 0000000000..6fbce27109
Binary files /dev/null and b/sound/effects/footstep/woodbarefoot5.ogg differ
diff --git a/sound/effects/footstep/woodclaw1.ogg b/sound/effects/footstep/woodclaw1.ogg
new file mode 100644
index 0000000000..181403b93f
Binary files /dev/null and b/sound/effects/footstep/woodclaw1.ogg differ
diff --git a/sound/effects/footstep/woodclaw2.ogg b/sound/effects/footstep/woodclaw2.ogg
new file mode 100644
index 0000000000..29b04a9554
Binary files /dev/null and b/sound/effects/footstep/woodclaw2.ogg differ
diff --git a/sound/effects/footstep/woodclaw3.ogg b/sound/effects/footstep/woodclaw3.ogg
new file mode 100644
index 0000000000..9f4ac6d334
Binary files /dev/null and b/sound/effects/footstep/woodclaw3.ogg differ
diff --git a/sound/effects/meatslap.ogg b/sound/effects/meatslap.ogg
new file mode 100644
index 0000000000..3d8ea7df1a
Binary files /dev/null and b/sound/effects/meatslap.ogg differ
diff --git a/vorestation.dme b/vorestation.dme
index c41047b091..9c508495e7 100644
--- a/vorestation.dme
+++ b/vorestation.dme
@@ -67,6 +67,7 @@
#include "code\__defines\exosuit_fab.dm"
#include "code\__defines\faction.dm"
#include "code\__defines\flags.dm"
+#include "code\__defines\footsteps.dm"
#include "code\__defines\gamemode.dm"
#include "code\__defines\holder.dm"
#include "code\__defines\holomap.dm"
@@ -167,6 +168,7 @@
#include "code\__defines\dcs\helpers.dm"
#include "code\__defines\dcs\signals.dm"
#include "code\__defines\dcs\signals\signals_subsystem.dm"
+#include "code\__defines\dcs\signals\signals_turf.dm"
#include "code\__defines\traits\_traits.dm"
#include "code\__defines\traits\declarations.dm"
#include "code\__defines\traits\sources.dm"
@@ -439,6 +441,7 @@
#include "code\datums\progressbar.dm"
#include "code\datums\reference_tracking.dm"
#include "code\datums\riding.dm"
+#include "code\datums\signals.dm"
#include "code\datums\soul_link.dm"
#include "code\datums\sun.dm"
#include "code\datums\verb_callbacks.dm"
@@ -527,6 +530,8 @@
#include "code\datums\diseases\advance\symptoms\weigh.dm"
#include "code\datums\elements\_element.dm"
#include "code\datums\elements\conflict_checking.dm"
+#include "code\datums\elements\footstep.dm"
+#include "code\datums\elements\footstep_override.dm"
#include "code\datums\elements\light_blocking.dm"
#include "code\datums\elements\turf_transparency.dm"
#include "code\datums\game_masters\_common.dm"