Partial sparks boilerplate reduction (#26081)

* Partial sparks boilerplate reduction

- Lots of obects are making `/datum/effect_system/spark_spread`, setting
them up, firing them, and then not qdeling them afterwards.
- Makes a `do_sparks` global proc that takes the same arguments as `set_up`
and then calls `start` and then `qdel`
- Switches a bunch of things to use this proc
- Makes emitters keep their own spark_spread datum around, since they
spark so damn much.
- Also makes some things use timers and ports some things to Initialize.

* Compilation
This commit is contained in:
coiax
2017-04-12 19:59:45 +02:00
committed by AnturK
parent a1403bc424
commit de35ec5f67
21 changed files with 72 additions and 114 deletions
@@ -123,9 +123,7 @@
if(hasShocked)
return 0
hasShocked = 1
var/datum/effect_system/spark_spread/s = new /datum/effect_system/spark_spread
s.set_up(5, 1, AM.loc)
s.start()
do_sparks(5, TRUE, AM.loc)
var/atom/target = get_edge_target_turf(AM, get_dir(src, get_step_away(AM, src)))
AM.throw_at(target, 200, 4)
addtimer(CALLBACK(src, .proc/clear_shock), 5)
+7 -3
View File
@@ -28,6 +28,8 @@
var/projectile_sound = 'sound/weapons/emitter.ogg'
var/datum/effect_system/spark_spread/sparks
/obj/machinery/power/emitter/New()
..()
var/obj/item/weapon/circuitboard/machine/B = new /obj/item/weapon/circuitboard/machine/emitter(null)
@@ -87,11 +89,15 @@
if(state == 2 && anchored)
connect_to_network()
sparks = new
sparks.set_up(5, TRUE, src)
/obj/machinery/power/emitter/Destroy()
if(SSticker && SSticker.current_state == GAME_STATE_PLAYING)
message_admins("Emitter deleted at ([x],[y],[z] - <A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[x];Y=[y];Z=[z]'>JMP</a>)",0,1)
log_game("Emitter deleted at ([x],[y],[z])")
investigate_log("<font color='red'>deleted</font> at ([x],[y],[z]) at [get_area(src)]","singulo")
QDEL_NULL(sparks)
return ..()
/obj/machinery/power/emitter/update_icon()
@@ -198,9 +204,7 @@
A.setDir(src.dir)
playsound(src.loc, projectile_sound, 25, 1)
if(prob(35))
var/datum/effect_system/spark_spread/s = new /datum/effect_system/spark_spread
s.set_up(5, 1, src)
s.start()
sparks.start()
switch(dir)
if(NORTH)
A.yo = 20