Files
Bubberstation/code/game/objects/effects/effect_system/effect_system.dm
T
MrMelbert 5146cfd403 Moves camera update handling to background subsystem, (maybe) fixing lag (#92208)
## About The Pull Request

When a camera update is triggered, it is instead added to a queue on a
background subsystem

An AI entering a camera chunk which is queued to update will force the
update immediately (bypassing the queue)

While the root problem of this is, ultimately, not addressed...

<img width="554" height="58"
alt="467828777-eff3f0e5-49d6-4997-b4d7-05eff6432155"
src="https://github.com/user-attachments/assets/c2d6a5f5-d958-463e-959f-116bd0dab475"
/>

...the change will ultimately prevent update spam from consuming all of
the server's resources - instead allocating updates to the backburner in
times of high server stress (or on multi-z maps)

## Changelog

🆑 Melbert
refactor: Refactored the way camera updates are handled to hopefully
reduce some lag. Report any oddities
/🆑
2025-11-08 01:43:48 +01:00

71 lines
2.2 KiB
Plaintext

/* This is an attempt to make some easily reusable "particle" type effect, to stop the code
constantly having to be rewritten. An item like the jetpack that uses the ion_trail_follow system, just has one
defined, then set up when it is created with New(). Then this same system can just be reused each time
it needs to create more trails.A beaker could have a steam_trail_follow system set up, then the steam
would spawn and follow the beaker, even if it is carried or thrown.
*/
/obj/effect/particle_effect
name = "particle effect"
mouse_opacity = MOUSE_OPACITY_TRANSPARENT
pass_flags = PASSTABLE | PASSGRILLE
anchored = TRUE
// Prevents effects from getting registered for SSnewtonian_movement
/obj/effect/particle_effect/newtonian_move(inertia_angle, instant = FALSE, start_delay = 0, drift_force = 0, controlled_cap = null)
return TRUE
/datum/effect_system
var/number = 3
var/cardinals_only = FALSE
var/turf/location
var/atom/holder
var/effect_type
var/total_effects = 0
var/autocleanup = FALSE //will delete itself after use
/datum/effect_system/Destroy()
holder = null
location = null
return ..()
/datum/effect_system/proc/set_up(number = 3, cardinals_only = FALSE, location)
src.number = min(number, 10)
src.cardinals_only = cardinals_only
src.location = get_turf(location)
/datum/effect_system/proc/attach(atom/atom)
holder = atom
/datum/effect_system/proc/start()
if(QDELETED(src))
return
for(var/i in 1 to number)
if(total_effects > 20)
return
generate_effect()
/datum/effect_system/proc/generate_effect()
if(holder)
location = get_turf(holder)
var/obj/effect/effect = new effect_type(location)
total_effects++
var/direction
if(cardinals_only)
direction = pick(GLOB.cardinals)
else
direction = pick(GLOB.alldirs)
var/step_amt = pick(1,2,3)
var/step_delay = 5
var/datum/move_loop/loop = GLOB.move_manager.move(effect, direction, step_delay, timeout = step_delay * step_amt, priority = MOVEMENT_ABOVE_SPACE_PRIORITY)
RegisterSignal(loop, COMSIG_QDELETING, PROC_REF(decrement_total_effect))
/datum/effect_system/proc/decrement_total_effect(datum/source)
SIGNAL_HANDLER
total_effects--
if(!autocleanup || total_effects > 0)
return
QDEL_IN(src, 2 SECONDS)