Grilles and rods.

Grilles no longer return more rods than they were created from when destroyed (by method other than wirecutters).
Rods are now acquired from and returned to a pool.
Also adds a pre-broken grille for mapping, avoids the case where one might be able to destroy the same grille twice.
This commit is contained in:
PsiOmega
2015-05-02 21:33:37 +02:00
parent a9b1f8bfe0
commit ca7fa2aa19
15 changed files with 48 additions and 38 deletions

View File

@@ -97,7 +97,7 @@
src.d_state = 1
if(target)
var/obj/item/stack/rods/R = new /obj/item/stack/rods(target.loc)
var/obj/item/stack/rods/R = PoolOrNew(/obj/item/stack/rods, target.loc)
R.amount = 2
qdel(Target)

View File

@@ -23,24 +23,20 @@ var/global/list/GlobalPool = list()
//Either way it gets passed to new
/proc/PoolOrNew(var/get_type,var/second_arg)
if(!get_type)
return
var/datum/D
D = GetFromPool(get_type,second_arg)
if(!D)
if(ispath(get_type))
if(islist(second_arg))
return new get_type (arglist(second_arg))
else
return new get_type (second_arg)
// So the GC knows we're pooling this type.
if(!GlobalPool[get_type])
GlobalPool[get_type] = list(new get_type)
if(islist(second_arg))
return new get_type (arglist(second_arg))
else
return new get_type (second_arg)
return D
/proc/GetFromPool(var/get_type,var/second_arg)
if(!get_type)
return 0
if(isnull(GlobalPool[get_type]))
return 0
@@ -75,9 +71,10 @@ var/global/list/GlobalPool = list()
D.Destroy()
D.ResetVars()
D.disposed = 1 //Set to stop processing while pooled
/proc/IsPooled(var/datum/D)
if(isnull(GlobalPool[D.type]) || length(GlobalPool[D.type]) == 0)
if(isnull(GlobalPool[D.type]))
return 0
return 1
@@ -86,10 +83,13 @@ var/global/list/GlobalPool = list()
New(arglist(args))
else
New(args)
disposed = null
/atom/movable/Prepare(args)
if(islist(args))
var/list/args_list = args
if(istype(args_list) && args_list.len)
loc = args[1]
else
loc = args
..()

View File

@@ -868,8 +868,8 @@
var/turf/Tsec = get_turf(src)
new /obj/item/device/assembly/prox_sensor(Tsec)
new /obj/item/stack/rods(Tsec)
new /obj/item/stack/rods(Tsec)
PoolOrNew(/obj/item/stack/rods, Tsec)
PoolOrNew(/obj/item/stack/rods, Tsec)
new /obj/item/stack/cable_coil/cut(Tsec)
if (cell)
cell.loc = Tsec

View File

@@ -264,7 +264,7 @@ for reference:
var/turf/Tsec = get_turf(src)
/* var/obj/item/stack/rods/ =*/
new /obj/item/stack/rods(Tsec)
PoolOrNew(/obj/item/stack/rods, Tsec)
var/datum/effect/effect/system/spark_spread/s = new /datum/effect/effect/system/spark_spread
s.set_up(3, 1, src)

View File

@@ -164,7 +164,7 @@
switch (Proj.damage_type)
if(BRUTE)
new /obj/item/stack/sheet/metal(src.loc, 2)
new /obj/item/stack/rods(src.loc, 3)
PoolOrNew(/obj/item/stack/rods, list(src.loc, 3))
if(BURN)
new /obj/effect/decal/cleanable/ash(src.loc) // Turn it to ashes!
qdel(src)

View File

@@ -82,7 +82,7 @@
if(ptank)
ptank.loc = T
ptank = null
new /obj/item/stack/rods(T)
PoolOrNew(/obj/item/stack/rods, T)
qdel(src)
return

View File

@@ -144,11 +144,11 @@
var/obj/structure/window/W = A
new /obj/item/weapon/shard( W.loc )
if(W.reinf) new /obj/item/stack/rods( W.loc)
if(W.reinf) PoolOrNew(/obj/item/stack/rods, W.loc)
if (W.dir == SOUTHWEST)
new /obj/item/weapon/shard( W.loc )
if(W.reinf) new /obj/item/stack/rods( W.loc)
if(W.reinf) PoolOrNew(/obj/item/stack/rods, W.loc)
qdel(A)

View File

