DCS Update + Footstep element (#17076)

* DCS Update + Footstep element

* Steppy

* Revert "Steppy"

This reverts commit fab0590fb7.

* Reapply "Steppy"

This reverts commit 1f7ad8f8f7.

* Ough

* Oops! Wrong map.

* lil stuff

* Update

* Only loud

* Missed one

* NO MORE SILENT

* ...parenthesis.
This commit is contained in:
Guti
2025-02-08 18:19:59 -05:00
committed by GitHub
parent d1b65c3635
commit a081d48590
79 changed files with 1695 additions and 579 deletions
+43 -7
View File
@@ -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))