Implements shared particle holders, re-adds slimed status particles using the new system (#87892)

## About The Pull Request

Partial revert of #86701
Implements a shared holder particle system, somewhat inspired by
https://github.com/Baystation12/Baystation12/pull/34014 (thanks Kapu).
Atoms can be assigned "shared" particles via add_shared_particles, with
an optional "alternate" key passed as a second arg if you're planning to
edit the returned particle holder (for example, color it like slimed
status does). Removing is done via remove_shared_particles with an
option to delete the shared holder if nothing is using it anymore (on by
default). This system should be prioritized over normal particle holders
when a lot of entities would be using a certain particle effect (like
fires) as it conserves a lot of clientside performance.

Burning, acid, decaying, firestacks and slimed status now use this
system which should help with clientside performance and amount of atoms
created/destroyed.

## Why It's Good For The Game

Less clientside lag.

## Changelog
🆑
refactor: Firestacks, burning/acid/decaying effects and (brought back
after being temporarily removed) slimed status effects now use a new
"shared" particles system, which should considerably improve client
performance when encountering a lot of burning/slimed entities.
/🆑

---------

Co-authored-by: Ghom <42542238+Ghommie@users.noreply.github.com>
This commit is contained in:
SmArtKar
2024-11-20 13:46:00 +01:00
committed by GitHub
co-authored by Ghom
parent 27b5f28e54
commit bcb5c47571
10 changed files with 170 additions and 47 deletions
+14 -4
View File
@@ -8,8 +8,10 @@ GLOBAL_DATUM_INIT(fire_overlay, /mutable_appearance, mutable_appearance('icons/e
/datum/component/burning
/// Fire overlay appearance we apply
var/fire_overlay
/// Particle holder for fire particles, if any
/// Particle holder for fire particles, if any. Still utilized over shared holders because they're movable-only
var/obj/effect/abstract/particle_holder/particle_effect
/// Particle type we're using for cleaning up our shared holder
var/particle_type
/datum/component/burning/Initialize(fire_overlay = GLOB.fire_overlay, fire_particles = /particles/smoke/burning)
if(!isatom(parent))
@@ -25,9 +27,14 @@ GLOBAL_DATUM_INIT(fire_overlay, /mutable_appearance, mutable_appearance('icons/e
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)
if (fire_particles)
if(ismovable(parent))
var/atom/movable/movable_parent = parent
// burning particles look pretty bad when they stack on mobs, so that behavior is not wanted for items
movable_parent.add_shared_particles(fire_particles, "[fire_particles]_[isitem(parent)]", isitem(parent) ? NONE : PARTICLE_ATTACH_MOB)
particle_type = fire_particles
else
particle_effect = new(atom_parent, fire_particles)
START_PROCESSING(SSburning, src)
/datum/component/burning/Destroy(force)
@@ -35,6 +42,9 @@ GLOBAL_DATUM_INIT(fire_overlay, /mutable_appearance, mutable_appearance('icons/e
fire_overlay = null
if(particle_effect)
QDEL_NULL(particle_effect)
if (ismovable(parent) && particle_type)
var/atom/movable/movable_parent = parent
movable_parent.remove_shared_particles("[particle_type]_[isitem(parent)]")
return ..()
/datum/component/burning/RegisterWithParent()