revert beams.

This commit is contained in:
ESwordTheCat
2014-06-30 08:11:41 -08:00
parent ac64512217
commit 8cc2331592

View File

@@ -1,3 +1,4 @@
/*
* Use: Caches beam state images and holds turfs that had these images overlaid.
* Structure:
@@ -187,101 +188,134 @@ var/list/beam_master = list()
eyeblur = 4
var/frequency = 1
/obj/item/projectile/beam/process()
var/reference = "\ref[src]"
spawn(0)
var/nextLoc = locate(Clamp(x + xo, 1, world.maxx), Clamp(y + yo, 1, world.maxy), z)
var/target_dir
while(src && --kill_count >= 0)
process()
var/lastposition = loc
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
spawn while(loc) //Move until we hit something
if((!( current ) || loc == current)) //If we pass our target
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
returnToPool(src)
return
step_towards(src, current) //Move~
if(loc == nextLoc)
nextLoc = locate(Clamp(x + xo, 1, world.maxx), Clamp(y + yo, 1, world.maxy), z)
if(isnull(loc))
return
if(lastposition == loc)
kill_count = 0
lastposition = loc
if(kill_count < 1)
//del(src)
returnToPool(src)
return
kill_count--
step_towards(src, nextLoc, 0)
target_dir = get_dir(src, nextLoc)
if(!bumped && !isturf(original))
if(loc == get_turf(original))
if(!(original in permutated))
Bump(original)
if(!("[icon_state][target_dir]" in beam_master))
beam_master["[icon_state][target_dir]"] = image(icon, icon_state, 10, target_dir)
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
loc.overlays += beam_master["[icon_state][target_dir]"]
//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!
if(reference in beam_master)
var/list/turf_master = beam_master[reference]
//Finally add the overlay
src.loc.overlays += beam_master["[icon_state][target_dir]"]
if("[icon_state][target_dir]" in turf_master)
var/list/turfs = turf_master["[icon_state][target_dir]"]
turfs += loc
//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
turf_master["[icon_state][target_dir]"] = list(loc)
var/list/turfs = list()
turfs["[icon_state][target_dir]"] = list(loc)
beam_master[reference] = turfs
else
var/list/turfs = new
turfs["[icon_state][target_dir]"] = list(loc)
beam_master[reference] = turfs
first = 0
cleanup(reference)
return
dumbfire(var/dir)
var/lastposition = loc
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
if(!dir)
//del(src)
returnToPool(src)
spawn while(loc) //Move until we hit something
if((x == 1 || x == world.maxx || y == 1 || y == world.maxy))
//del(src) //Delete if it passes the world edge
returnToPool(src)
return
var/turf/T = get_step(src, dir)
step_towards(src, T) //Move~
if(isnull(loc))
return
if(lastposition == loc)
kill_count = 0
lastposition = loc
if(kill_count < 1)
//del(src)
returnToPool(src)
kill_count--
cleanup(reference)
if(!bumped && !isturf(original))
if(loc == get_turf(original))
if(!(original in permutated))
Bump(original)
/obj/item/projectile/beam/dumbfire(const/dir)
if(!(dir in alldirs))
returnToPool(src)
if(!first) //Add the overlay as we pass over tiles
var/target_dir = dir //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
src.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
else
first = 0
cleanup(reference)
return
var/reference = "\ref[src]"
spawn(0)
var/nextLoc = locate(Clamp(x + xo, 1, world.maxx), Clamp(y + yo, 1, world.maxy), z)
var/target_dir = dir
Destroy()
cleanup("\ref[src]")
..()
while(src && --kill_count >= 0)
if((x == 1 || x == world.maxx || y == 1 || y == world.maxy))
returnToPool(src)
return
if(loc == nextLoc)
nextLoc = locate(Clamp(x + xo, 1, world.maxx), Clamp(y + yo, 1, world.maxy), z)
step_towards(src, nextLoc, 0)
if(!("[icon_state][target_dir]" in beam_master))
beam_master["[icon_state][target_dir]"] = image(icon, icon_state, 10, target_dir)
loc.overlays += beam_master["[icon_state][target_dir]"]
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 = new
turfs["[icon_state][target_dir]"] = list(loc)
beam_master[reference] = turfs
cleanup(reference)
/obj/item/projectile/beam/Destroy()
// don't use qdel when deleting this, returnToPool will handle it.
..()
/obj/item/projectile/beam/proc/cleanup(const/reference)
spawn(3)
var/list/turf_master = beam_master[reference]
for(var/laser_state in turf_master)
var/list/turfs = turf_master[laser_state]
for(var/atom/A in turfs)
A.overlays -= beam_master[laser_state]
turfs -= A
returnToPool(src)
proc/cleanup(reference) //Waits .3 seconds then removes the overlay.
src = null // Redundant.
spawn(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]
turfs.Cut()
return
/obj/item/projectile/beam/practice
name = "laser"