Files
kiwistation/code/modules/detectivework/evidence.dm
T
MrPerson ff3f84ab81 Replaces /image with /mutable_appearance, where appropriate (#26518)
In cases where you're creating an image to use as an overlay, it makes more sense to use a mutable_appearance if you can. The image will create a static appearance for not just the image but also each intermediate step if you change vars along the way. The mutable appearance avoids this unnecessary and expensive process. The only situation that requires an image instead of a mutable_appearance is if the overlay is supposed to be directional. MA's ignore direction while images don't. I dunno why, probably another BYOND-ism.

I added a convenience function, mutable_appearance(), designed to emulate image(). Also went ahead and set the default plane of /mutable_appearance to FLOAT_PLANE because it's fucking 0 by default.

Several overlays that were image() calls were changed to just text strings when I could. overlays += "string" has the same result as overlays += image(icon, "string") and saves a proc call.
2017-04-25 12:15:16 +02:00

92 lines
3.0 KiB
Plaintext

//CONTAINS: Evidence bags
/obj/item/weapon/evidencebag
name = "evidence bag"
desc = "An empty evidence bag."
icon = 'icons/obj/storage.dmi'
icon_state = "evidenceobj"
item_state = ""
w_class = WEIGHT_CLASS_TINY
/obj/item/weapon/evidencebag/afterattack(obj/item/I, mob/user,proximity)
if(!proximity || loc == I)
return
evidencebagEquip(I, user)
/obj/item/weapon/evidencebag/attackby(obj/item/I, mob/user, params)
if(evidencebagEquip(I, user))
return 1
/obj/item/weapon/evidencebag/proc/evidencebagEquip(obj/item/I, mob/user)
if(!istype(I) || I.anchored == 1)
return
if(istype(I, /obj/item/weapon/evidencebag))
to_chat(user, "<span class='notice'>You find putting an evidence bag in another evidence bag to be slightly absurd.</span>")
return 1 //now this is podracing
if(I.w_class > WEIGHT_CLASS_NORMAL)
to_chat(user, "<span class='notice'>[I] won't fit in [src].</span>")
return
if(contents.len)
to_chat(user, "<span class='notice'>[src] already has something inside it.</span>")
return
if(!isturf(I.loc)) //If it isn't on the floor. Do some checks to see if it's in our hands or a box. Otherwise give up.
if(istype(I.loc,/obj/item/weapon/storage)) //in a container.
var/obj/item/weapon/storage/U = I.loc
U.remove_from_storage(I, src)
if(user.is_holding(I))
user.dropItemToGround(I)
else
return
user.visible_message("[user] puts [I] into [src].", "<span class='notice'>You put [I] inside [src].</span>",\
"<span class='italics'>You hear a rustle as someone puts something into a plastic bag.</span>")
icon_state = "evidence"
var/mutable_appearance/in_evidence = new(I)
in_evidence.plane = FLOAT_PLANE
in_evidence.layer = FLOAT_LAYER
in_evidence.pixel_x = 0
in_evidence.pixel_y = 0
add_overlay(in_evidence)
add_overlay("evidence") //should look nicer for transparent stuff. not really that important, but hey.
desc = "An evidence bag containing [I]. [I.desc]"
I.loc = src
w_class = I.w_class
return 1
/obj/item/weapon/evidencebag/attack_self(mob/user)
if(contents.len)
var/obj/item/I = contents[1]
user.visible_message("[user] takes [I] out of [src].", "<span class='notice'>You take [I] out of [src].</span>",\
"<span class='italics'>You hear someone rustle around in a plastic bag, and remove something.</span>")
cut_overlays() //remove the overlays
user.put_in_hands(I)
w_class = WEIGHT_CLASS_TINY
icon_state = "evidenceobj"
desc = "An empty evidence bag."
else
to_chat(user, "[src] is empty.")
icon_state = "evidenceobj"
return
/obj/item/weapon/storage/box/evidence
name = "evidence bag box"
desc = "A box claiming to contain evidence bags."
/obj/item/weapon/storage/box/evidence/New()
new /obj/item/weapon/evidencebag(src)
new /obj/item/weapon/evidencebag(src)
new /obj/item/weapon/evidencebag(src)
new /obj/item/weapon/evidencebag(src)
new /obj/item/weapon/evidencebag(src)
new /obj/item/weapon/evidencebag(src)
..()
return