Update SSOverlays (ported from Baystation) (#19051)

Our SSOverlays system is outdated, and is likely the cause of many of
the issues seen in #18895. It has also been linked to a massive server
performance decrease.

This brings an updated system from Baystation, hopefully with speed
increases.

Should be testmerged, ideally with #18895.

---------

Co-authored-by: Cody Brittain <cbrittain10@live.com>
This commit is contained in:
Cody Brittain
2024-05-01 07:46:27 +00:00
committed by GitHub
co-authored by Cody Brittain
parent 405a05b819
commit 9983fca311
350 changed files with 1626 additions and 1498 deletions
+2 -2
View File
@@ -153,7 +153,7 @@
/obj/screen/new_player/selection/MouseEntered(location, control, params)
if(hud_arrow)
add_overlay(hud_arrow, force_compile = TRUE)
AddOverlays(hud_arrow)
else
var/matrix/M = matrix()
M.Scale(1.1, 1)
@@ -162,7 +162,7 @@
/obj/screen/new_player/selection/MouseExited(location,control,params)
if(hud_arrow)
cut_overlays(force_compile = TRUE)
ClearOverlays()
else
animate(src, color = null, transform = null, time = 3, easing = CUBIC_EASING)
return ..()
@@ -227,7 +227,7 @@ Works together with spawning an observer, noted above.
/mob/proc/ghostize(var/can_reenter_corpse = TRUE, var/should_set_timer = TRUE)
if(ckey)
cut_overlay(image('icons/effects/effects.dmi', "zzz_glow")) // not very efficient but ghostize isn't called /too/ often.
CutOverlays(image('icons/effects/effects.dmi', "zzz_glow")) // not very efficient but ghostize isn't called /too/ often.
var/mob/abstract/observer/ghost = new(src) //Transfer safety to observer spawning proc.
ghost.can_reenter_corpse = can_reenter_corpse
ghost.timeofdeath = src.stat == DEAD ? src.timeofdeath : world.time
@@ -76,7 +76,7 @@
flower_color = null
flower_image = null
cut_overlays()
ClearOverlays()
. = ..()
GC_TEMPORARY_HARDDEL
@@ -6,14 +6,14 @@
else
icon_state = "[initial(icon_state)]"
cut_overlays()
ClearOverlays()
if(flower_color)
add_overlay("flower_back")
AddOverlays("flower_back")
if(!flower_image)
flower_image = image(icon = 'icons/mob/diona.dmi', icon_state = "flower_fore")
flower_image.color = flower_color
add_overlay(flower_image)
AddOverlays(flower_image)
if(hat)
add_overlay(get_hat_icon(hat, 0, -8))
AddOverlays(get_hat_icon(hat, 0, -8))
+3 -3
View File
@@ -1491,11 +1491,11 @@
new_oxy = "oxydamageoverlay[severity]"
if(new_oxy != last_oxy_overlay)
damageoverlay.cut_overlay(last_oxy_overlay)
damageoverlay.add_overlay(new_oxy)
damageoverlay.CutOverlays(last_oxy_overlay)
damageoverlay.AddOverlays(new_oxy)
last_oxy_overlay = new_oxy
else if (last_oxy_overlay)
damageoverlay.cut_overlay(last_oxy_overlay)
damageoverlay.CutOverlays(last_oxy_overlay)
last_oxy_overlay = null
//Fevers
@@ -4,7 +4,7 @@
if(species)
species.handle_login_special(src)
if(client)
cut_overlay(image('icons/effects/effects.dmi', "zzz_glow"))
CutOverlays(image('icons/effects/effects.dmi', "zzz_glow"))
var/datum/antagonist/antag = player_is_antag(mind, FALSE)
if(antag)
antag.handle_latelogin(src)
@@ -3,4 +3,4 @@
if(species)
species.handle_logout_special(src)
if(mind && mind.active && stat != DEAD)
add_overlay(image('icons/effects/effects.dmi', icon_state = "zzz_glow"))
AddOverlays(image('icons/effects/effects.dmi', icon_state = "zzz_glow"))
@@ -112,12 +112,12 @@ There are several things that need to be remembered:
return // No point.
update_hud() //TODO: remove the need for this
cut_overlays()
ClearOverlays()
if(cloaked)
icon = 'icons/mob/human.dmi'
icon_state = "body_cloaked"
add_overlay(list(overlays_raw[L_HAND_LAYER], overlays_raw[R_HAND_LAYER]))
AddOverlays(list(overlays_raw[L_HAND_LAYER], overlays_raw[R_HAND_LAYER]))
else if (icon_update)
if (icon != stand_icon)
@@ -137,7 +137,7 @@ There are several things that need to be remembered:
var/icon/aura_overlay = icon(A.icon, icon_state = A.icon_state)
ovr += aura_overlay
add_overlay(ovr)
AddOverlays(ovr)
if (((lying_prev != lying) || forceDirUpdate || size_multiplier != 1) && forceDirUpdate != UPDATE_ICON_IGNORE_DIRECTION_UPDATE)
if(lying && !species.prone_icon) //Only rotate them if we're not drawing a specific icon for being prone.
@@ -166,7 +166,7 @@ There are several things that need to be remembered:
M.Translate(0, 16*(size_multiplier-1))
animate(src, transform = M, time = ANIM_LYING_TIME)
compile_overlays()
UpdateOverlays()
lying_prev = lying
/mob/living/carbon/human/proc/HeldObjectDirTransform(var/hand = slot_l_hand, var/direction)
@@ -402,8 +402,8 @@ There are several things that need to be remembered:
part.cut_additional_images(src)
var/list/add_images = part.get_additional_images(src)
if(add_images)
add_overlay(add_images, TRUE)
compile_overlays()
AddOverlays(add_images, ATOM_ICON_CACHE_PROTECTED)
UpdateOverlays()
//END CACHED ICON GENERATION.
stand_icon.Blend(base_icon,ICON_OVERLAY)
@@ -135,7 +135,7 @@
. = ..()
var/mutable_appearance/filling = mutable_appearance(icon, "[icon_state]-100")
filling.color = COLOR_PINK
add_overlay(filling)
AddOverlays(filling)
/obj/item/docility_serum/attack(mob/living/carbon/slime/M as mob, mob/user as mob)
if(!istype(M, /mob/living/carbon/slime/))//If target is not a slime.
@@ -178,7 +178,7 @@
. = ..()
var/mutable_appearance/filling = mutable_appearance(icon, "[icon_state]-100")
filling.color = COLOR_PALE_PINK
add_overlay(filling)
AddOverlays(filling)
/obj/item/advanced_docility_serum/attack(mob/living/carbon/slime/M as mob, mob/user as mob)
if(!istype(M, /mob/living/carbon/slime/))//If target is not a slime.
@@ -226,7 +226,7 @@
var/mutable_appearance/filling = mutable_appearance(icon, "[icon_state]-100")
filling.color = COLOR_GREEN
add_overlay(filling)
AddOverlays(filling)
return INITIALIZE_HINT_NORMAL
@@ -265,7 +265,7 @@
var/mutable_appearance/filling = mutable_appearance(icon, "[icon_state]-100")
filling.color = COLOR_BLUE
add_overlay(filling)
AddOverlays(filling)
return INITIALIZE_HINT_NORMAL
@@ -26,15 +26,15 @@
. += FONT_SMALL(SPAN_WARNING("It is currently processing <b>[length(extract_slimes)] slime\s</b>."))
/obj/machinery/slime_extractor/update_icon()
cut_overlays()
ClearOverlays()
if(panel_open)
var/mutable_appearance/panel_overlay = mutable_appearance(icon, "[icon_state]-panel")
add_overlay(panel_overlay)
AddOverlays(panel_overlay)
if(length(extract_slimes))
var/mutable_appearance/interior_overlay = mutable_appearance(icon, "[icon_state]-interior", plane = EFFECTS_ABOVE_LIGHTING_PLANE)
add_overlay(interior_overlay)
AddOverlays(interior_overlay)
var/mutable_appearance/spinning_overlay = mutable_appearance(icon, "[icon_state]-running", plane = EFFECTS_ABOVE_LIGHTING_PLANE)
add_overlay(spinning_overlay)
AddOverlays(spinning_overlay)
set_light(2.5, 1, COLOR_VIOLET)
else
set_light(FALSE)
@@ -3,7 +3,7 @@
icon_state = "[colour] baby slime dead"
else
icon_state = "[colour] [is_adult ? "adult" : "baby"] slime[victim ? "" : " eat"]"
cut_overlays()
ClearOverlays()
if(mood)
add_overlay("aslime-[mood]")
AddOverlays("aslime-[mood]")
..()
+1 -1
View File
@@ -1000,7 +1000,7 @@ default behaviour is:
for(var/aura in auras)
var/obj/aura/A = aura
var/icon/aura_overlay = icon(A.icon, icon_state = A.icon_state)
add_overlay(aura_overlay)
AddOverlays(aura_overlay)
/mob/living/proc/add_aura(var/obj/aura/aura)
LAZYDISTINCTADD(auras, aura)
@@ -302,9 +302,9 @@
"emag" = image(icon, "[icon_state]-eyes_emag")
)
if(eye_overlay)
cut_overlay(eye_overlay)
CutOverlays(eye_overlay)
eye_overlay = cached_eye_overlays[a_intent]
add_overlay(eye_overlay)
AddOverlays(eye_overlay)
/mob/living/silicon/robot/drone/setup_panel_cache()
cached_panel_overlays = list(
@@ -316,10 +316,10 @@
/mob/living/silicon/robot/drone/set_intent(var/set_intent)
a_intent = set_intent
cut_overlay(eye_overlay)
CutOverlays(eye_overlay)
if(!stat)
eye_overlay = cached_eye_overlays[emagged ? "emag" : set_intent]
add_overlay(eye_overlay)
AddOverlays(eye_overlay)
/mob/living/silicon/robot/drone/choose_icon()
return
@@ -333,7 +333,7 @@
hat = new_hat
new_hat.forceMove(src)
hat_overlay = get_hat_icon(hat, hat_x_offset, hat_y_offset)
add_overlay(hat_overlay)
AddOverlays(hat_overlay)
//Drones cannot be upgraded with borg modules so we need to catch some items before they get used in ..().
/mob/living/silicon/robot/drone/attackby(obj/item/attacking_item, mob/user)
@@ -31,7 +31,7 @@
H.put_in_hands(hat)
H.visible_message(SPAN_WARNING("\The [H] removes \the [src]'s [hat]."))
hat = null
cut_overlay(hat_overlay)
CutOverlays(hat_overlay)
QDEL_NULL(hat_overlay)
update_icon()
else
@@ -8,10 +8,10 @@
/obj/item/borg/combat/shield/on_module_activate(mob/living/silicon/robot/R)
R.shield_overlay = image(R.icon, "[R.module_sprites[R.icontype][ROBOT_CHASSIS]]-shield")
R.add_overlay(R.shield_overlay)
R.AddOverlays(R.shield_overlay)
/obj/item/borg/combat/shield/on_module_deactivate(mob/living/silicon/robot/R)
R.cut_overlay(R.shield_overlay)
R.CutOverlays(R.shield_overlay)
/obj/item/borg/combat/shield/verb/set_shield_level()
set name = "Set shield level"
@@ -121,19 +121,19 @@
update_icon()
/obj/item/robot_parts/robot_suit/update_icon()
cut_overlays()
ClearOverlays()
if(l_arm)
add_overlay("l_arm+o")
AddOverlays("l_arm+o")
if(r_arm)
add_overlay("r_arm+o")
AddOverlays("r_arm+o")
if(chest)
add_overlay("chest+o")
AddOverlays("chest+o")
if(l_leg)
add_overlay("l_leg+o")
AddOverlays("l_leg+o")
if(r_leg)
add_overlay("r_leg+o")
AddOverlays("r_leg+o")
if(head)
add_overlay("head+o")
AddOverlays("head+o")
/obj/item/robot_parts/robot_suit/proc/check_completion()
if(l_arm && r_arm)
@@ -13,11 +13,11 @@
handle_regular_hud_updates()
update_items()
if(stat)
cut_overlay(eye_overlay)
CutOverlays(eye_overlay)
has_cut_eye_overlay = TRUE
else if(has_cut_eye_overlay)
eye_overlay = cached_eye_overlays[a_intent]
add_overlay(eye_overlay)
AddOverlays(eye_overlay)
has_cut_eye_overlay = null
if(stat != DEAD) //still using power
use_power()
@@ -322,12 +322,12 @@
return TRUE
/mob/living/silicon/robot/update_fire()
cut_overlay(image("icon" = 'icons/mob/burning/burning_generic.dmi', "icon_state" = "upper"))
cut_overlay(image("icon" = 'icons/mob/burning/burning_generic.dmi', "icon_state" = "lower"))
CutOverlays(image("icon" = 'icons/mob/burning/burning_generic.dmi', "icon_state" = "upper"))
CutOverlays(image("icon" = 'icons/mob/burning/burning_generic.dmi', "icon_state" = "lower"))
if(on_fire)
add_overlay(image("icon" = 'icons/mob/burning/burning_generic.dmi', "icon_state" = "upper"))
add_overlay(image("icon" = 'icons/mob/burning/burning_generic.dmi', "icon_state" = "lower"))
AddOverlays(image("icon" = 'icons/mob/burning/burning_generic.dmi', "icon_state" = "upper"))
AddOverlays(image("icon" = 'icons/mob/burning/burning_generic.dmi', "icon_state" = "lower"))
/mob/living/silicon/robot/fire_act()
if(!on_fire) // Silicons don't gain stacks from hotspots, but hotspots can ignite them.
@@ -512,7 +512,7 @@
set name = "Rebuild Overlays"
set desc = "An OOC tool that rebuilds your overlays, useful if your talk bubble gets stuck to you."
cut_overlays()
ClearOverlays()
handle_panel_overlay()
set_intent(a_intent)
@@ -1,16 +1,16 @@
/mob/living/silicon/robot/set_intent(var/set_intent)
a_intent = set_intent
cut_overlay(eye_overlay)
CutOverlays(eye_overlay)
if(!length(module_sprites))
return
if(!length(cached_eye_overlays))
setup_eye_cache()
if(!stat)
eye_overlay = cached_eye_overlays[a_intent]
add_overlay(eye_overlay)
AddOverlays(eye_overlay)
/mob/living/silicon/robot/proc/handle_panel_overlay()
cut_overlay(panel_overlay)
CutOverlays(panel_overlay)
if(!length(cached_panel_overlays))
setup_panel_cache()
if(opened)
@@ -20,7 +20,7 @@
panel_overlay = cached_panel_overlays[ROBOT_PANEL_CELL]
else
panel_overlay = cached_panel_overlays[ROBOT_PANEL_NO_CELL]
add_overlay(panel_overlay)
AddOverlays(panel_overlay)
/mob/living/silicon/robot/proc/setup_icon_cache()
if(!module_sprites[icontype])
@@ -46,10 +46,10 @@
I_HURT = image(icon, "[eyeprefix]-eyes_harm")
)
if(eye_overlay)
cut_overlay(eye_overlay)
CutOverlays(eye_overlay)
eye_overlay = cached_eye_overlays[a_intent]
eye_overlay.plane = eye_plane
add_overlay(eye_overlay)
AddOverlays(eye_overlay)
/mob/living/silicon/robot/proc/setup_panel_cache()
if(!length(module_sprites))
@@ -120,13 +120,13 @@
..()
/mob/living/simple_animal/construct/proc/add_glow()
cut_overlays()
ClearOverlays()
var/overlay_plane = EFFECTS_ABOVE_LIGHTING_PLANE
var/image/glow = image(icon, "glow-[icon_state]")
glow.plane = overlay_plane
add_overlay(glow)
AddOverlays(glow)
set_light(2, -2, l_color = COLOR_WHITE)
/mob/living/simple_animal/construct/Life()
@@ -88,7 +88,7 @@
..()
/mob/living/simple_animal/corgi/regenerate_icons()
cut_overlays()
ClearOverlays()
if(inventory_head)
var/head_icon_state = inventory_head.icon_state
@@ -97,7 +97,7 @@
var/icon/head_icon = image('icons/mob/corgi_head.dmi',head_icon_state)
if(head_icon)
add_overlay(head_icon)
AddOverlays(head_icon)
if(inventory_back)
var/back_icon_state = inventory_back.icon_state
@@ -106,7 +106,7 @@
var/icon/back_icon = image('icons/mob/corgi_back.dmi',back_icon_state)
if(back_icon)
add_overlay(back_icon)
AddOverlays(back_icon)
/mob/living/simple_animal/corgi/puppy
name = "corgi puppy"
@@ -58,7 +58,7 @@
/mob/living/simple_animal/rat/king/update_icon()
..()
cut_overlays()
ClearOverlays()
for(var/mob/living/simple_animal/rat/R in rats)
var/image/rat_overlay = image('icons/mob/npc/animal.dmi', "[R.icon_state]")
@@ -66,7 +66,7 @@
var/matrix/M = matrix()
M.Translate(rand(-6, 6), rand(-4, 8))
rat_overlay.transform = M
add_overlay(rat_overlay)
AddOverlays(rat_overlay)
/mob/living/simple_animal/rat/king/proc/update()
if( rats.len >= RAT_GOD_LEVEL)
@@ -46,7 +46,7 @@
/mob/living/simple_animal/adultslime/Initialize()
. = ..()
add_overlay("aslime-:33")
AddOverlays("aslime-:33")
/mob/living/simple_animal/adultslime/death()
@@ -52,16 +52,16 @@
screen_overlay = image('icons/mob/npc/ipc_zombie.dmi', "[screen]")
screen_overlay.plane = plane = EFFECTS_ABOVE_LIGHTING_PLANE
screen_overlay.appearance_flags = KEEP_APART
add_overlay(screen_overlay)
AddOverlays(screen_overlay)
set_light(MINIMUM_USEFUL_LIGHT_RANGE, 2, LIGHT_COLOR_TUNGSTEN)
/mob/living/simple_animal/hostile/ipc_zombie/update_icon()
cut_overlays()
ClearOverlays()
if(screen && stat != DEAD)
screen_overlay = image('icons/mob/npc/ipc_zombie.dmi', "[screen]")
screen_overlay.plane = EFFECTS_ABOVE_LIGHTING_PLANE
screen_overlay.appearance_flags = KEEP_APART
add_overlay(screen_overlay)
AddOverlays(screen_overlay)
/mob/living/simple_animal/hostile/ipc_zombie/death()
..()
@@ -169,7 +169,7 @@
name = initial(name)
icon = initial(icon)
icon_state = initial(icon_state)
cut_overlays()
ClearOverlays()
overlays = null
//Baseline stats
@@ -30,7 +30,7 @@
eye_overlay = image(icon, "[icon_state]-eyes_emag")
eye_overlay.plane = EFFECTS_ABOVE_LIGHTING_PLANE
eye_overlay.appearance_flags = KEEP_APART
add_overlay(eye_overlay)
AddOverlays(eye_overlay)
/mob/living/simple_animal/hostile/rogue_drone/CanPass(atom/movable/mover, turf/target, height, air_group)
. = ..()
@@ -180,12 +180,12 @@
eye_overlay = image(icon, "eel_eyeglow")
eye_overlay.plane = EFFECTS_ABOVE_LIGHTING_PLANE
eye_overlay.appearance_flags = KEEP_APART
add_overlay(eye_overlay)
AddOverlays(eye_overlay)
set_light(MINIMUM_USEFUL_LIGHT_RANGE, 2, LIGHT_COLOR_TUNGSTEN)
/mob/living/simple_animal/hostile/carp/shark/reaver/eel/death()
. = ..()
cut_overlays()
ClearOverlays()
set_light(0)
/mob/living/simple_animal/hostile/carp/bloater
@@ -190,7 +190,7 @@
death()
/mob/living/simple_animal/Destroy()
cut_overlay(blood_overlay)
CutOverlays(blood_overlay)
movement_target = null
QDEL_NULL(udder)
@@ -404,7 +404,7 @@
if(force_reset || current_blood_state != blood_state)
if(blood_overlay)
cut_overlay(blood_overlay)
CutOverlays(blood_overlay)
if(blood_state == BLOOD_NONE)
return
var/blood_overlay_name = get_blood_overlay_name()
@@ -412,7 +412,7 @@
I.color = blood_type
I.blend_mode = BLEND_INSET_OVERLAY
blood_overlay = I
add_overlay(blood_overlay)
AddOverlays(blood_overlay)
/mob/living/simple_animal/proc/get_blood_overlay_name()
return "blood_overlay"