Files
Bubberstation/code/datums/elements/crackable.dm
SkyratBot b4fd13b16b [MIRROR] Improve the naming of the element argument hash index selector [MDB IGNORE] (#17588)
* Improve the naming of the element argument hash index selector (#71319)

So confusing name

* Improve the naming of the element argument hash index selector

* sr sync

Co-authored-by: oranges <email@oranges.net.nz>
Co-authored-by: tastyfish <crazychris32@gmail.com>
2022-11-21 16:27:40 -05:00

28 lines
1.1 KiB
Plaintext

/// Adds crack overlays to an object when integrity gets low
/datum/element/crackable
element_flags = ELEMENT_BESPOKE
argument_hash_start_idx = 2
var/list/icon/crack_icons
/// The level at which the object starts showing cracks, 1 being at full health and 0.5 being at half health
var/crack_integrity = 1
/datum/element/crackable/Attach(datum/target, icon/crack_icon, list/crack_states, crack_integrity)
. = ..()
if(!isobj(target))
return ELEMENT_INCOMPATIBLE
src.crack_integrity = crack_integrity || src.crack_integrity
if(!crack_icons) // This is the first attachment and we need to do first time setup
crack_icons = list()
for(var/state in crack_states)
for(var/i in 1 to 36)
var/icon/new_crack_icon = icon(crack_icon, state)
new_crack_icon.Turn(i * 10)
crack_icons += new_crack_icon
RegisterSignal(target, COMSIG_ATOM_INTEGRITY_CHANGED, PROC_REF(IntegrityChanged))
/datum/element/crackable/proc/IntegrityChanged(obj/source, old_value, new_value)
SIGNAL_HANDLER
if(new_value >= source.max_integrity * crack_integrity)
return
source.AddComponent(/datum/component/cracked, crack_icons, crack_integrity)