diff --git a/code/__DEFINES/atmospherics.dm b/code/__DEFINES/atmospherics.dm index fc7255140bf..cab223597eb 100644 --- a/code/__DEFINES/atmospherics.dm +++ b/code/__DEFINES/atmospherics.dm @@ -535,6 +535,18 @@ out_var += cached_gases[total_moles_id][MOLES];\ } +GLOBAL_LIST_INIT(nonoverlaying_gases, typecache_of_gases_with_no_overlays()) +#define GAS_OVERLAYS(gases, out_var)\ + out_var = list();\ + for(var/_ID in gases){\ + if(GLOB.nonoverlaying_gases[_ID]) continue;\ + var/_GAS = gases[_ID];\ + var/_GAS_META = _GAS[GAS_META];\ + if(_GAS[MOLES] <= _GAS_META[META_GAS_MOLES_VISIBLE]) continue;\ + var/_GAS_OVERLAY = _GAS_META[META_GAS_OVERLAY];\ + out_var += _GAS_OVERLAY[min(TOTAL_VISIBLE_STATES, CEILING(_GAS[MOLES] / MOLES_GAS_VISIBLE_STEP, 1))];\ + } + #ifdef TESTING GLOBAL_LIST_INIT(atmos_adjacent_savings, list(0,0)) #define CALCULATE_ADJACENT_TURFS(T, state) if (SSadjacent_air.queue[T]) { GLOB.atmos_adjacent_savings[1] += 1 } else { GLOB.atmos_adjacent_savings[2] += 1; SSadjacent_air.queue[T] = state} diff --git a/code/datums/greyscale/json_configs/canister_default.json b/code/datums/greyscale/json_configs/canister_default.json index 7ce97efcc57..b965e9ec3fd 100644 --- a/code/datums/greyscale/json_configs/canister_default.json +++ b/code/datums/greyscale/json_configs/canister_default.json @@ -12,5 +12,13 @@ "blend_mode": "overlay", "color_ids": [ 1 ] } + ], + "window-base": [ + { + "type": "icon_state", + "icon_state": "window-base", + "blend_mode": "overlay", + "color_ids": [ 1 ] + } ] } diff --git a/code/datums/greyscale/json_configs/canister_double_stripe.json b/code/datums/greyscale/json_configs/canister_double_stripe.json index 914f7102719..33dd115d3ea 100644 --- a/code/datums/greyscale/json_configs/canister_double_stripe.json +++ b/code/datums/greyscale/json_configs/canister_double_stripe.json @@ -25,5 +25,13 @@ "blend_mode": "overlay", "color_ids": [ 1 ] } + ], + "window-base": [ + { + "type": "icon_state", + "icon_state": "window-base", + "blend_mode": "overlay", + "color_ids": [ 1 ] + } ] } diff --git a/code/datums/greyscale/json_configs/canister_hazard.json b/code/datums/greyscale/json_configs/canister_hazard.json index 5bd07b49d4c..81c19362231 100644 --- a/code/datums/greyscale/json_configs/canister_hazard.json +++ b/code/datums/greyscale/json_configs/canister_hazard.json @@ -18,5 +18,13 @@ "blend_mode": "overlay", "color_ids": [ 1 ] } + ], + "window-base": [ + { + "type": "icon_state", + "icon_state": "window-base", + "blend_mode": "overlay", + "color_ids": [ 1 ] + } ] } diff --git a/code/datums/greyscale/json_configs/canister_stripe.json b/code/datums/greyscale/json_configs/canister_stripe.json index 0fe05bf9112..9e5f087c0ae 100644 --- a/code/datums/greyscale/json_configs/canister_stripe.json +++ b/code/datums/greyscale/json_configs/canister_stripe.json @@ -18,5 +18,13 @@ "blend_mode": "overlay", "color_ids": [ 1 ] } + ], + "window-base": [ + { + "type": "icon_state", + "icon_state": "window-base", + "blend_mode": "overlay", + "color_ids": [ 1 ] + } ] } diff --git a/code/modules/atmospherics/environmental/LINDA_turf_tile.dm b/code/modules/atmospherics/environmental/LINDA_turf_tile.dm index 30d0ba1dcd7..9462696466c 100644 --- a/code/modules/atmospherics/environmental/LINDA_turf_tile.dm +++ b/code/modules/atmospherics/environmental/LINDA_turf_tile.dm @@ -139,10 +139,7 @@ /turf/open/proc/update_visuals() - var/list/atmos_overlay_types = src.atmos_overlay_types // Cache for free performance - var/list/new_overlay_types = list() - var/static/list/nonoverlaying_gases = typecache_of_gases_with_no_overlays() if(!air) // 2019-05-14: was not able to get this path to fire in testing. Consider removing/looking at callers -Naksu if (atmos_overlay_types) @@ -153,14 +150,8 @@ var/list/gases = air.gases - for(var/id in gases) - if (nonoverlaying_gases[id]) - continue - var/gas = gases[id] - var/gas_meta = gas[GAS_META] - var/gas_overlay = gas_meta[META_GAS_OVERLAY] - if(gas_overlay && gas[MOLES] > gas_meta[META_GAS_MOLES_VISIBLE]) - new_overlay_types += gas_overlay[min(TOTAL_VISIBLE_STATES, CEILING(gas[MOLES] / MOLES_GAS_VISIBLE_STEP, 1))] + var/list/new_overlay_types + GAS_OVERLAYS(gases, new_overlay_types) if (atmos_overlay_types) for(var/overlay in atmos_overlay_types-new_overlay_types) //doesn't remove overlays that would only be added diff --git a/code/modules/atmospherics/gasmixtures/gas_mixture.dm b/code/modules/atmospherics/gasmixtures/gas_mixture.dm index 981e78a8f40..1165c636734 100644 --- a/code/modules/atmospherics/gasmixtures/gas_mixture.dm +++ b/code/modules/atmospherics/gasmixtures/gas_mixture.dm @@ -133,6 +133,12 @@ GLOBAL_LIST_INIT(gaslist_cache, init_gaslist_cache()) /datum/gas_mixture/proc/return_volume() return max(0, volume) +/// Gets the gas visuals for everything in this mixture +/datum/gas_mixture/proc/return_visuals() + var/list/output + GAS_OVERLAYS(gases, output) + return output + /// Calculate thermal energy in joules /datum/gas_mixture/proc/thermal_energy() return THERMAL_ENERGY(src) //see code/__DEFINES/atmospherics.dm; use the define in performance critical areas diff --git a/code/modules/atmospherics/machinery/portable/canister.dm b/code/modules/atmospherics/machinery/portable/canister.dm index 23c5669cf3b..9a4097fecd0 100644 --- a/code/modules/atmospherics/machinery/portable/canister.dm +++ b/code/modules/atmospherics/machinery/portable/canister.dm @@ -90,6 +90,8 @@ GLOBAL_LIST_INIT(gas_id_to_canister, init_gas_id_to_canister()) var/restricted = FALSE ///Set the tier of the canister and overlay used var/mode = CANISTER_TIER_1 + ///Window overlay showing the gas inside the canister + var/image/window /obj/machinery/portable_atmospherics/canister/Initialize(mapload, datum/gas_mixture/existing_mixture) . = ..() @@ -99,6 +101,8 @@ GLOBAL_LIST_INIT(gas_id_to_canister, init_gas_id_to_canister()) else create_gas() + update_window() + var/random_quality = rand() pressure_limit = initial(pressure_limit) * (1 + 0.2 * random_quality) @@ -400,7 +404,9 @@ GLOBAL_LIST_INIT(gas_id_to_canister, init_gas_id_to_canister()) if(connected_port) . += mutable_appearance(canister_overlay_file, "can-connector") - switch(air_contents.return_pressure()) + var/air_pressure = air_contents.return_pressure() + + switch(air_pressure) if((40 * ONE_ATMOSPHERE) to INFINITY) . += mutable_appearance(canister_overlay_file, "can-3") if((10 * ONE_ATMOSPHERE) to (40 * ONE_ATMOSPHERE)) @@ -410,6 +416,28 @@ GLOBAL_LIST_INIT(gas_id_to_canister, init_gas_id_to_canister()) if((10) to (5 * ONE_ATMOSPHERE)) . += mutable_appearance(canister_overlay_file, "can-0") + update_window() + +/obj/machinery/portable_atmospherics/canister/update_greyscale() + . = ..() + update_window() + +/obj/machinery/portable_atmospherics/canister/proc/update_window() + if(!air_contents) + return + var/static/alpha_filter + if(!alpha_filter) // Gotta do this seperate since the icon may not be correct at world init + alpha_filter = filter(type="alpha", icon=icon(icon, "window-base")) + + cut_overlay(window) + window = image(icon, icon_state="window-base", layer=FLOAT_LAYER) + var/list/window_overlays = list() + for(var/visual in air_contents.return_visuals()) + var/image/new_visual = image(visual, layer=FLOAT_PLANE) + new_visual.filters = alpha_filter + window_overlays += new_visual + window.overlays = window_overlays + add_overlay(window) /obj/machinery/portable_atmospherics/canister/should_atmos_process(datum/gas_mixture/air, exposed_temperature) return exposed_temperature > temperature_resistance * mode diff --git a/icons/obj/atmospherics/canisters.dmi b/icons/obj/atmospherics/canisters.dmi index 385914d1979..065290481a5 100644 Binary files a/icons/obj/atmospherics/canisters.dmi and b/icons/obj/atmospherics/canisters.dmi differ