Files
Bubberstation/code/datums/elements/crackable.dm
Emmett Gaines 67c89fa1ab Greyscale Mat Datum Stationary Smooth Tanks (#59556)
Stationary gas tanks have been in a terrible place for a long time, this addresses some of the issues with a more balance focused change coming in a second mapping pr after this one.

Stationary gas tanks have been made constructable and act similarly to canisters in that they can be damaged, repaired, and over-pressurized to explode. Additionally, they can be made with any rigid material and their stats depend on that material. A glass tank is going to have far less pressure capability than one made of plasteel.

In terms of gameplay there are two main differences now: Adjacent stationary tanks will merge together both graphically and with their internal storage. Any port on any of the tanks can access this shared storage. Also stationary tanks no longer magically have many times the volume for gas as the tile it's in, instead they have a pressure cap and a normal amount of volume.

Of interest to coders this pr also adds a generic grouping datum that acts similar to how pipe networks work. It maintains a listing of all adjacent objects whose type falls within a specified filter. In this case it's used for the gas tanks to know of every other tank in the group. I'll be looking into spreading it's usage elsewhere where this can replace existing one off systems.

Some (de)construction:
First a glass tank is constructed which is then immediately damaged by the high pressure in the gas storage that is now shared. After repairing it for a moment another metal tank is built.
2021-06-26 19:26:33 -07:00

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_OBJ_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)