Files
Yogstation/code/game/objects/effects/effect_system/effect_system.dm
John Willard 892cee1705 Adds grep for mapload and var in Args (#19203)
* Adds grep for mapload and var in Args

* vars in args

* some more

* stuff

* Update shuttle_creator.dm

* Update __techweb_helpers.dm

* fix

* Update discoball.dm

* Update check_grep.sh

* Update check_grep.sh

* Update check_grep.sh

* Update check_grep.sh

* I'll finish this later

* datum and lateinit maploads

* componentinit stuff

* mapload fixes

* why isnt CI catching these major issues

* MERGE CONFLICT FUCKED MY PR OVER

* Update check_grep.sh

* Update food.dm
2023-06-15 12:04:36 -05:00

77 lines
2.1 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
/obj/effect/particle_effect/Initialize(mapload)
. = ..()
GLOB.cameranet.updateVisibility(src)
/obj/effect/particle_effect/Destroy()
GLOB.cameranet.updateVisibility(src)
return ..()
/obj/effect/particle_effect/newtonian_move() // Prevents effects from getting registered for SSspacedrift
return TRUE
/datum/effect_system
var/number = 3
var/cardinals = 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 = 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
INVOKE_ASYNC(src, PROC_REF(generate_effect))
/datum/effect_system/proc/generate_effect()
if(holder)
location = get_turf(holder)
var/obj/effect/E = new effect_type(location)
total_effects++
var/direction
if(cardinals)
direction = pick(GLOB.cardinals)
else
direction = pick(GLOB.alldirs)
var/steps_amt = pick(1,2,3)
for(var/j in 1 to steps_amt)
sleep(0.5 SECONDS)
step(E,direction)
if(!QDELETED(src))
addtimer(CALLBACK(src, PROC_REF(decrement_total_effect)), 20)
/datum/effect_system/proc/decrement_total_effect()
total_effects--
if(autocleanup && total_effects <= 0)
qdel(src)