Files
Bubberstation/code/game/objects/effects/effect_system/effect_system.dm
Cyberboss f7c9749ca0 Fixes some bad addtimer calls. Adds INVOKE_ASYNC. Replaces addtimer(..., 0) (#23424)
* Fixes some bad addtimers

* Adds INVOKE

* Warning for addtimer

* Working syntax

* Another bad call

* Fixes the addtimer warning

* Add suppress_zero_warning to addtimer

Useful for addtimer that uses vars

* Add INVOKE_AGAIN for when the var is already defined

* Replace addtimer(...,0) with INVOKE((...))

* Much more sensible syntax

* Less overhead, less copypaste

* Rename INVOKE_ASYNC

* Use a macro

* Allman style

* Wait, why make it a datum in the first place?

* Revert the rename

* Rename again, keep line endings

* typo

* More typos

* Untouches Addtimer

* Update callbacks.dm

* Update timer.dm

* Revert allman style

* Revert "Revert allman style"

This reverts commit 47361da15bd04eca138be5f13acdc9dd5ba89331.

* Trying to match that whitespace diff

* Why is this missing?

* I'm not fucking dealing with this!
2017-01-31 09:20:54 +13:00

74 lines
1.8 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 = 0
pass_flags = PASSTABLE | PASSGRILLE
/obj/effect/particle_effect/New()
..()
if(ticker)
cameranet.updateVisibility(src)
/obj/effect/particle_effect/Destroy()
if(ticker)
cameranet.updateVisibility(src)
. = ..()
/datum/effect_system
var/number = 3
var/cardinals = 0
var/turf/location
var/atom/holder
var/effect_type
var/total_effects = 0
/datum/effect_system/Destroy()
holder = null
location = null
return ..()
/datum/effect_system/proc/set_up(n = 3, c = 0, loca)
if(n > 10)
n = 10
number = n
cardinals = c
if(isturf(loca))
location = loca
else
location = get_turf(loca)
/datum/effect_system/proc/attach(atom/atom)
holder = atom
/datum/effect_system/proc/start()
for(var/i in 1 to number)
if(total_effects > 20)
return
INVOKE_ASYNC(src, .proc/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(cardinal)
else
direction = pick(alldirs)
var/steps_amt = pick(1,2,3)
for(var/j in 1 to steps_amt)
sleep(5)
step(E,direction)
addtimer(CALLBACK(src, .proc/decrement_total_effect), 20)
/datum/effect_system/proc/decrement_total_effect()
total_effects--