Files
Bubberstation/code/game/objects/items/crayons.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

97 lines
2.5 KiB
Plaintext

/obj/item/toy/crayon/red
icon_state = "crayonred"
colour = "#DA0000"
colourName = "red"
/obj/item/toy/crayon/orange
icon_state = "crayonorange"
colour = "#FF9300"
colourName = "orange"
/obj/item/toy/crayon/yellow
icon_state = "crayonyellow"
colour = "#FFF200"
colourName = "yellow"
/obj/item/toy/crayon/green
icon_state = "crayongreen"
colour = "#A8E61D"
colourName = "green"
/obj/item/toy/crayon/blue
icon_state = "crayonblue"
colour = "#00B7EF"
colourName = "blue"
/obj/item/toy/crayon/purple
icon_state = "crayonpurple"
colour = "#DA00FF"
colourName = "purple"
/obj/item/toy/crayon/mime
icon_state = "crayonmime"
desc = "A very sad-looking crayon."
colour = "#FFFFFF"
colourName = "mime"
uses = 0
/obj/item/toy/crayon/mime/attack_self(mob/living/user as mob) //inversion
if(colour != "#FFFFFF")
colour = "#FFFFFF"
user << "You will now draw in white with this crayon."
else
colour = "#000000"
user << "You will now draw in black with this crayon."
return
/obj/item/toy/crayon/rainbow
icon_state = "crayonrainbow"
colour = "#FFF000"
colourName = "rainbow"
uses = 0
/obj/item/toy/crayon/rainbow/attack_self(mob/living/user as mob)
colour = input(user, "Please select the main colour.", "Crayon colour") as color
return
/obj/item/toy/crayon/afterattack(atom/target, mob/user as mob, proximity)
if(!proximity) return
if(istype(target,/turf/simulated/floor))
var/drawtype = input("Choose what you'd like to draw.", "Crayon scribbles") in list("graffiti","rune","letter")
switch(drawtype)
if("letter")
drawtype = input("Choose the letter.", "Crayon scribbles") in list("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z")
user << "You start drawing a letter on the [target.name]."
if("graffiti")
user << "You start drawing graffiti on the [target.name]."
if("rune")
user << "You start drawing a rune on the [target.name]."
if(instant || do_after(user, 50))
new /obj/effect/decal/cleanable/crayon(target,colour,drawtype)
user << "You finish drawing."
if(uses)
uses--
if(!uses)
user << "\red You used up your crayon!"
qdel(src)
return
/obj/item/toy/crayon/attack(mob/M as mob, mob/user as mob)
if(M == user)
user << "You take a bite of the crayon. Delicious!"
user.nutrition += 5
if(uses)
uses -= 5
if(uses <= 0)
user << "\red You ate your crayon!"
qdel(src)
else
..()