Files
Bubberstation/code/datums/components/damage_buffs.dm
SkyratBot 88f8ef7adc [MIRROR] Netherworld Mobs Refractor [MDB IGNORE] (#19181)
* Netherworld Mobs Refractor

* Update statues.dm

* Update tgstation.dme

* w

---------

Co-authored-by: Comxy <tijntensen@gmail.com>
Co-authored-by: Gandalf <9026500+Gandalf2k15@users.noreply.github.com>
2023-03-10 02:44:53 +00:00

26 lines
856 B
Plaintext

/**
* Attached to a mob so it can change or do actions based on the fact it got attacked.
*/
/datum/component/damage_buffs
/// Callback to a mob for health changes
var/datum/callback/health_callback
/datum/component/damage_buffs/Initialize(datum/callback/health_callback)
if(!ismob(parent))
return ELEMENT_INCOMPATIBLE
src.health_callback = health_callback
parent.AddElement(/datum/element/relay_attackers)
/datum/component/damage_buffs/RegisterWithParent()
RegisterSignal(parent, COMSIG_ATOM_WAS_ATTACKED, PROC_REF(on_attacked))
/datum/component/damage_buffs/UnregisterFromParent()
UnregisterSignal(parent, COMSIG_ATOM_WAS_ATTACKED)
/// Add an attacking atom to a blackboard list of things which attacked us
/datum/component/damage_buffs/proc/on_attacked(mob/victim, atom/attacker)
SIGNAL_HANDLER
health_callback?.InvokeAsync(attacker)