Files
Alexis 21b4095dfd [MDB IGNORE] [IDB IGNORE] Upstream Sync - 04/17/2026 (#5453)
Upstream 04/17/2026

fixes https://github.com/Bubberstation/Bubberstation/issues/5549

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: tgstation-ci[bot] <179393467+tgstation-ci[bot]@users.noreply.github.com>
Co-authored-by: ArcaneMusic <41715314+ArcaneMusic@users.noreply.github.com>
Co-authored-by: MrMelbert <51863163+MrMelbert@users.noreply.github.com>
Co-authored-by: Rhials <28870487+Rhials@users.noreply.github.com>
Co-authored-by: rageguy505 <54517726+rageguy505@users.noreply.github.com>
Co-authored-by: LemonInTheDark <58055496+LemonInTheDark@users.noreply.github.com>
Co-authored-by: John Willard <53777086+JohnFulpWillard@users.noreply.github.com>
Co-authored-by: Aliceee2ch <160794176+Aliceee2ch@users.noreply.github.com>
Co-authored-by: Time-Green <7501474+Time-Green@users.noreply.github.com>
Co-authored-by: Tsar-Salat <62388554+Tsar-Salat@users.noreply.github.com>
Co-authored-by: SmArtKar <44720187+SmArtKar@users.noreply.github.com>
Co-authored-by: Maxipat <108554989+Maxipat112@users.noreply.github.com>
Co-authored-by: SyncIt21 <110812394+SyncIt21@users.noreply.github.com>
Co-authored-by: deltanedas <39013340+deltanedas@users.noreply.github.com>
Co-authored-by: SimplyLogan <47579821+loganuk@users.noreply.github.com>
Co-authored-by: loganuk <fakeemail123@aol.com>
Co-authored-by: Leland Kemble <70413276+lelandkemble@users.noreply.github.com>
Co-authored-by: FalloutFalcon <86381784+FalloutFalcon@users.noreply.github.com>
Co-authored-by: Roxy <75404941+TealSeer@users.noreply.github.com>
Co-authored-by: Lucy <lucy@absolucy.moe>
Co-authored-by: siliconOpossum <138069572+siliconOpossum@users.noreply.github.com>
Co-authored-by: Isratosh <Isratosh@hotmail.com>
Co-authored-by: TheRyeGuyWhoWillNowDie <70169560+TheRyeGuyWhoWillNowDie@users.noreply.github.com>
Co-authored-by: Neocloudy <88008002+Neocloudy@users.noreply.github.com>
Co-authored-by: Alexander V. <volas@ya.ru>
Co-authored-by: ElGitificador <168473461+ElGitificador@users.noreply.github.com>
Co-authored-by: Twaticus <46540570+Twaticus@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Bloop <13398309+vinylspiders@users.noreply.github.com>
Co-authored-by: Cameron Lennox <killer65311@gmail.com>
Co-authored-by: Tim <timothymtorres@gmail.com>
Co-authored-by: Iamgoofball <iamgoofball@gmail.com>
Co-authored-by: Layzu666 <121319428+Layzu666@users.noreply.github.com>
Co-authored-by: Arturlang <24881678+Arturlang@users.noreply.github.com>
Co-authored-by: _0Steven <42909981+00-Steven@users.noreply.github.com>
Co-authored-by: mrmanlikesbt <99309552+mrmanlikesbt@users.noreply.github.com>
Co-authored-by: Ben10Omintrix <138636438+Ben10Omintrix@users.noreply.github.com>
Co-authored-by: John F. Kennedy <54908920+MacaroniCritter@users.noreply.github.com>
Co-authored-by: Cursor <102828457+theselfish@users.noreply.github.com>
Co-authored-by: Josh <josh.adam.powell@gmail.com>
Co-authored-by: Josh Powell <josh.powell@softwire.com>
Co-authored-by: Yobrocharlie <Charliemiller5617@gmail.com>
Co-authored-by: Hardly3D <66234359+Hardly3D@users.noreply.github.com>
Co-authored-by: shayoki <96078776+shayoki@users.noreply.github.com>
Co-authored-by: LT3 <83487515+lessthnthree@users.noreply.github.com>
2026-05-16 00:56:00 +02:00

132 lines
4.5 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.
*/
#define PER_SYSTEM_PARTICLE_CAP 20
/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
// Does not contain any behaviors and should not be used by itself
abstract_type = /datum/effect_system
/// Turf on which to spawn the effects
var/turf/location = null
/// Atom that is spawning the particles whose location we're following
var/atom/holder = null
/datum/effect_system/New(turf/location)
. = ..()
src.location = get_turf(location)
/datum/effect_system/Destroy()
holder = null
location = null
return ..()
/// Instruct the effect system to start following an atom. Can be chained into .start()
/datum/effect_system/proc/attach(atom/new_holder)
RETURN_TYPE(/datum/effect_system)
holder = new_holder
return src
/// Start the effect system
/datum/effect_system/proc/start()
return
/// Basic effect system which spawns a certain number of moving effects
/datum/effect_system/basic
/// Total number of particles to spawn
var/amount = 3
/// Should we pick among cardinals or all directions when deciding where the particle should move
var/cardinals_only = FALSE
/// Typepath of the effect to spawn
var/effect_type = null
/// Total amount of effects we currently have active
var/total_effects = 0
/// Should the system delete itself after finishing?
var/autocleanup = FALSE
/// Should the system delete effects that stop moving?
var/delete_on_stop = FALSE
/// How frequently (in deciseconds) should we move our particles?
var/step_delay = 0.5 SECONDS
// Internal use
/// The length of the previous assigned moveloop in deciseconds
var/last_loop_length = 0
/// List of dirs avalible to pick, used to avoid accidential duplicates
var/list/pickable_dirs = list()
/datum/effect_system/basic/New(turf/location, amount = null, cardinals_only = null)
. = ..()
if (!isnull(amount))
src.amount = amount
if (!isnull(cardinals_only))
src.cardinals_only = cardinals_only
/datum/effect_system/basic/start()
if(QDELETED(src))
return
for(var/i in 1 to amount)
if(total_effects > PER_SYSTEM_PARTICLE_CAP)
return
generate_effect()
/// Returns how many steps to attempt to move a generated effect
/datum/effect_system/basic/proc/get_step_count()
return rand(1, 3)
/// Generates a effect for our system to control, returns the generated effect
/datum/effect_system/basic/proc/generate_effect()
if(holder)
location = get_turf(holder)
var/obj/effect/effect = new effect_type(location)
total_effects++
if(!length(pickable_dirs))
if(cardinals_only)
pickable_dirs = GLOB.cardinals.Copy()
else
pickable_dirs = GLOB.alldirs.Copy()
// Try not to reuse dirs if possible to avoid weird stacking
var/direction = pick_n_take(pickable_dirs)
var/step_count = get_step_count()
var/datum/move_loop/loop = GLOB.move_manager.move(effect, direction, step_delay, timeout = step_delay * step_count, priority = MOVEMENT_ABOVE_SPACE_PRIORITY, flags = MOVEMENT_LOOP_START_FAST)
RegisterSignal(loop, COMSIG_MOVELOOP_POSTPROCESS, PROC_REF(post_move))
RegisterSignal(loop, COMSIG_QDELETING, PROC_REF(loop_end))
last_loop_length = loop.lifetime
return effect
/datum/effect_system/basic/proc/post_move(datum/move_loop/source, result, visual_delay)
SIGNAL_HANDLER
if(result == MOVELOOP_FAILURE)
move_failed(source, source.moving)
/// Allows us to hook into being unable to automatically move
/datum/effect_system/basic/proc/move_failed(datum/move_loop/loop, obj/effect/failed)
if(QDELETED(failed) || !delete_on_stop)
return
qdel(failed)
/datum/effect_system/basic/proc/loop_end(datum/move_loop/source)
SIGNAL_HANDLER
total_effects--
if(delete_on_stop && !QDELETED(source.moving))
qdel(source.moving)
if(autocleanup && total_effects == 0)
QDEL_IN(src, 2 SECONDS)
#undef PER_SYSTEM_PARTICLE_CAP