mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-15 04:01:41 +00:00
* fixes simple_flying element missing ELEMENT_DETACH ! (#59096) * fixes simple_flying element missing ELEMENT_DETACH Co-authored-by: tralezab <40974010+tralezab@users.noreply.github.com>
30 lines
1.0 KiB
Plaintext
30 lines
1.0 KiB
Plaintext
/**
|
|
* # simple flying element!
|
|
*
|
|
* Non bespoke element (1 in existence) that makes animals fly while living and... not while dead!
|
|
* Note: works for carbons and above, but please do something better. humans have wings got dangit!
|
|
*/
|
|
/datum/element/simple_flying
|
|
element_flags = ELEMENT_DETACH
|
|
|
|
/datum/element/simple_flying/Attach(datum/target)
|
|
. = ..()
|
|
if(!isliving(target))
|
|
return ELEMENT_INCOMPATIBLE
|
|
var/mob/living/valid_target = target
|
|
on_stat_change(valid_target, new_stat = valid_target.stat) //immediately try adding flight if they're conscious
|
|
RegisterSignal(target, COMSIG_MOB_STATCHANGE, .proc/on_stat_change)
|
|
|
|
/datum/element/simple_flying/Detach(datum/target)
|
|
. = ..()
|
|
UnregisterSignal(target, COMSIG_MOB_STATCHANGE)
|
|
|
|
///signal called by the stat of the target changing
|
|
/datum/element/simple_flying/proc/on_stat_change(mob/living/simple_animal/target, new_stat)
|
|
SIGNAL_HANDLER
|
|
|
|
if(new_stat == CONSCIOUS)
|
|
ADD_TRAIT(target, TRAIT_MOVE_FLYING, ROUNDSTART_TRAIT)
|
|
else
|
|
REMOVE_TRAIT(target, TRAIT_MOVE_FLYING, ROUNDSTART_TRAIT)
|