Files
Bubberstation/code/game/objects/structures/kitchen_spike.dm
MrPerson 9eee3e5067 First pass at a qdel() garbage collection system for tgstation
Works pretty well. If it can't GC something, it'll just del() it and be done.
Speed is amazing, holy shit.

New procs you should be aware of:
qdel(atom/movable) - sets up an object for garbage collection. Call this rather than del(atom/movable).
atom/movable/Destroy() - called right before the object is GC'd, so it still has a loc. Also called if the object is del()'d.
new controller - garbage.dm has all the details on this. Basically it nulls all references on GC'd objects and force del() them if necessary.
Generally speaking, objects should use Destroy() for behavior prior to deletion rather than Del(). You should also always call the parent so the object gets the right gc_destroyed var set.

ISSUES:
Tries to GC mobs atm. This actually works for new players, not so much for humans/monkies/simple_animals/anything. I'm guessing it needs to clear out their mind and HUD and maybe other things.
Gibbing is really bugged. It works, but the overlays just sit there for awhile and ugh. I'm very tempted just to del() mob/living and mob/camera and call it a day.
qdel() equipment doesn't unequip the item.
Pipes don't generally GC correctly. Debugging suggests they get referenced in many pipenets and that isn't cleared properly. However some do work fine. Need assistance here.
Bots don't GC, probably in the radio controller.
Lots of other shit doesn't GC but it's hard to find them because of the pipe spam.
I think I'm calling Destroy() twice by accident.
2014-02-23 14:55:12 -08:00

80 lines
2.7 KiB
Plaintext

//////Kitchen Spike
/obj/structure/kitchenspike
name = "a meat spike"
icon = 'icons/obj/kitchen.dmi'
icon_state = "spike"
desc = "A spike for collecting meat from animals"
density = 1
anchored = 1
var/meat = 0
var/occupied = 0
var/meattype = 0 // 0 - Nothing, 1 - Monkey, 2 - Xeno
/obj/structure/kitchenspike
attack_paw(mob/user as mob)
return src.attack_hand(usr)
attackby(obj/item/weapon/grab/G as obj, mob/user as mob)
if(!istype(G, /obj/item/weapon/grab))
return
if(istype(G.affecting, /mob/living/carbon/monkey))
if(src.occupied == 0)
src.icon_state = "spikebloody"
src.occupied = 1
src.meat = 5
src.meattype = 1
for(var/mob/O in viewers(src, null))
O.show_message(text("\red [user] has forced [G.affecting] onto the spike, killing them instantly!"))
qdel(G.affecting)
qdel(G)
else
user << "\red The spike already has something on it, finish collecting its meat first!"
else if(istype(G.affecting, /mob/living/carbon/alien))
if(src.occupied == 0)
src.icon_state = "spikebloodygreen"
src.occupied = 1
src.meat = 5
src.meattype = 2
for(var/mob/O in viewers(src, null))
O.show_message(text("\red [user] has forced [G.affecting] onto the spike, killing them instantly!"))
qdel(G.affecting)
qdel(G)
else
user << "\red The spike already has something on it, finish collecting its meat first!"
else
user << "\red They are too big for the spike, try something smaller!"
return
// MouseDrop_T(var/atom/movable/C, mob/user)
// if(istype(C, /obj/mob/carbon/monkey)
// else if(istype(C, /obj/mob/carbon/alien) && !istype(C, /mob/living/carbon/alien/larva/slime))
// else if(istype(C, /obj/livestock/spesscarp
attack_hand(mob/user as mob)
if(..())
return
if(src.occupied)
if(src.meattype == 1)
if(src.meat > 1)
src.meat--
new /obj/item/weapon/reagent_containers/food/snacks/meat/monkey( src.loc )
usr << "You remove some meat from the monkey."
else if(src.meat == 1)
src.meat--
new /obj/item/weapon/reagent_containers/food/snacks/meat/monkey(src.loc)
usr << "You remove the last piece of meat from the monkey!"
src.icon_state = "spike"
src.occupied = 0
else if(src.meattype == 2)
if(src.meat > 1)
src.meat--
new /obj/item/weapon/reagent_containers/food/snacks/xenomeat( src.loc )
usr << "You remove some meat from the alien."
else if(src.meat == 1)
src.meat--
new /obj/item/weapon/reagent_containers/food/snacks/xenomeat(src.loc)
usr << "You remove the last piece of meat from the alien!"
src.icon_state = "spike"
src.occupied = 0