Files
SmArtKarandGitHub f58b8511f0 Refactors effect_system (#94999)
## About The Pull Request

This PR refactors ``effect_system``s to be a bit easier to use by
getting rid of ``set_up``, allowing ``attach()`` to be chained into
``start()`` and refactoring most direct system usages in our code to use
helper procs.

``set_up`` was unnecessary and only existed to allow ``New``'s behavior
to be fully overriden, which is not required if we split
sparks/lightning/steam into a new ``/datum/effect_system/basic`` subtype
which houses the effect spreading behavior. This allows us to roll all
logic from ``set_up`` into ``New`` and cut down on code complexity.
Chaining setup as ``system.attach(src).start()`` also helps a bit in
case no helper method exists

I've added ``do_chem_smoke`` and ``do_foam`` helpers, which respectively
allow chemical smoke or foam to be spawned easily without having to
manually create effect datums and reagent holders.

Also turns out we've had some nonfunctional effect systems which either
never set themselves up, or never started, so I fixed those while I was
at it (mostly by moving them to aforementioned helper procs)

## Why It's Good For The Game

Cleaner code, makes it significantly easier for users to work with. Also
most of our effect system usage was copypasta which was passing booleans
as numbers, while perfectly fine helper procs existed in our code.

## Changelog
🆑
refactor: Refactored sparks, foam, smoke, and other miscellaneous effect
systems.
refactor: Vapes now have consistent rigging with cigs using the new
system.
fix: Fixed some effects never working.
/🆑
2026-02-03 22:23:09 -05:00

59 lines
1.7 KiB
Plaintext

/obj/effect/particle_effect/expl_particles
name = "fire"
icon_state = "explosion_particle"
opacity = TRUE
anchored = TRUE
/obj/effect/particle_effect/expl_particles/Initialize(mapload)
..()
return INITIALIZE_HINT_LATELOAD
/obj/effect/particle_effect/expl_particles/LateInitialize()
var/step_amt = pick(25;1, 50;2, 100;3, 200;4)
var/datum/move_loop/loop = GLOB.move_manager.move(src, pick(GLOB.alldirs), 1, timeout = step_amt, priority = MOVEMENT_ABOVE_SPACE_PRIORITY)
RegisterSignal(loop, COMSIG_QDELETING, PROC_REF(end_particle))
/obj/effect/particle_effect/expl_particles/proc/end_particle(datum/source)
SIGNAL_HANDLER
if (!QDELETED(src))
qdel(src)
/datum/effect_system/basic/expl_particles
amount = 10
/datum/effect_system/basic/expl_particles/generate_effect()
new /obj/effect/particle_effect/expl_particles(location)
/obj/effect/explosion
name = "fire"
icon = 'icons/effects/96x96.dmi'
icon_state = "explosion"
opacity = TRUE
anchored = TRUE
layer = ABOVE_ALL_MOB_LAYER
plane = ABOVE_GAME_PLANE
mouse_opacity = MOUSE_OPACITY_TRANSPARENT
pixel_x = -32
pixel_y = -32
/obj/effect/explosion/Initialize(mapload)
. = ..()
QDEL_IN(src, 10)
/datum/effect_system/explosion
/datum/effect_system/explosion/start()
new /obj/effect/explosion(location)
var/datum/effect_system/basic/expl_particles/boom_particles = new(location)
boom_particles.start()
/datum/effect_system/explosion/smoke
/datum/effect_system/explosion/smoke/proc/create_smoke()
var/datum/effect_system/fluid_spread/smoke/smoke_system = new(location, range = 2)
smoke_system.attach(holder).start()
/datum/effect_system/explosion/smoke/start()
..()
addtimer(CALLBACK(src, PROC_REF(create_smoke)), 0.5 SECONDS)