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.
This commit is contained in:
MrPerson
2017-04-25 03:15:16 -07:00
committed by AnturK
parent 572696292a
commit ff3f84ab81
151 changed files with 763 additions and 921 deletions
@@ -12,11 +12,7 @@
canSmoothWith = null
buildstacktype = null
flags = NODECONSTRUCT
var/image/nest_overlay
/obj/structure/bed/nest/New()
nest_overlay = image('icons/mob/alien.dmi', "nestoverlay", layer=LYING_MOB_LAYER)
return ..()
var/static/mutable_appearance/nest_overlay = mutable_appearance('icons/mob/alien.dmi', "nestoverlay", LYING_MOB_LAYER)
/obj/structure/bed/nest/user_unbuckle_mob(mob/living/buckled_mob, mob/living/user)
if(has_buckled_mobs())
@@ -145,11 +145,11 @@
obj_integrity = 70
max_integrity = 70
buildstackamount = 2
var/image/armrest = null
var/mutable_appearance/armrest
item_chair = null
/obj/structure/chair/comfy/Initialize()
armrest = image("icons/obj/chairs.dmi", "comfychair_armrest")
armrest = mutable_appearance('icons/obj/chairs.dmi', "comfychair_armrest")
armrest.layer = ABOVE_MOB_LAYER
return ..()
@@ -8,7 +8,7 @@
/obj/structure/chair/e_chair/New()
..()
add_overlay(image('icons/obj/chairs.dmi', src, "echair_over", MOB_LAYER + 1))
add_overlay(mutable_appearance('icons/obj/chairs.dmi', "echair_over", MOB_LAYER + 1))
/obj/structure/chair/e_chair/attackby(obj/item/weapon/W, mob/user, params)
if(istype(W, /obj/item/weapon/wrench))
+4 -2
View File
@@ -7,7 +7,7 @@
anchored = 0
density = 1
opacity = 0
var/case_type = null
var/case_type = ""
var/gun_category = /obj/item/weapon/gun
var/open = 1
var/capacity = 4
@@ -25,8 +25,10 @@
/obj/structure/guncase/update_icon()
cut_overlays()
if(case_type && LAZYLEN(contents))
var/mutable_appearance/gun_overlay = mutable_appearance(icon, case_type)
for(var/i in 1 to contents.len)
add_overlay(image(icon = src.icon, icon_state = "[case_type]", pixel_x = 3 * (i - 1) ))
gun_overlay.pixel_x = 3 * (i - 1)
add_overlay(gun_overlay)
if(open)
add_overlay("[icon_state]_open")
else
@@ -143,21 +143,21 @@
/obj/structure/transit_tube/proc/create_tube_overlay(direction, shift_dir)
var/image/I
var/image/tube_overlay = new(dir = direction)
if(shift_dir)
I = image(loc = src, icon_state = "decorative_diag", dir = direction)
tube_overlay.icon_state = "decorative_diag"
switch(shift_dir)
if(NORTH)
I.pixel_y = 32
tube_overlay.pixel_y = 32
if(SOUTH)
I.pixel_y = -32
tube_overlay.pixel_y = -32
if(EAST)
I.pixel_x = 32
tube_overlay.pixel_x = 32
if(WEST)
I.pixel_x = -32
tube_overlay.pixel_x = -32
else
I = image(loc = src, icon_state = "decorative", dir = direction)
add_overlay(I)
tube_overlay.icon_state = "decorative"
add_overlay(tube_overlay)
+1 -1
View File
@@ -239,7 +239,7 @@
qdel(mymist)
if(on)
add_overlay(image('icons/obj/watercloset.dmi', src, "water", MOB_LAYER + 1, dir))
add_overlay(mutable_appearance('icons/obj/watercloset.dmi', "water", MOB_LAYER + 1))
if(watertemp == "freezing")
return
if(!ismist)
+3 -3
View File
@@ -18,7 +18,7 @@
var/fulltile = 0
var/glass_type = /obj/item/stack/sheet/glass
var/glass_amount = 1
var/image/crack_overlay
var/static/mutable_appearance/crack_overlay = mutable_appearance('icons/obj/structures.dmi')
var/list/debris = list()
can_be_unanchored = 1
resistance_flags = ACID_PROOF
@@ -361,10 +361,10 @@
if(smooth)
queue_smooth(src)
cut_overlay(crack_overlay)
cut_overlays()
if(ratio > 75)
return
crack_overlay = image('icons/obj/structures.dmi',"damage[ratio]",-(layer+0.1))
crack_overlay.icon_state = "damage[ratio]"
add_overlay(crack_overlay)
/obj/structure/window/temperature_expose(datum/gas_mixture/air, exposed_temperature, exposed_volume)