Moar object pool.

This commit is contained in:
ESwordTheCat
2014-04-29 05:59:43 -08:00
parent f72eeb1a6a
commit 5446f21a1f
5 changed files with 44 additions and 18 deletions

View File

@@ -162,6 +162,7 @@ var/list/masterPool
*/ */
/atom/movable /atom/movable
proc/resetVariables() proc/resetVariables()
name = initial(name)
density = initial(density) density = initial(density)
icon = initial(icon) icon = initial(icon)
icon_state = initial(icon_state) icon_state = initial(icon_state)

View File

@@ -97,13 +97,14 @@
proc/check_fire(var/mob/living/target as mob, var/mob/living/user as mob) //Checks if you can hit them or not. proc/check_fire(var/mob/living/target as mob, var/mob/living/user as mob) //Checks if you can hit them or not.
if(!istype(target) || !istype(user)) if(!istype(target) || !istype(user))
return 0 return 0
var/obj/item/projectile/test/in_chamber = new /obj/item/projectile/test(get_step_to(user,target)) //Making the test.... var/obj/item/projectile/test/in_chamber = getFromPool(/obj/item/projectile/test, get_step_to(user, target)) //Making the test....
in_chamber.target = target in_chamber.target = target
in_chamber.flags = flags //Set the flags... in_chamber.flags = flags //Set the flags...
in_chamber.pass_flags = pass_flags //And the pass flags to that of the real projectile... in_chamber.pass_flags = pass_flags //And the pass flags to that of the real projectile...
in_chamber.firer = user in_chamber.firer = user
var/output = in_chamber.process() //Test it! var/output = in_chamber.process() //Test it!
del(in_chamber) //No need for it anymore //del(in_chamber) //No need for it anymore
returnToPool(in_chamber)
return output //Send it back to the gun! return output //Send it back to the gun!
Bump(atom/A as mob|obj|turf|area) Bump(atom/A as mob|obj|turf|area)
@@ -197,7 +198,7 @@
if(!istype(src, /obj/item/projectile/beam/lightning)) if(!istype(src, /obj/item/projectile/beam/lightning))
density = 0 density = 0
invisibility = 101 invisibility = 101
del(src) returnToPool(src)
return 1 return 1
@@ -212,13 +213,15 @@
process() process()
if(kill_count < 1) if(kill_count < 1)
del(src) //del(src)
returnToPool(src)
kill_count-- kill_count--
spawn while(src) spawn while(src)
if((!( current ) || loc == current)) if((!( current ) || loc == current))
current = locate(min(max(x + xo, 1), world.maxx), min(max(y + yo, 1), world.maxy), z) 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)) if((x == 1 || x == world.maxx || y == 1 || y == world.maxy))
del(src) //del(src)
returnToPool(src)
return return
step_towards(src, current) step_towards(src, current)
sleep(1) sleep(1)
@@ -230,9 +233,11 @@
return return
proc/dumbfire(var/dir) // for spacepods, go snowflake go proc/dumbfire(var/dir) // for spacepods, go snowflake go
if(!dir) if(!dir)
del(src) //del(src)
returnToPool(src)
if(kill_count < 1) if(kill_count < 1)
del(src) //del(src)
returnToPool(src)
kill_count-- kill_count--
spawn while(src) spawn while(src)
var/turf/T = get_step(src, dir) var/turf/T = get_step(src, dir)
@@ -252,6 +257,11 @@
var/target = null var/target = null
var/result = 0 //To pass the message back to the gun. var/result = 0 //To pass the message back to the gun.
resetVariables()
target = initial(target)
result = initial(result)
return ..()
Bump(atom/A as mob|obj|turf|area) Bump(atom/A as mob|obj|turf|area)
if(A == firer) if(A == firer)
loc = A.loc loc = A.loc

View File

