diff --git a/code/__DEFINES/components.dm b/code/__DEFINES/components.dm index a9daedf4fd..81b397bd6f 100644 --- a/code/__DEFINES/components.dm +++ b/code/__DEFINES/components.dm @@ -43,6 +43,10 @@ #define COMSIG_PARENT_PREQDELETED "parent_preqdeleted" //before a datum's Destroy() is called: (force), returning a nonzero value will cancel the qdel operation #define COMSIG_PARENT_QDELETING "parent_qdeleting" //just before a datum's Destroy() is called: (force), at this point none of the other components chose to interrupt qdel and Destroy will be called +/// Trait signals +#define COMPONENT_ADD_TRAIT (1<<0) +#define COMPONENT_REMOVE_TRAIT (1<<1) + // /atom signals #define COMSIG_PARENT_ATTACKBY "atom_attackby" //from base of atom/attackby(): (/obj/item, /mob/living, params) #define COMPONENT_NO_AFTERATTACK 1 //Return this in response if you don't want afterattack to be called diff --git a/code/__DEFINES/traits.dm b/code/__DEFINES/traits.dm index e62dbce38b..4059b7d0ff 100644 --- a/code/__DEFINES/traits.dm +++ b/code/__DEFINES/traits.dm @@ -1,3 +1,5 @@ +#define SIGNAL_TRAIT(trait_ref) "trait [trait_ref]" + // trait accessor defines #define ADD_TRAIT(target, trait, source) \ do { \ @@ -6,12 +8,14 @@ target.status_traits = list(); \ _L = target.status_traits; \ _L[trait] = list(source); \ + SEND_SIGNAL(target, SIGNAL_TRAIT(trait), COMPONENT_ADD_TRAIT); \ } else { \ _L = target.status_traits; \ if (_L[trait]) { \ _L[trait] |= list(source); \ } else { \ _L[trait] = list(source); \ + SEND_SIGNAL(target, SIGNAL_TRAIT(trait), COMPONENT_ADD_TRAIT); \ } \ } \ } while (0) @@ -32,6 +36,7 @@ };\ if (!length(_L[trait])) { \ _L -= trait \ + SEND_SIGNAL(target, SIGNAL_TRAIT(trait), COMPONENT_REMOVE_TRAIT); \ }; \ if (!length(_L)) { \ target.status_traits = null \ @@ -47,6 +52,7 @@ _L[_T] &= _S;\ if (!length(_L[_T])) { \ _L -= _T } \ + SEND_SIGNAL(target, SIGNAL_TRAIT(trait), COMPONENT_REMOVE_TRAIT); \ };\ if (!length(_L)) { \ target.status_traits = null\