Files
Bubberstation/code/datums/components/burning.dm
ChungusGamer666 b093b12e03 Burning and acid components fixes and improvements (#74803)
## About The Pull Request

Generally cleans up code on both components.
Moves burn proc back to /obj level, I'm not sure why I moved it to /atom
level, it was unnecessary.
Acid component generalized so it can be used on any atom that uses
atom_integrity.
Fixes a bug where objects that stopped burning didn't update their burn
overlay properly due to bad removal logic and leftover code.
Standardizes examine messages on burning items by just slapping an
examine signal registration on the component.
Adds fire particles to items thanks to Lemon's PR:
https://github.com/tgstation/tgstation/pull/74524

## Why It's Good For The Game

Particles look cool

![image](https://user-images.githubusercontent.com/82850673/232605615-6e3bc804-bc68-4f09-8615-5e5946acbc10.png)

![image](https://user-images.githubusercontent.com/82850673/232664951-e0474331-495f-4717-8b0f-a647aedc4d9f.png)

Bugfixes are good
Code improvements are good

## Changelog

🆑
add: Burning items now get (small) smoke particles. Sick.
fix: Burning objects now clear their burning overlay properly.
qol: Examining burning objects will always tell you that they are
burning.
/🆑

---------

Co-authored-by: san7890 <the@san7890.com>
2023-04-23 17:50:58 -06:00

82 lines
3.2 KiB
Plaintext

GLOBAL_DATUM_INIT(fire_overlay, /mutable_appearance, mutable_appearance('icons/effects/fire.dmi', "fire", appearance_flags = RESET_COLOR))
/**
* Component representing an atom being on fire.
* Should not be used on mobs, they use the fire stacks status effects.
* Can only be used on atoms that use the integrity system.
*/
/datum/component/burning
/// Fire overlay appearance we apply
var/fire_overlay
/// Particle holder for fire particles, if any
var/obj/effect/abstract/particle_holder/particle_effect
/datum/component/burning/Initialize(fire_overlay = GLOB.fire_overlay, fire_particles = /particles/smoke/burning)
if(!isatom(parent))
return COMPONENT_INCOMPATIBLE
var/atom/atom_parent = parent
if(!atom_parent.uses_integrity)
stack_trace("Tried to add /datum/component/burning to an atom ([atom_parent.type]) that does not use atom_integrity!")
return COMPONENT_INCOMPATIBLE
// only flammable atoms should have this component, but it's not really an error if we try to apply this to a non flammable one
if(!(atom_parent.resistance_flags & FLAMMABLE) || (atom_parent.resistance_flags & FIRE_PROOF))
qdel(src)
return
src.fire_overlay = fire_overlay
if(fire_particles)
// burning particles look pretty bad when they stack on mobs, so that behavior is not wanted for items
particle_effect = new(atom_parent, fire_particles, isitem(atom_parent) ? NONE : PARTICLE_ATTACH_MOB)
START_PROCESSING(SSburning, src)
/datum/component/burning/Destroy(force, silent)
STOP_PROCESSING(SSburning, src)
if(particle_effect)
QDEL_NULL(particle_effect)
return ..()
/datum/component/burning/RegisterWithParent()
RegisterSignal(parent, COMSIG_PARENT_EXAMINE, PROC_REF(on_examine))
RegisterSignal(parent, COMSIG_ATOM_UPDATE_OVERLAYS, PROC_REF(on_update_overlays))
RegisterSignal(parent, COMSIG_ATOM_EXTINGUISH, PROC_REF(on_extinguish))
var/atom/atom_parent = parent
atom_parent.resistance_flags |= ON_FIRE
atom_parent.update_appearance()
/datum/component/burning/UnregisterFromParent()
UnregisterSignal(parent, list(COMSIG_PARENT_EXAMINE, COMSIG_ATOM_UPDATE_OVERLAYS, COMSIG_ATOM_EXTINGUISH))
var/atom/atom_parent = parent
if(!QDELETED(atom_parent))
atom_parent.resistance_flags &= ~ON_FIRE
atom_parent.update_appearance()
/datum/component/burning/process(seconds_per_tick)
var/atom/atom_parent = parent
// Check if the parent somehow became fireproof
if(atom_parent.resistance_flags & FIRE_PROOF)
atom_parent.extinguish()
return
atom_parent.take_damage(10 * seconds_per_tick, BURN, FIRE, FALSE)
/// Alerts any examiners that the parent is on fire (even though it should be rather obvious)
/datum/component/burning/proc/on_examine(atom/source, mob/user, list/examine_list)
SIGNAL_HANDLER
examine_list += span_danger("[source.p_theyre(TRUE)] burning!")
/// Maintains the burning overlay on the parent atom
/datum/component/burning/proc/on_update_overlays(atom/source, list/overlays)
SIGNAL_HANDLER
//most likely means the component is being removed
if(!(source.resistance_flags & ON_FIRE))
return
if(fire_overlay)
overlays += fire_overlay
/// Deletes the component when the atom gets extinguished
/datum/component/burning/proc/on_extinguish(atom/source, list/overlays)
SIGNAL_HANDLER
qdel(src)