update_appearance (#55468)

Creates update_name and update_desc
Creates the wrapper proc update_appearance to batch update_name, update_desc, and update_icon together
Less non-icon handling code in update_icon and friends
Signal hooks for things that want to change names and descriptions
99%+ of the changes in this are just from switching everything over to update_appearance from update_icon
This commit is contained in:
TemporalOroboros
2021-02-19 12:06:18 -03:00
committed by GitHub
parent dc4b7226d0
commit e4079c87b8
585 changed files with 4689 additions and 4133 deletions
+28 -30
View File
@@ -15,7 +15,7 @@
/obj/structure/fireaxecabinet/Initialize()
. = ..()
fireaxe = new
update_icon()
update_appearance()
/obj/structure/fireaxecabinet/Destroy()
if(fireaxe)
@@ -33,7 +33,7 @@
to_chat(user, "<span class='notice'>You begin repairing [src].</span>")
if(I.use_tool(src, user, 40, volume=50, amount=2))
obj_integrity = max_integrity
update_icon()
update_appearance()
to_chat(user, "<span class='notice'>You repair [src].</span>")
else
to_chat(user, "<span class='warning'>[src] is already in good condition!</span>")
@@ -47,7 +47,7 @@
if(do_after(user, 20, target = src) && G.use(2))
broken = FALSE
obj_integrity = max_integrity
update_icon()
update_appearance()
else if(open || broken)
if(istype(I, /obj/item/fireaxe) && !fireaxe)
var/obj/item/fireaxe/F = I
@@ -58,7 +58,7 @@
return
fireaxe = F
to_chat(user, "<span class='notice'>You place the [F.name] back in the [name].</span>")
update_icon()
update_appearance()
return
else if(!broken)
toggle_open()
@@ -80,11 +80,11 @@
return
. = ..()
if(.)
update_icon()
update_appearance()
/obj/structure/fireaxecabinet/obj_break(damage_flag)
if(!broken && !(flags_1 & NODECONSTRUCT_1))
update_icon()
update_appearance()
broken = TRUE
playsound(src, 'sound/effects/glassbr3.ogg', 100, TRUE)
new /obj/item/shard(loc)
@@ -114,14 +114,14 @@
fireaxe = null
to_chat(user, "<span class='notice'>You take the fire axe from the [name].</span>")
src.add_fingerprint(user)
update_icon()
update_appearance()
return
if(locked)
to_chat(user, "<span class='warning'>The [name] won't budge!</span>")
return
else
open = !open
update_icon()
update_appearance()
return
/obj/structure/fireaxecabinet/attack_paw(mob/living/user, list/modifiers)
@@ -138,33 +138,31 @@
to_chat(user, "<span class='warning'>The [name] won't budge!</span>")
return
open = !open
update_icon()
update_appearance()
/obj/structure/fireaxecabinet/update_overlays()
. = ..()
if(fireaxe)
. += "axe"
if(!open)
var/hp_percent = obj_integrity/max_integrity * 100
if(broken)
. += "glass4"
else
switch(hp_percent)
if(-INFINITY to 40)
. += "glass3"
if(40 to 60)
. += "glass2"
if(60 to 80)
. += "glass1"
if(80 to INFINITY)
. += "glass"
if(locked)
. += "locked"
else
. += "unlocked"
else
if(open)
. += "glass_raised"
return
var/hp_percent = obj_integrity/max_integrity * 100
if(broken)
. += "glass4"
else
switch(hp_percent)
if(-INFINITY to 40)
. += "glass3"
if(40 to 60)
. += "glass2"
if(60 to 80)
. += "glass1"
if(80 to INFINITY)
. += "glass"
. += locked ? "locked" : "unlocked"
/obj/structure/fireaxecabinet/proc/toggle_lock(mob/user)
to_chat(user, "<span class='notice'>Resetting circuitry...</span>")
@@ -172,7 +170,7 @@
if(do_after(user, 20, target = src))
to_chat(user, "<span class='notice'>You [locked ? "disable" : "re-enable"] the locking modules.</span>")
locked = !locked
update_icon()
update_appearance()
/obj/structure/fireaxecabinet/verb/toggle_open()
set name = "Open/Close"
@@ -184,5 +182,5 @@
return
else
open = !open
update_icon()
update_appearance()
return