Files
Bubberstation/code/game/objects/effects/effect_system/effects_water.dm
T
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

92 lines
3.3 KiB
Plaintext

//WATER EFFECTS
/obj/effect/particle_effect/water
name = "water"
icon_state = "extinguish"
pass_flags = PASSTABLE | PASSMACHINE | PASSSTRUCTURE | PASSGRILLE | PASSBLOB | PASSVEHICLE
mouse_opacity = MOUSE_OPACITY_TRANSPARENT
/// Amount of turfs we pass before deleting ourselves
var/life = 15
/obj/effect/particle_effect/water/Initialize(mapload)
. = ..()
QDEL_IN(src, 7 SECONDS)
/obj/effect/particle_effect/water/Move(turf/newloc)
life -= 1
if (life <= 0)
qdel(src)
return FALSE
return ..()
/obj/effect/particle_effect/water/Bump(atom/A)
if(reagents)
reagents.expose(A)
A.reagents?.expose_temperature(reagents.chem_temp)
return ..()
///Extinguisher snowflake
/obj/effect/particle_effect/water/extinguisher
/obj/effect/particle_effect/water/extinguisher/Move()
. = ..()
if(!reagents)
return
reagents.expose(get_turf(src))
for(var/atom/thing as anything in get_turf(src))
reagents.expose(thing)
/// Starts the effect moving at a target with a delay in deciseconds, and a lifetime in moves
/// Returns the created loop
/obj/effect/particle_effect/water/extinguisher/proc/move_at(atom/target, delay, lifetime)
var/datum/move_loop/loop = GLOB.move_manager.move_towards_legacy(src, target, delay, timeout = delay * lifetime, flags = MOVEMENT_LOOP_START_FAST, priority = MOVEMENT_ABOVE_SPACE_PRIORITY)
RegisterSignal(loop, COMSIG_MOVELOOP_POSTPROCESS, PROC_REF(post_forcemove))
RegisterSignal(loop, COMSIG_QDELETING, PROC_REF(movement_stopped))
return loop
/obj/effect/particle_effect/water/extinguisher/proc/post_forcemove(datum/move_loop/source, success)
SIGNAL_HANDLER
if(!success)
end_life(source)
/obj/effect/particle_effect/water/extinguisher/proc/movement_stopped(datum/move_loop/source)
SIGNAL_HANDLER
if(!QDELETED(src))
end_life(source)
/obj/effect/particle_effect/water/extinguisher/proc/end_life(datum/move_loop/engine)
QDEL_IN(src, engine.delay) //Gotta let it stop drifting
animate(src, alpha = 0, time = engine.delay)
/obj/effect/particle_effect/water/extinguisher/stomach_acid
name = "acid"
icon_state = "xenobarf"
// Stomach acid doesn't use legacy because it's not "targeted", and we instead want the circular sorta look
/obj/effect/particle_effect/water/extinguisher/stomach_acid/move_at(atom/target, delay, lifetime)
var/datum/move_loop/loop = GLOB.move_manager.move_towards(src, target, delay, timeout = delay * lifetime, flags = MOVEMENT_LOOP_START_FAST, priority = MOVEMENT_ABOVE_SPACE_PRIORITY)
RegisterSignal(loop, COMSIG_MOVELOOP_POSTPROCESS, PROC_REF(post_forcemove))
RegisterSignal(loop, COMSIG_QDELETING, PROC_REF(movement_stopped))
return loop
/////////////////////////////////////////////
// GENERIC STEAM SPREAD SYSTEM
// Usage: set_up(number of bits of steam, use North/South/East/West only, spawn location)
// The attach(atom/atom) proc is optional, and can be called to attach the effect
// to something, like a smoking beaker, so then you can just call start() and the steam
// will always spawn at the items location, even if it's moved.
/////////////////////////////////////////////
/obj/effect/particle_effect/steam
name = "steam"
icon_state = "extinguish"
density = FALSE
/obj/effect/particle_effect/steam/Initialize(mapload)
. = ..()
QDEL_IN(src, 2 SECONDS)
/datum/effect_system/basic/steam_spread
effect_type = /obj/effect/particle_effect/steam