-
Notifications
You must be signed in to change notification settings - Fork 103
/
Copy pathtraits.dm
30 lines (28 loc) · 1.14 KB
/
traits.dm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#define TRAIT_CALLBACK_ADD(target, trait, source) CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(___TraitAdd), ##target, ##trait, ##source)
#define TRAIT_CALLBACK_REMOVE(target, trait, source) CALLBACK(GLOBAL_PROC, GLOBAL_PROC_REF(___TraitRemove), ##target, ##trait, ##source)
///DO NOT USE ___TraitAdd OR ___TraitRemove as a replacement for ADD_TRAIT / REMOVE_TRAIT defines. To be used explicitly for callback.
/proc/___TraitAdd(target,trait,source)
if(!target || !trait || !source)
return
if(islist(target))
for(var/i in target)
if(!isatom(i))
continue
var/atom/the_atom = i
ADD_TRAIT(the_atom,trait,source)
else if(isatom(target))
var/atom/the_atom2 = target
ADD_TRAIT(the_atom2,trait,source)
///DO NOT USE ___TraitAdd OR ___TraitRemove as a replacement for ADD_TRAIT / REMOVE_TRAIT defines. To be used explicitly for callback.
/proc/___TraitRemove(target,trait,source)
if(!target || !trait || !source)
return
if(islist(target))
for(var/i in target)
if(!isatom(i))
continue
var/atom/the_atom = i
REMOVE_TRAIT(the_atom,trait,source)
else if(isatom(target))
var/atom/the_atom2 = target
REMOVE_TRAIT(the_atom2,trait,source)