mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-29 02:51:41 +00:00
* moves obj_integrity and associated procs to the atom level * Feex good * Whoops forgot the maps Co-authored-by: Kylerace <kylerlumpkin1@gmail.com> Co-authored-by: GoldenAlpharex <jerego1234@hotmail.com> Co-authored-by: Gandalf <jzo123@hotmail.com>
28 lines
1.1 KiB
Plaintext
28 lines
1.1 KiB
Plaintext
/// Adds crack overlays to an object when integrity gets low
|
|
/datum/element/crackable
|
|
element_flags = ELEMENT_BESPOKE | ELEMENT_DETACH
|
|
id_arg_index = 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/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)
|