mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2026-08-26 14:31:59 +01:00
516 Renderer update (#20579)
Updated the renderers to work with BYOND 516. Some update of ZAS to hopefully be more efficient, and cold/hot air effects. Gas effects are now less prominent. Ported from Bay
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/var/datum/xgm_gas_data/gas_data
|
||||
var/global/datum/xgm_gas_data/gas_data
|
||||
|
||||
/datum/xgm_gas_data
|
||||
//Simple list of all the gas IDs.
|
||||
@@ -9,7 +9,7 @@
|
||||
var/list/specific_heat = list()
|
||||
//Molar mass of the gas. Used for calculating specific entropy.
|
||||
var/list/molar_mass = list()
|
||||
//Tile overlays. /obj/effect/gas_overlay, created from references to 'icons/effects/tile_effects.dmi'
|
||||
//Tile overlays. /obj/gas_overlay, created from references to 'icons/effects/tile_effects.dmi'
|
||||
var/list/tile_overlay = list()
|
||||
//Optional color for tile overlay
|
||||
var/list/tile_overlay_color = list()
|
||||
@@ -36,7 +36,7 @@
|
||||
var/singleton/xgm_gas/gas = new p //avoid initial() because of potential New() actions
|
||||
|
||||
if(gas.id in gas_data.gases)
|
||||
log_world("ERROR: Duplicate gas id `[gas.id]` in `[p]`")
|
||||
stack_trace("ERROR: Duplicate gas id `[gas.id]` in `[p]`")
|
||||
|
||||
gas_data.gases += gas.id
|
||||
gas_data.name[gas.id] = gas.name
|
||||
@@ -44,27 +44,62 @@
|
||||
gas_data.molar_mass[gas.id] = gas.molar_mass
|
||||
if(gas.overlay_limit)
|
||||
gas_data.overlay_limit[gas.id] = gas.overlay_limit
|
||||
var/obj/effect/gas_overlay/I = new()
|
||||
if(gas.tile_overlay)
|
||||
I.icon_state = gas.tile_overlay
|
||||
if(gas.tile_color)
|
||||
gas_data.tile_overlay_color[gas.id] = gas.tile_color
|
||||
I.color = gas.tile_color
|
||||
gas_data.tile_overlay[gas.id] = I
|
||||
gas_data.tile_overlay[gas.id] = gas.tile_overlay
|
||||
gas_data.tile_overlay_color[gas.id] = gas.tile_color
|
||||
gas_data.flags[gas.id] = gas.flags
|
||||
|
||||
return 1
|
||||
|
||||
/obj/effect/gas_overlay
|
||||
/obj/gas_overlay
|
||||
name = "gas"
|
||||
desc = DESC_PARENT
|
||||
desc = "You shouldn't be clicking this."
|
||||
icon = 'icons/effects/tile_effects.dmi'
|
||||
icon_state = "generic"
|
||||
layer = FIRE_LAYER
|
||||
appearance_flags = RESET_COLOR
|
||||
mouse_opacity = MOUSE_OPACITY_TRANSPARENT
|
||||
appearance_flags = DEFAULT_APPEARANCE_FLAGS | RESET_COLOR
|
||||
mouse_opacity = 0
|
||||
var/gas_id
|
||||
|
||||
/obj/effect/gas_overlay/Initialize()
|
||||
/obj/gas_overlay/proc/update_alpha_animation(new_alpha)
|
||||
animate(src, alpha = new_alpha)
|
||||
alpha = new_alpha
|
||||
animate(src, alpha = 0.8 * new_alpha, time = 10, easing = SINE_EASING | EASE_OUT, loop = -1)
|
||||
animate(alpha = new_alpha, time = 10, easing = SINE_EASING | EASE_IN, loop = -1)
|
||||
|
||||
/obj/gas_overlay/Initialize(mapload, gas)
|
||||
. = ..()
|
||||
animate(src, alpha = 175, time = 10, easing = SINE_EASING | EASE_OUT, loop = -1)
|
||||
animate(alpha = 255, time = 10, easing = SINE_EASING | EASE_IN, loop = -1)
|
||||
gas_id = gas
|
||||
if(gas_data.tile_overlay[gas_id])
|
||||
icon_state = gas_data.tile_overlay[gas_id]
|
||||
color = gas_data.tile_overlay_color[gas_id]
|
||||
|
||||
/obj/gas_overlay/heat
|
||||
name = "gas"
|
||||
desc = "You shouldn't be clicking this."
|
||||
plane = HEAT_EFFECT_PLANE
|
||||
gas_id = GAS_HEAT
|
||||
render_source = HEAT_EFFECT_TARGET
|
||||
|
||||
/obj/gas_overlay/heat/Initialize(mapload, gas)
|
||||
. = ..()
|
||||
icon = null
|
||||
icon_state = null
|
||||
|
||||
/obj/effect/gas_cold_back
|
||||
render_source = COLD_EFFECT_BACK_TARGET
|
||||
plane = DEFAULT_PLANE
|
||||
layer = BELOW_OBJ_LAYER
|
||||
|
||||
/obj/gas_overlay/cold
|
||||
name = "gas"
|
||||
desc = "You shouldn't be clicking this."
|
||||
gas_id = GAS_COLD
|
||||
render_source = COLD_EFFECT_TARGET
|
||||
var/obj/effect/gas_cold_back/b = null
|
||||
|
||||
/obj/gas_overlay/cold/Initialize(mapload, gas)
|
||||
. = ..()
|
||||
icon = null
|
||||
icon_state = null
|
||||
b = new()
|
||||
vis_contents += b
|
||||
|
||||
@@ -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()
|
||||
//Cache of gas overlay objects
|
||||
var/list/tile_overlay_cache
|
||||
|
||||
/datum/gas_mixture/New(_volume = CELL_VOLUME, _temperature = 0, _group_multiplier = 1)
|
||||
volume = _volume
|
||||
@@ -353,32 +355,73 @@
|
||||
zburn(null, force_burn=0, no_check=0) //could probably just call zburn() here with no args but I like being explicit.
|
||||
|
||||
|
||||
///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.
|
||||
//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)
|
||||
for(var/obj/gas_overlay/O in graphic)
|
||||
if(istype(O, /obj/gas_overlay/heat))
|
||||
continue
|
||||
if(istype(O, /obj/gas_overlay/cold))
|
||||
continue
|
||||
if(gas[O.gas_id] <= gas_data.overlay_limit[O.gas_id])
|
||||
LAZYADD(graphic_remove, O)
|
||||
for(var/g in gas_data.overlay_limit)
|
||||
if (graphic && graphic[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])
|
||||
LAZYADD(graphic_remove, gas_data.tile_overlay[g])
|
||||
else
|
||||
//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])
|
||||
if(!(gas_data.tile_overlay[g] in graphic))
|
||||
LAZYADD(graphic_add, gas_data.tile_overlay[g])
|
||||
|
||||
//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])
|
||||
var/tile_overlay = get_tile_overlay(g)
|
||||
if(!(tile_overlay in graphic))
|
||||
LAZYADD(graphic_add, tile_overlay)
|
||||
. = 0
|
||||
|
||||
var/heat_overlay = get_tile_overlay(GAS_HEAT)
|
||||
//If it's hot add something
|
||||
if(temperature >= CARBON_LIFEFORM_FIRE_RESISTANCE)
|
||||
if(!(heat_overlay in graphic))
|
||||
LAZYADD(graphic_add, heat_overlay)
|
||||
else if (heat_overlay in graphic)
|
||||
LAZYADD(graphic_remove, heat_overlay)
|
||||
|
||||
var/cold_overlay = get_tile_overlay(GAS_COLD)
|
||||
if(temperature <= FOGGING_TEMPERATURE && (return_pressure() >= (ONE_ATMOSPHERE / 4)))
|
||||
if(!(cold_overlay in graphic))
|
||||
LAZYADD(graphic_add, cold_overlay)
|
||||
else if (cold_overlay in graphic)
|
||||
LAZYADD(graphic_remove, cold_overlay)
|
||||
|
||||
//Apply changes
|
||||
if(graphic_add && LAZYLEN(graphic_add))
|
||||
LAZYINITLIST(graphic)
|
||||
for (var/entry in graphic_add)
|
||||
graphic[entry] = TRUE // This is an assoc list to make checking it a bit faster.
|
||||
if(graphic_add && length(graphic_add))
|
||||
graphic |= graphic_add
|
||||
. = 1
|
||||
if(graphic_add && LAZYLEN(graphic_remove))
|
||||
if(graphic_remove && length(graphic_remove))
|
||||
graphic -= graphic_remove
|
||||
. = 1
|
||||
if(length(graphic))
|
||||
var/pressure_mod = clamp(return_pressure() / ONE_ATMOSPHERE, 0, 2)
|
||||
for(var/obj/gas_overlay/O in graphic)
|
||||
if(istype(O, /obj/gas_overlay/heat)) //Heat based
|
||||
var/new_alpha = clamp(max(125, 255 * ((temperature - CARBON_LIFEFORM_FIRE_RESISTANCE) / CARBON_LIFEFORM_FIRE_RESISTANCE * 4)), 125, 255)
|
||||
if(new_alpha != O.alpha)
|
||||
O.update_alpha_animation(new_alpha)
|
||||
continue
|
||||
if(istype(O, /obj/gas_overlay/cold))
|
||||
var/new_alpha = clamp(max(125, 200 * (1 - ((temperature - MAX_FOG_TEMPERATURE) / (FOGGING_TEMPERATURE - MAX_FOG_TEMPERATURE)))), 125, 200)
|
||||
if(new_alpha != O.alpha)
|
||||
O.update_alpha_animation(new_alpha)
|
||||
continue
|
||||
var/concentration_mod = clamp(gas[O.gas_id] / total_moles, 0.1, 1)
|
||||
var/new_alpha = min(230, round(pressure_mod * concentration_mod * 180, 5))
|
||||
if(new_alpha != O.alpha)
|
||||
O.update_alpha_animation(new_alpha)
|
||||
|
||||
UNSETEMPTY(graphic)
|
||||
/datum/gas_mixture/proc/get_tile_overlay(gas_id)
|
||||
if(!LAZYACCESS(tile_overlay_cache, gas_id))
|
||||
if(gas_id == GAS_HEAT) //Not a real gas but functionally same thing
|
||||
LAZYSET(tile_overlay_cache, gas_id, new/obj/gas_overlay/heat(null, GAS_HEAT))
|
||||
else if(gas_id == GAS_COLD) //Not a real gas but functionally same thing
|
||||
LAZYSET(tile_overlay_cache, gas_id, new/obj/gas_overlay/cold(null, GAS_COLD))
|
||||
else
|
||||
LAZYSET(tile_overlay_cache, gas_id, new/obj/gas_overlay(null, gas_id))
|
||||
return tile_overlay_cache[gas_id]
|
||||
|
||||
///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)
|
||||
|
||||
Reference in New Issue
Block a user