Adds canister windows (#58826)

This commit is contained in:
Emmett Gaines
2021-05-03 05:15:14 -07:00
committed by GitHub
parent b66f1676bc
commit 45630da55e
9 changed files with 81 additions and 12 deletions
+12
View File
@@ -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}
@@ -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 ]
}
]
}
@@ -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 ]
}
]
}
@@ -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 ]
}
]
}
@@ -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 ]
}
]
}
@@ -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
@@ -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
@@ -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
Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB