Miscellaneous ZAS Fixes and Optimizations (#8396)

This commit is contained in:
Guti
2024-05-14 23:08:27 +02:00
committed by GitHub
parent 4fcfe6c82e
commit 932e21e7d3
7 changed files with 230 additions and 16 deletions
+20 -4
View File
@@ -40,17 +40,33 @@
gas_data.specific_heat[gas.id] = gas.specific_heat
gas_data.molar_mass[gas.id] = gas.molar_mass
if(gas.tile_overlay)
gas_data.tile_overlay[gas.id] = new /atom/movable/gas_visuals(null, gas.tile_overlay)
if(gas.overlay_limit)
gas_data.tile_overlay[gas.id] = gas.tile_overlay // CHOMPEdit
if(gas.overlay_limit)
gas_data.overlay_limit[gas.id] = gas.overlay_limit
gas_data.flags[gas.id] = gas.flags
return 1
/atom/movable/gas_visuals
// CHOMPEdit Start
/obj/effect/gas_overlay
name = "gas"
desc = "You shouldn't be clicking this."
icon = 'icons/effects/tile_effects.dmi'
icon_state = "generic"
layer = GASFIRE_LAYER
appearance_flags = PIXEL_SCALE | RESET_COLOR
mouse_opacity = 0
/*
plane = ABOVE_MOB_PLANE
/atom/movable/gas_visuals/New(newloc, ico)
..()
icon_state = ico
icon_state = ico
*/
var/gas_id
/obj/effect/gas_overlay/Initialize(mapload, gas)
. = ..()
gas_id = gas
if(gas_data.tile_overlay[gas_id])
icon_state = gas_data.tile_overlay[gas_id]
// CHOMPEdit End
+27 -3
View File
@@ -13,7 +13,9 @@
var/group_multiplier = 1
//List of active tile overlays for this gas_mixture. Updated by check_tile_graphic()
var/list/graphic
var/list/graphic = list() // CHOMPAdd
var/list/tile_overlay_cache // COMPAdd
/datum/gas_mixture/New(vol = CELL_VOLUME)
volume = vol
@@ -334,11 +336,13 @@
zburn(null, force_burn=0, no_check=0) //could probably just call zburn() here with no args but I like being explicit.
// CHOMPEdit Start
//Rechecks the gas_mixture and adjusts the graphic list if needed.
//Two lists can be passed by reference if you need know specifically which graphics were added and removed.
/datum/gas_mixture/proc/check_tile_graphic(list/graphic_add = null, list/graphic_remove = null)
var/list/cur_graphic = graphic // Cache for sanic speed
// var/list/cur_graphic = graphic // Cache for sanic speed
for(var/g in gas_data.overlay_limit)
/*
if(cur_graphic && cur_graphic.Find(gas_data.tile_overlay[g]))
//Overlay is already applied for this gas, check if it's still valid.
if(gas[g] <= gas_data.overlay_limit[g])
@@ -347,7 +351,14 @@
//Overlay isn't applied for this gas, check if it's valid and needs to be added.
if(gas[g] > gas_data.overlay_limit[g])
LAZYADD(graphic_add, gas_data.tile_overlay[g])
*/
if(gas[g] > gas_data.overlay_limit[g])
var/tile_overlay = get_tile_overlay(g)
if(!(tile_overlay in graphic))
LAZYADD(graphic_add, tile_overlay)
. = FALSE
/*
. = 0
//Apply changes
if(LAZYLEN(graphic_add))
@@ -356,7 +367,14 @@
if(LAZYLEN(graphic_remove))
LAZYREMOVE(graphic, graphic_remove)
. = 1
*/
if(graphic_add && graphic_add.len)
graphic |= graphic_add
. = TRUE
if(graphic_remove && graphic_remove.len)
graphic -= graphic_remove
. = TRUE
// CHOMPEdit End
//Simpler version of merge(), adjusts gas amounts directly and doesn't account for temperature or group_multiplier.
/datum/gas_mixture/proc/add(datum/gas_mixture/right_side)
@@ -375,6 +393,12 @@
update_values()
return 1
// Gets the gas overlay for a given gas, and returns the appropriate overlay. Caches. - CHOMPADD
/datum/gas_mixture/proc/get_tile_overlay(gas_id)
if(!LAZYACCESS(tile_overlay_cache, gas_id))
LAZYSET(tile_overlay_cache, gas_id, new/obj/effect/gas_overlay(null, gas_id))
return tile_overlay_cache[gas_id]
//Multiply all gas amounts by a factor.
/datum/gas_mixture/proc/multiply(factor)