Minor XGM changes (#20855)

* Moves things around, changes comments, fixes overlay plane

* Lummox-approved

* These procs being able to return null was always a terrible idea

* Oops
This commit is contained in:
Exxion
2018-11-29 09:43:50 -05:00
committed by jknpj
parent 3b7b390a22
commit 8d744f2e2d
5 changed files with 126 additions and 124 deletions

View File

@@ -5,110 +5,3 @@
#define GAS_SLEEPING "sleeping_agent" #define GAS_SLEEPING "sleeping_agent"
#define GAS_VOLATILE "volatile_fuel" #define GAS_VOLATILE "volatile_fuel"
#define GAS_OXAGENT "oxygen_agent_b" #define GAS_OXAGENT "oxygen_agent_b"
/datum/gas
var/id = ""
var/name = "Unnamed Gas"
var/short_name // HTML-formatted short name.
var/specific_heat = 20 // J/(mol*K)
var/molar_mass = 0.032 // kg/mol
var/tile_overlay = null
var/overlay_limit = null
var/flags = 0
/datum/gas/proc/is_human_safe(var/moles, var/datum/gas_mixture/mixture)
return TRUE
/datum/gas/oxygen
id = GAS_OXYGEN
name = "Oxygen"
short_name = "O<sub>2</sub>"
specific_heat = 20 // J/(mol*K)
molar_mass = 0.032 // kg/mol
flags = XGM_GAS_OXIDIZER
/datum/gas/oxygen/is_human_safe(var/moles, var/datum/gas_mixture/mixture)
return abs(moles/mixture.total_moles() - O2STANDARD) < 0.02
/datum/gas/nitrogen
id = GAS_NITROGEN
name = "Nitrogen"
short_name = "N<sub>2</sub>"
specific_heat = 20 // J/(mol*K)
molar_mass = 0.028 // kg/mol
/datum/gas/nitrogen/is_human_safe(var/moles, var/datum/gas_mixture/mixture)
return abs(moles/mixture.total_moles() - N2STANDARD) < 0.2
/datum/gas/carbon_dioxide
id = GAS_CARBON
name = "Carbon Dioxide"
short_name = "CO<sub>2</sub>"
specific_heat = 30 // J/(mol*K)
molar_mass = 0.044 // kg/mol
flags = XGM_GAS_LOGGED
/datum/gas/carbon_dioxide/is_human_safe(var/moles, var/datum/gas_mixture/mixture)
return moles/mixture.total_moles() < 0.01
/datum/gas/plasma
id = GAS_PLASMA
name = "Plasma"
//Note that this has a significant impact on TTV yield.
//Because it is so high, any leftover plasma soaks up a lot of heat and drops the yield pressure.
specific_heat = 200 // J/(mol*K)
//Hypothetical group 14 (same as carbon), period 8 element.
//Using multiplicity rule, it's atomic number is 162
//and following a N/Z ratio of 1.5, the molar mass of a monatomic gas is:
molar_mass = 0.405 // kg/mol
tile_overlay = "plasma"
overlay_limit = MOLES_PLASMA_VISIBLE / CELL_VOLUME
flags = XGM_GAS_FUEL | XGM_GAS_CONTAMINANT | XGM_GAS_LOGGED
/datum/gas/plasma/is_human_safe(var/moles, var/datum/gas_mixture/mixture)
return moles/mixture.total_moles() < 0.01
/datum/gas/sleeping_agent
id = GAS_SLEEPING
name = "Sleeping Agent"
short_name = "N<sub>2</sub>O"
specific_heat = 40 // J/(mol*K)
molar_mass = 0.044 // kg/mol. N₂O
tile_overlay = "sleeping_agent"
overlay_limit = 1 / CELL_VOLUME
flags = XGM_GAS_OXIDIZER | XGM_GAS_LOGGED // N₂O is a powerful oxidizer
/datum/gas/sleeping_agent/is_human_safe(var/moles, var/datum/gas_mixture/mixture)
return moles/mixture.total_moles() < 0.01
/datum/gas/volatile_fuel
id = GAS_VOLATILE
name = "Volatile Fuel"
specific_heat = 30
molar_mass = 0.163 // @MoMMI#9954 roll 32 405
flags = XGM_GAS_FUEL | XGM_GAS_LOGGED
/datum/gas/volatile_fuel/is_human_safe(var/moles, var/datum/gas_mixture/mixture)
return moles/mixture.total_moles() < 0.01
/datum/gas/oxygen_agent_b
id = GAS_OXAGENT
name = "Oxygen Agent B"
specific_heat = 300
molar_mass = 0.300
flags = XGM_GAS_FUEL | XGM_GAS_OXIDIZER | XGM_GAS_CONTAMINANT | XGM_GAS_LOGGED
/datum/gas/oxygen_agent_b/is_human_safe(var/moles, var/datum/gas_mixture/mixture)
return moles/mixture.total_moles() < 0.01

View File

@@ -11,9 +11,9 @@
var/list/specific_heat = list() var/list/specific_heat = list()
// Molar mass of the gas. Used for calculating specific entropy. // Molar mass of the gas. Used for calculating specific entropy.
var/list/molar_mass = list() var/list/molar_mass = list()
// Tile overlays. /images, created from references to 'icons/effects/tile_effects.dmi' // Tile overlays.
var/list/tile_overlay = list() var/list/tile_overlay = list()
// Overlay limits. There must be at least this many moles for the overlay to appear. // Overlay limits. There must be strictly more than this many moles per liter for the overlay to appear.
var/list/overlay_limit = list() var/list/overlay_limit = list()
// Flags. // Flags.
var/list/flags = list() var/list/flags = list()
@@ -38,8 +38,8 @@
molar_mass[gas.id] = gas.molar_mass molar_mass[gas.id] = gas.molar_mass
flags[gas.id] = gas.flags flags[gas.id] = gas.flags
if(gas.tile_overlay) if(gas.tile_overlay)
tile_overlay[gas.id] = image('icons/effects/tile_effects.dmi', gas.tile_overlay, FLY_LAYER) tile_overlay[gas.id] = gas.tile_overlay
if(gas.overlay_limit) if(isnum(gas.overlay_limit))
overlay_limit[gas.id] = gas.overlay_limit overlay_limit[gas.id] = gas.overlay_limit
return TRUE return TRUE

110
code/ZAS/XGM_gases.dm Normal file
View File

@@ -0,0 +1,110 @@
/datum/gas
var/id = ""
var/name = "Unnamed Gas"
var/short_name // HTML-formatted short name.
var/specific_heat = 20 // J/(mol*K)
var/molar_mass = 0.032 // kg/mol
var/tile_overlay = null //The overlay to draw over tiles containing this gas if it is visible. Can be anything that the overlays list will accept.
var/overlay_limit = null //If the molar_density of this gas in a zone is strictly greater than this number, it is visible.
var/flags = 0
//This should probably be in a different file, but currently it's only used here.
/image/effect
plane = EFFECTS_PLANE
/datum/gas/proc/is_human_safe(var/moles, var/datum/gas_mixture/mixture)
return TRUE
/datum/gas/oxygen
id = GAS_OXYGEN
name = "Oxygen"
short_name = "O<sub>2</sub>"
specific_heat = 20 // J/(mol*K)
molar_mass = 0.032 // kg/mol
flags = XGM_GAS_OXIDIZER
/datum/gas/oxygen/is_human_safe(var/moles, var/datum/gas_mixture/mixture)
return abs(moles/mixture.total_moles() - O2STANDARD) < 0.02
/datum/gas/nitrogen
id = GAS_NITROGEN
name = "Nitrogen"
short_name = "N<sub>2</sub>"
specific_heat = 20 // J/(mol*K)
molar_mass = 0.028 // kg/mol
/datum/gas/nitrogen/is_human_safe(var/moles, var/datum/gas_mixture/mixture)
return abs(moles/mixture.total_moles() - N2STANDARD) < 0.2
/datum/gas/carbon_dioxide
id = GAS_CARBON
name = "Carbon Dioxide"
short_name = "CO<sub>2</sub>"
specific_heat = 30 // J/(mol*K)
molar_mass = 0.044 // kg/mol
flags = XGM_GAS_LOGGED
/datum/gas/carbon_dioxide/is_human_safe(var/moles, var/datum/gas_mixture/mixture)
return moles/mixture.total_moles() < 0.01
/datum/gas/plasma
id = GAS_PLASMA
name = "Plasma"
//Note that this has a significant impact on TTV yield.
//Because it is so high, any leftover plasma soaks up a lot of heat and drops the yield pressure.
specific_heat = 200 // J/(mol*K)
//Hypothetical group 14 (same as carbon), period 8 element.
//Using multiplicity rule, it's atomic number is 162
//and following a N/Z ratio of 1.5, the molar mass of a monatomic gas is:
molar_mass = 0.405 // kg/mol
tile_overlay = new /image/effect('icons/effects/tile_effects.dmi', "plasma", FLY_LAYER)
overlay_limit = MOLES_PLASMA_VISIBLE / CELL_VOLUME
flags = XGM_GAS_FUEL | XGM_GAS_CONTAMINANT | XGM_GAS_LOGGED
/datum/gas/plasma/is_human_safe(var/moles, var/datum/gas_mixture/mixture)
return moles/mixture.total_moles() < 0.01
/datum/gas/sleeping_agent
id = GAS_SLEEPING
name = "Sleeping Agent"
short_name = "N<sub>2</sub>O"
specific_heat = 40 // J/(mol*K)
molar_mass = 0.044 // kg/mol. N₂O
tile_overlay = new /image/effect('icons/effects/tile_effects.dmi', "sleeping_agent", FLY_LAYER)
overlay_limit = 1 / CELL_VOLUME
flags = XGM_GAS_OXIDIZER | XGM_GAS_LOGGED // N₂O is a powerful oxidizer
/datum/gas/sleeping_agent/is_human_safe(var/moles, var/datum/gas_mixture/mixture)
return moles/mixture.total_moles() < 0.01
/datum/gas/volatile_fuel
id = GAS_VOLATILE
name = "Volatile Fuel"
specific_heat = 30
molar_mass = 0.163 // @MoMMI#9954 roll 32 405
flags = XGM_GAS_FUEL | XGM_GAS_LOGGED
/datum/gas/volatile_fuel/is_human_safe(var/moles, var/datum/gas_mixture/mixture)
return moles/mixture.total_moles() < 0.01
/datum/gas/oxygen_agent_b
id = GAS_OXAGENT
name = "Oxygen Agent B"
specific_heat = 300
molar_mass = 0.300
flags = XGM_GAS_FUEL | XGM_GAS_OXIDIZER | XGM_GAS_CONTAMINANT | XGM_GAS_LOGGED
/datum/gas/oxygen_agent_b/is_human_safe(var/moles, var/datum/gas_mixture/mixture)
return moles/mixture.total_moles() < 0.01

View File

@@ -232,21 +232,20 @@
//Removes the given number of moles from src, and returns a new gas_mixture containing the removed gas. //Removes the given number of moles from src, and returns a new gas_mixture containing the removed gas.
/datum/gas_mixture/proc/remove(moles, update = TRUE, update_removed = TRUE) /datum/gas_mixture/proc/remove(moles, update = TRUE, update_removed = TRUE)
var/sum = total_moles var/sum = total_moles
if(!sum)
return
moles = min(moles, sum) //Cannot take more air than tile has! moles = min(moles, sum) //Cannot take more air than tile has!
return remove_ratio(moles / sum, update, update_removed) var/ratio = sum && (moles / sum) //Don't divide by zero
return remove_ratio(ratio, update, update_removed)
//Removes the given proportion of the gas in src, and returns a new gas_mixture containing the removed gas. //Removes the given proportion of the gas in src, and returns a new gas_mixture containing the removed gas.
/datum/gas_mixture/proc/remove_ratio(ratio, update = TRUE, update_removed = TRUE) /datum/gas_mixture/proc/remove_ratio(ratio, update = TRUE, update_removed = TRUE)
var/datum/gas_mixture/removed = new()
if(ratio <= 0 || total_moles <= 0) if(ratio <= 0 || total_moles <= 0)
return return removed
ratio = min(ratio, 1) ratio = min(ratio, 1)
var/datum/gas_mixture/removed = new()
for(var/g in gas) for(var/g in gas)
var/moles = gas[g] * ratio var/moles = gas[g] * ratio
gas[g] -= moles gas[g] -= moles
@@ -265,10 +264,9 @@
//Removes the given volume of gas from src, and returns a new gas_mixture containing the removed gas, with the given volume. //Removes the given volume of gas from src, and returns a new gas_mixture containing the removed gas, with the given volume.
/datum/gas_mixture/proc/remove_volume(removed_volume, update = TRUE, update_removed = TRUE) /datum/gas_mixture/proc/remove_volume(removed_volume, update = TRUE, update_removed = TRUE)
var/datum/gas_mixture/removed = remove_ratio(removed_volume / volume, update, FALSE) var/datum/gas_mixture/removed = remove_ratio(removed_volume / volume, update, FALSE)
if(removed) removed.volume = removed_volume
removed.volume = removed_volume if(update_removed)
if(update_removed) removed.update_values()
removed.update_values()
return removed return removed
@@ -481,13 +479,13 @@ var/static/list/sharing_lookup_table = list(0.30, 0.40, 0.48, 0.54, 0.60, 0.66)
/datum/gas_mixture/unsimulated/remove_ratio(ratio, update, update_removed = TRUE) /datum/gas_mixture/unsimulated/remove_ratio(ratio, update, update_removed = TRUE)
var/datum/gas_mixture/removed = new()
if(ratio <= 0 || total_moles <= 0) if(ratio <= 0 || total_moles <= 0)
return null return removed
ratio = min(ratio, 1) ratio = min(ratio, 1)
var/datum/gas_mixture/removed = new()
for(var/g in gas) for(var/g in gas)
removed[g] += gas[g] * ratio removed[g] += gas[g] * ratio

View File

@@ -2421,6 +2421,7 @@
#include "code\ZAS\Plasma.dm" #include "code\ZAS\Plasma.dm"
#include "code\ZAS\Turf.dm" #include "code\ZAS\Turf.dm"
#include "code\ZAS\XGM.dm" #include "code\ZAS\XGM.dm"
#include "code\ZAS\XGM_gases.dm"
#include "code\ZAS\Zone.dm" #include "code\ZAS\Zone.dm"
#include "goon\code\datums\browserOutput.dm" #include "goon\code\datums\browserOutput.dm"
#include "goon\code\obj\machinery\bot\chefbot.dm" #include "goon\code\obj\machinery\bot\chefbot.dm"