Makes every single shot not create ~40 timers but one

This commit is contained in:
Heroman3003
2019-09-26 09:04:22 +10:00
parent 7940fef4ba
commit 86274e0bc6
2 changed files with 17 additions and 10 deletions
+6 -6
View File
@@ -44,6 +44,7 @@
var/tracer_type
var/muzzle_type
var/impact_type
var/datum/beam_components_cache/beam_components
//Fancy hitscan lighting effects!
var/hitscan_light_intensity = 1.5
@@ -432,7 +433,6 @@
if(hitscan)
finalize_hitscan_and_generate_tracers()
STOP_PROCESSING(SSprojectiles, src)
cleanup_beam_segments()
qdel(trajectory)
return ..()
@@ -456,10 +456,11 @@
/obj/item/projectile/proc/generate_hitscan_tracers(cleanup = TRUE, duration = 5, impacting = TRUE)
if(!length(beam_segments))
return
beam_components = new
if(tracer_type)
var/tempref = "\ref[src]"
for(var/datum/point/p in beam_segments)
generate_tracer_between_points(p, beam_segments[p], tracer_type, color, duration, hitscan_light_range, hitscan_light_color_override, hitscan_light_intensity, tempref)
generate_tracer_between_points(p, beam_segments[p], beam_components, tracer_type, color, duration, hitscan_light_range, hitscan_light_color_override, hitscan_light_intensity, tempref)
if(muzzle_type && duration > 0)
var/datum/point/p = beam_segments[1]
var/atom/movable/thing = new muzzle_type
@@ -469,7 +470,7 @@
thing.transform = M
thing.color = color
thing.set_light(muzzle_flash_range, muzzle_flash_intensity, muzzle_flash_color_override? muzzle_flash_color_override : color)
QDEL_IN(thing, duration)
beam_components.beam_components += thing
if(impacting && impact_type && duration > 0)
var/datum/point/p = beam_segments[beam_segments[beam_segments.len]]
var/atom/movable/thing = new impact_type
@@ -479,9 +480,8 @@
thing.transform = M
thing.color = color
thing.set_light(impact_light_range, impact_light_intensity, impact_light_color_override? impact_light_color_override : color)
QDEL_IN(thing, duration)
if(cleanup)
cleanup_beam_segments()
beam_components.beam_components += thing
QDEL_IN(beam_components, duration)
//Returns true if the target atom is on our current turf and above the right layer
//If direct target is true it's the originally clicked target.