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
@@ -149,13 +149,13 @@
ammo_picture.pixel_x = rand(-6, 6)
ammo_picture.pixel_y = rand(-6, 6)
ammo_overlay[bullet] = ammo_picture
add_overlay(ammo_overlay[bullet])
AddOverlays(ammo_overlay[bullet])
/obj/item/ammo_pile/proc/remove_ammo(var/atom/target)
var/obj/bullet = ammo[1]
if(target)
bullet.forceMove(target)
cut_overlay(ammo_overlay[bullet])
CutOverlays(ammo_overlay[bullet])
ammo -= bullet
check_ammo()
+2 -2
View File
@@ -198,11 +198,11 @@
underlays += I
if(has_safety)
cut_overlay(safety_overlay, TRUE)
CutOverlays(safety_overlay, ATOM_ICON_CACHE_PROTECTED)
safety_overlay = null
if(!isturf(loc)) // In a mob, holster or bag or something
safety_overlay = image(gun_gui_icons,"[safety()]")
add_overlay(safety_overlay, TRUE)
AddOverlays(safety_overlay, ATOM_ICON_CACHE_PROTECTED)
if(is_wieldable)
if(wielded)
+2 -2
View File
@@ -39,12 +39,12 @@
else
src.visible_message("<span class='danger'>A flag pops out of the barrel of \the [src.name]'s barrel!</span>")
playsound(src, fire_sound, 20, 1)
src.add_overlay(bang_flag)
src.AddOverlays(bang_flag)
fired_gun = 1
/obj/item/gun/bang/attack_hand(mob/user as mob)
if(user.get_inactive_hand() == src && fired_gun)
src.cut_overlay(bang_flag)
src.CutOverlays(bang_flag)
user.visible_message("<span class='notice'>\The [user] pushes the flag back into the barrel of \the [src.name].</span>", "<span class='notice'>You push the flag back into the barrel of \the [src.name].</span>")
playsound(src.loc, 'sound/weapons/TargetOff.ogg', 50,1)
fired_gun = 0
@@ -93,33 +93,33 @@
/obj/item/gun/energy/gun/nuclear/proc/update_charge()
if (crit_fail)
add_overlay("nucgun-whee")
AddOverlays("nucgun-whee")
return
var/ratio = max((power_supply?.charge / power_supply?.maxcharge), 0)
ratio = round(ratio, 0.25) * 100
add_overlay("nucgun-[ratio]")
AddOverlays("nucgun-[ratio]")
/obj/item/gun/energy/gun/nuclear/proc/update_reactor()
if(crit_fail)
add_overlay("nucgun-crit")
AddOverlays("nucgun-crit")
return
if(lightfail)
add_overlay("nucgun-medium")
AddOverlays("nucgun-medium")
else if ((power_supply?.charge/power_supply?.maxcharge) <= 0.5)
add_overlay("nucgun-light")
AddOverlays("nucgun-light")
else
add_overlay("nucgun-clean")
AddOverlays("nucgun-clean")
/obj/item/gun/energy/gun/nuclear/proc/update_mode()
var/datum/firemode/current_mode = firemodes[sel_mode]
switch(current_mode.name)
if("stun")
add_overlay("nucgun-stun")
AddOverlays("nucgun-stun")
if("lethal")
add_overlay("nucgun-kill")
AddOverlays("nucgun-kill")
/obj/item/gun/energy/gun/nuclear/update_icon()
cut_overlays()
ClearOverlays()
update_charge()
update_reactor()
update_mode()
@@ -248,13 +248,13 @@
if(open_bolt && has_clip)
if(has_clip.stored_ammo.len > 0)
load_ammo(has_clip, user)
src.cut_overlays()
src.ClearOverlays()
if(!has_clip.stored_ammo.len)
add_overlay("springfield-clip-empty")
AddOverlays("springfield-clip-empty")
else if(has_clip.stored_ammo.len <= 3)
add_overlay("springfield-clip-half")
AddOverlays("springfield-clip-half")
else
add_overlay("springfield-clip-full")
AddOverlays("springfield-clip-full")
else
to_chat(user, "<span class='warning'>There is no ammo in \the [has_clip.name]!</span>")
else if(!open_bolt)
@@ -278,7 +278,7 @@
if(has_clip)
has_clip.forceMove(get_turf(src))
has_clip = null
cut_overlays()
ClearOverlays()
if(chambered)//We have a shell in the chamber
@@ -302,11 +302,11 @@
has_clip = attacking_item
to_chat(user, "<span class='notice'>You load the clip into \the [src].</span>")
if(!has_clip.stored_ammo.len)
add_overlay("springfield-clip-empty")
AddOverlays("springfield-clip-empty")
else if(has_clip.stored_ammo.len <= 3)
add_overlay("springfield-clip-half")
AddOverlays("springfield-clip-half")
else
add_overlay("springfield-clip-full")
AddOverlays("springfield-clip-full")
else
to_chat(user, "<span class='notice'>There's already a clip in \the [src].</span>")