@@ -103,7 +103,7 @@
if(iswirecutter(W))
if(!shock(user, 100))
playsound(loc, 'sound/items/Wirecutter.ogg', 100, 1)
new /obj/item/stack/rods(loc, 2)
PoolOrNew(/obj/item/stack/rods, list(get_turf(src), destroyed ? 1 : 2))
qdel(src)
else if((isscrewdriver(W)) && (istype(loc, /turf/simulated) || anchored))
if(!shock(user, 90))
@@ -173,11 +173,11 @@
density = 0
destroyed = 1
update_icon()
new /obj/item/stack/rods(loc)
PoolOrNew(/obj/item/stack/rods, get_turf(src))
else
if(health <= -6)
new /obj/item/stack/rods(loc)
PoolOrNew(/obj/item/stack/rods, get_turf(src))
qdel(src)
return
return
@@ -221,6 +221,16 @@
spawn(1) healthcheck()
return 1
// Used in mapping to avoid
/obj/structure/grille/broken
destroyed = 1
icon_state = "grille-b"
density = 0
New()
..()
health -= rand(initial(health)*0.8, initial(health)*0.9) //Largely under broken threshold, this is used to adjust the health, NOT to break it
healthcheck() //Send this to healthcheck just in case we want to do something else with it
/obj/structure/grille/cult
name = "cult grille"
desc = "A matrice built out of an unknown material, with some sort of force field blocking air around it"

View File

@@ -78,7 +78,7 @@ obj/structure/windoor_assembly/Destroy()
user << "\blue You dissasembled the windoor assembly!"
new /obj/item/stack/sheet/glass/reinforced(get_turf(src), 5)
if(secure)
new /obj/item/stack/rods(get_turf(src), 4)
PoolOrNew(/obj/item/stack/rods, list(get_turf(src), 4))
qdel(src)
else
user << "\blue You need more welding fuel to dissassemble the windoor assembly."

View File

@@ -88,11 +88,11 @@
index = 0
while(index < 2)
new shardtype(loc)
if(reinf) new /obj/item/stack/rods(loc)
if(reinf) PoolOrNew(/obj/item/stack/rods, loc)
index++
else
new shardtype(loc)
if(reinf) new /obj/item/stack/rods(loc)
if(reinf) PoolOrNew(/obj/item/stack/rods, loc)
qdel(src)
return

View File

@@ -64,7 +64,7 @@
user << "\blue Removing rods..."
playsound(src, 'sound/items/Ratchet.ogg', 80, 1)
if(do_after(user, 30))
new /obj/item/stack/rods(src, 2)
PoolOrNew(/obj/item/stack/rods, list(loc, 2))
ChangeTurf(/turf/simulated/floor)
var/turf/simulated/floor/F = src
F.make_plating()

View File

@@ -98,7 +98,7 @@
playsound(src, 'sound/items/Wirecutter.ogg', 100, 1)
src.d_state = 1
src.icon_state = "r_wall-1"
new /obj/item/stack/rods( src )
PoolOrNew(/obj/item/stack/rods, src)
user << "<span class='notice'>You cut the outer grille.</span>"
return
@@ -206,7 +206,7 @@
if( d_state == 5 && user.loc == T && user.get_active_hand() == WT )
src.d_state = 6
src.icon_state = "r_wall-6"
new /obj/item/stack/rods( src )
PoolOrNew(/obj/item/stack/rods, src)
user << "<span class='notice'>The support rods drop out as you cut them loose from the frame.</span>"
else
user << "<span class='notice'>You need more welding fuel to complete this task.</span>"
@@ -223,7 +223,7 @@
if( d_state == 5 && user.loc == T && user.get_active_hand() == W )
src.d_state = 6
src.icon_state = "r_wall-6"
new /obj/item/stack/rods( src )
PoolOrNew(/obj/item/stack/rods, src)
user << "<span class='notice'>The support rods drop out as you cut them loose from the frame.</span>"
return

View File

@@ -217,7 +217,7 @@
if(building == 1)
I = new /obj/item/stack/tile/plasteel(src)
else
I = new /obj/item/stack/rods(src)
I = PoolOrNew(/obj/item/stack/rods, src)
A.attackby(I, src)
target = null
repairing = 0

View File

@@ -183,16 +183,16 @@
step_to(O, get_turf(pick(view(7, src))))
//rods
O = new /obj/item/stack/rods(src.loc)
O = PoolOrNew(/obj/item/stack/rods, src.loc)
step_to(O, get_turf(pick(view(7, src))))
if(prob(75))
O = new /obj/item/stack/rods(src.loc)
O = PoolOrNew(/obj/item/stack/rods, src.loc)
step_to(O, get_turf(pick(view(7, src))))
if(prob(50))
O = new /obj/item/stack/rods(src.loc)
O = PoolOrNew(/obj/item/stack/rods, src.loc)
step_to(O, get_turf(pick(view(7, src))))
if(prob(25))
O = new /obj/item/stack/rods(src.loc)
O = PoolOrNew(/obj/item/stack/rods, src.loc)
step_to(O, get_turf(pick(view(7, src))))
//plasteel

View File

@@ -201,8 +201,8 @@
src.visible_message("\red <B>[src] blows apart!</B>", 1)
var/turf/Tsec = get_turf(src)
new /obj/item/stack/rods(Tsec)
new /obj/item/stack/rods(Tsec)
PoolOrNew(/obj/item/stack/rods, Tsec)
PoolOrNew(/obj/item/stack/rods, Tsec)
new /obj/item/stack/cable_coil/cut(Tsec)
if(cell)