mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-20 12:35:33 +01:00
[MIRROR] refactors is_flying_animal into simple_flight element (#5523)
* refactors is_flying_animal into simple_flight element (#58914) * refactors is_flying_animal into simple_flight element * Update bumbles.dm Co-authored-by: tralezab <40974010+tralezab@users.noreply.github.com> Co-authored-by: Gandalf <jzo123@hotmail.com>
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
/**
|
||||
* # 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
|
||||
|
||||
/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)
|
||||
Reference in New Issue
Block a user