Revert "Optimized the code regarding the beam projectiles leaving a fleeting beam behind them, however the count of deletions is still quite high despite this. 30-50 deletions per second."

This reverts commit 45c8a37bd1.
This commit is contained in:
Albert Iordache
2012-07-22 23:35:38 +03:00
parent ac4b8d076a
commit 188e7e3a2a

View File

@@ -1,13 +1,3 @@
var/list/beam_master = list()
//Use: Caches beam state images and holds turfs that had these images overlaid.
//Structure:
//beam_master
// icon_states/dirs of beams
// image for that beam
// references for fired beams
// icon_states/dirs for each placed beam image
// turfs that have that icon_state/dir
/obj/item/projectile/beam
name = "laser"
icon_state = "laser"
@@ -17,63 +7,46 @@ var/list/beam_master = list()
flag = "laser"
eyeblur = 4
var/frequency = 1
var/ID = 0
var/main = 0
fired()
var/reference = "\ref[src]" //So we do not have to recalculate it a ton
var/first = 1 //So we don't make the overlay in the same tile as the firer
main = 1
ID = rand(0,1000)
var/first = 1
var/obj/effect/effect/laserdealer/lasor = new /obj/effect/effect/laserdealer(null)
spawn(0)
while(!bumped) //Move until we hit something
step_towards(src, current) //Move~
lasor.setup(ID)
spawn(0)
while(!bumped)
step_towards(src, current)
for(var/mob/living/M in loc)
Bump(M) //Bump anyone we touch
if((!( current ) || loc == current)) //If we pass our target
Bump(M)
if((!( current ) || loc == current))
current = locate(min(max(x + xo, 1), world.maxx), min(max(y + yo, 1), world.maxy), z)
if((x == 1 || x == world.maxx || y == 1 || y == world.maxy))
del(src) //Delete if it passes the world edge
del(src)
return
if(!first) //Add the overlay as we pass over tiles
var/target_dir = get_dir(src, current) //So we don't call this too much
//If the icon has not been added yet
if( !("[icon_state][target_dir]" in beam_master) )
var/image/I = image(icon,icon_state,10,target_dir) //Generate it.
beam_master["[icon_state][target_dir]"] = I //And cache it!
//Finally add the overlay
loc.overlays += beam_master["[icon_state][target_dir]"]
//Add the turf to a list in the beam master so they can be cleaned up easily.
if(reference in beam_master)
var/list/turf_master = beam_master[reference]
if("[icon_state][target_dir]" in turf_master)
var/list/turfs = turf_master["[icon_state][target_dir]"]
turfs += loc
else
turf_master["[icon_state][target_dir]"] = list(loc)
else
var/list/turfs = list()
turfs["[icon_state][target_dir]"] = list(loc)
beam_master[reference] = turfs
if(!first)
var/obj/item/projectile/beam/new_beam = new src.type(loc)
processing_objects.Remove(new_beam)
new_beam.dir = get_dir(src, current)
new_beam.ID = ID
new_beam.icon_state = icon_state
else
first = 0
cleanup(reference)
return
proc/cleanup(reference) //Waits .3 seconds then removes the overlay.
src = null
sleep(3)
var/list/turf_master = beam_master[reference]
for(var/laser_state in turf_master)
var/list/turfs = turf_master[laser_state]
for(var/turf/T in turfs)
T.overlays -= beam_master[laser_state]
return
/obj/effect/effect/laserdealer
name = "laserdealio"
proc/setup(var/ID = 0)
sleep(5)
for(var/obj/item/projectile/beam/beam in world)
if(ID == beam.ID)
del(beam)
spawn(0)
del(src)
/obj/item/projectile/practice
name = "laser"