@@ -10,11 +10,6 @@
*/ */
var/list/beam_master = list() var/list/beam_master = list()
//Special laser the captains gun uses
/obj/item/projectile/beam/captain
name = "captain laser"
damage = 40
/obj/item/projectile/beam/lightning /obj/item/projectile/beam/lightning
invisibility = 101 invisibility = 101
name = "lightning" name = "lightning"
@@ -163,7 +158,8 @@ var/list/beam_master = list()
if(src.loc != current) if(src.loc != current)
tang = adjustAngle(get_angle(src.loc,current)) tang = adjustAngle(get_angle(src.loc,current))
icon_state = "[tang]" icon_state = "[tang]"
del(src) //del(src)
returnToPool(src)
return return
/*cleanup(reference) //Waits .3 seconds then removes the overlay. /*cleanup(reference) //Waits .3 seconds then removes the overlay.
//world << "setting invisibility" //world << "setting invisibility"
@@ -191,6 +187,11 @@ var/list/beam_master = list()
eyeblur = 4 eyeblur = 4
var/frequency = 1 var/frequency = 1
// Special laser the captains gun uses
captain
name = "captain laser"
damage = 40
process() process()
var/reference = "\ref[src]" //So we do not have to recalculate it a ton 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 var/first = 1 //So we don't make the overlay in the same tile as the firer
@@ -245,16 +246,19 @@ var/list/beam_master = list()
var/reference = "\ref[src]" //So we do not have to recalculate it a ton 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 var/first = 1 //So we don't make the overlay in the same tile as the firer
if(!dir) if(!dir)
del(src) //del(src)
returnToPool(src)
spawn while(src) //Move until we hit something spawn while(src) //Move until we hit something
if((x == 1 || x == world.maxx || y == 1 || y == world.maxy)) if((x == 1 || x == world.maxx || y == 1 || y == world.maxy))
del(src) //Delete if it passes the world edge //del(src) //Delete if it passes the world edge
returnToPool(src)
return return
var/turf/T = get_step(src, dir) var/turf/T = get_step(src, dir)
step_towards(src, T) //Move~ step_towards(src, T) //Move~
if(kill_count < 1) if(kill_count < 1)
del(src) //del(src)
returnToPool(src)
kill_count-- kill_count--
if(!bumped && !isturf(original)) if(!bumped && !isturf(original))

View File

@@ -14,6 +14,10 @@
return 1 return 1
return 0 return 0
resetVariables()
embed = initial(embed)
return ..()
/obj/item/projectile/bullet/weakbullet /obj/item/projectile/bullet/weakbullet
damage = 10 damage = 10
stun = 5 stun = 5

View File

@@ -32,6 +32,8 @@
flag = "energy" flag = "energy"
var/temperature = 300 var/temperature = 300
resetVariables()
temperature = initial(temperature)
on_hit(var/atom/target, var/blocked = 0)//These two could likely check temp protection on the mob on_hit(var/atom/target, var/blocked = 0)//These two could likely check temp protection on the mob
if(istype(target, /mob/living)) if(istype(target, /mob/living))
@@ -147,6 +149,9 @@
flag = "energy" flag = "energy"
var/range = 2 var/range = 2
resetVariables()
range = initial(range)
obj/item/projectile/kinetic/New() obj/item/projectile/kinetic/New()
var/turf/proj_turf = get_turf(src) var/turf/proj_turf = get_turf(src)
if(!istype(proj_turf, /turf)) if(!istype(proj_turf, /turf))
@@ -193,10 +198,12 @@ obj/item/projectile/kinetic/New()
// Now we bump as a bullet, if the atom is a non-turf. // Now we bump as a bullet, if the atom is a non-turf.
if(!isturf(A)) if(!isturf(A))
..(A) ..(A)
qdel(src) // Comment this out if you want to shoot through the asteroid, ERASER-style. //qdel(src) // Comment this out if you want to shoot through the asteroid, ERASER-style.
returnToPool(src) // Comment this out if you want to shoot through the asteroid, ERASER-style.
return 1 return 1
else else
qdel(src) //qdel(src)
returnToPool(src)
return 0 return 0
/obj/item/effect/kinetic_blast /obj/item/effect/kinetic_blast