Files
vgstation13/code/modules/mining/ore_box.dm
DamianX f5c96279c6 Removed datum pooling (#26992)
* removed pooling

* replace returnToPool with qdel

* did stuff
2020-07-03 19:38:38 -03:00

85 lines
2.2 KiB
Plaintext

/**********************Ore box**************************/
/obj/structure/ore_box
icon = 'icons/obj/mining.dmi'
icon_state = "orebox0"
name = "Ore Box"
desc = "A heavy box used for storing ore."
density = 1
starting_materials = list()
var/list/stored_ores = list()
/obj/structure/ore_box/attackby(obj/item/weapon/W as obj, mob/user as mob)
// this makes it possible for supply cyborgs to interact with the box
if (istype(W, /obj/item/device/mining_scanner))
attack_hand(user)
return
if (istype(W, /obj/item/stack/ore))
var/obj/item/stack/ore/O = W
if(try_add_ore(O))
user.u_equip(W,0)
qdel(W)
if (istype(W, /obj/item/weapon/storage))
var/turf/T=get_turf(src)
var/obj/item/weapon/storage/S = W
S.hide_from(usr)
for(var/obj/item/stack/ore/O in S.contents)
if(try_add_ore(O))
S.remove_from_storage(O,T) //This will remove the item.
qdel(O)
to_chat(user, "<span class='notice'>You empty \the [W] into the box.</span>")
return
/obj/structure/ore_box/attack_hand(mob/user as mob)
var/dat = "<b>The contents of the ore box reveal...</b><ul>"
for(var/ore_id in stored_ores)
var/amount = stored_ores[ore_id]
var/obj/item/stack/ore/cast_type = ore_id
if(amount > 0)
dat += "<li><b>[initial(cast_type.name)]:</b> [amount]</li>"
dat += "</ul><A href='?src=\ref[src];removeall=1'>Empty box</A>"
user << browse("[dat]", "window=orebox")
return
/obj/structure/ore_box/Topic(href, href_list)
if(..())
return
usr.set_machine(src)
src.add_fingerprint(usr)
if(href_list["removeall"])
dump_everything()
to_chat(usr, "<span class='notice'>You empty the box.</span>")
src.updateUsrDialog()
return
/obj/structure/ore_box/proc/dump_everything(var/atom/target)
if (target == null)
target = get_turf(src)
for(var/ore_id in stored_ores)
var/amount = stored_ores[ore_id]
if(amount > 0)
drop_stack(ore_id, get_turf(src), amount)
stored_ores.Cut()
/obj/structure/ore_box/ex_act(severity)
switch(severity)
if(1.0)
dump_everything()
qdel(src)
if(2.0)
if (prob(50))
dump_everything()
qdel(src)
/obj/structure/ore_box/proc/try_add_ore(var/obj/item/stack/ore/O)
if (!O.can_orebox)
return FALSE
stored_ores[O.type] += O.amount
return TRUE