Skip to content

Commit

Permalink
[MIRROR] Makes gas visuals send less assets [MDB IGNORE] (#25213)
Browse files Browse the repository at this point in the history
* Makes gas visuals send less assets (#78955)

![Discord_2023-10-12_13-21-06](https://github.com/tgstation/tgstation/assets/1234602/e13cb015-dd94-48d9-a593-4258609049d1)

~~I'll see how this works out for the downstream, if it improves the
situation for them I'll check the profiler to see how much it affects
performance.~~

This reduces assets that need to be sent to the client, how much is hard
to tell but a downstream that was having issues due to it got reduced
issues when testing with this. Server side costs are roughly equivalent
now that I switched to using a straight color in the color matrix
filter.

* Makes gas visuals send less assets

---------

Co-authored-by: Emmett Gaines <[email protected]>
  • Loading branch information
2 people authored and FFMirrorBot committed Nov 23, 2023
1 parent 6edd548 commit 87ee2f4
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 6 deletions.
12 changes: 12 additions & 0 deletions code/__HELPERS/colors.dm
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,18 @@

return final_color

/// Given a color in the format of "#RRGGBB" or "#RRGGBBAA", gives back a 4 entry list with the number values of each
/proc/split_color(color)
var/list/output = list()
output += hex2num(copytext(color, 2, 4))
output += hex2num(copytext(color, 4, 6))
output += hex2num(copytext(color, 6, 8))
if(length(color) == 9)
output += hex2num(copytext(color, 8, 10))
else
output += 255
return output

///Returns a random color picked from a list, has 2 modes (0 and 1), mode 1 doesn't pick white, black or gray
/proc/random_colour(mode = 0)
switch(mode)
Expand Down
31 changes: 25 additions & 6 deletions code/modules/atmospherics/machinery/datum_pipeline.dm
Original file line number Diff line number Diff line change
Expand Up @@ -325,20 +325,18 @@
if(gas_visuals[icon_file])
return gas_visuals[icon_file]

var/obj/effect/abstract/new_overlay = new
var/obj/effect/abstract/gas_visual/new_overlay = new
new_overlay.icon = icon_file
new_overlay.appearance_flags = RESET_COLOR | KEEP_APART
new_overlay.vis_flags = VIS_INHERIT_ICON_STATE | VIS_INHERIT_LAYER | VIS_INHERIT_PLANE | VIS_INHERIT_ID
new_overlay.color = gasmix_color
new_overlay.ChangeColor(gasmix_color)

gas_visuals[icon_file] = new_overlay
return new_overlay

/// Called when the gasmix color has changed and the gas visuals need to be updated.
/datum/pipeline/proc/UpdateGasVisuals()
for(var/icon/source as anything in gas_visuals)
var/obj/effect/abstract/overlay = gas_visuals[source]
animate(overlay, time=5, color=gasmix_color)
var/obj/effect/abstract/gas_visual/overlay = gas_visuals[source]
overlay.ChangeColor(gasmix_color)

/// After updating, this proc handles looking at the new gas mixture and blends the colors together according to percentage of the gas mix.
/datum/pipeline/proc/CalculateGasmixColor(datum/gas_mixture/source)
Expand Down Expand Up @@ -370,3 +368,24 @@
if(gasmix_color != current_color)
gasmix_color = current_color
UpdateGasVisuals()

/obj/effect/abstract/gas_visual
appearance_flags = RESET_COLOR | KEEP_APART
vis_flags = VIS_INHERIT_ICON_STATE | VIS_INHERIT_LAYER | VIS_INHERIT_PLANE | VIS_INHERIT_ID
var/current_color
var/color_filter

/obj/effect/abstract/gas_visual/Initialize(mapload)
. = ..()
color_filter = filter(type="color", color=matrix())
filters += color_filter
color_filter = filters[filters.len]
if(current_color)
animate(color_filter, color=current_color, time=5)

/obj/effect/abstract/gas_visual/proc/ChangeColor(new_color)
current_color = new_color
if(isnull(color_filter))
// Called before init
return
animate(color_filter, time=5, color=new_color)

0 comments on commit 87ee2f4

Please sign in to comment.