Skip to content

Chemistry

dragonryan06 edited this page Jul 25, 2024 · 2 revisions

Overview

The universe in Asterium is composed of chemical mixtures known as Solutions. While a solution can be true to its chemical meaning, (a solute-solvent relationship such as saltwater), it can also be a simple mixture such as a rock composed of different amounts of minerals, or the contents of a planetary atmosphere. This difference is expressed by the homogenous bool on solution.gd.

A Reagent is a chemical, element, mineral, or any other lowest-unit of substance that makes up these Solutions and has many physical properties. At some point I plan on implementing chemical reactions between these reagents, and maybe dynamic solution names being generated based on their contents. (Adding salt and water to a storage tank would automatically rename its contents to "saltwater")

Reagents

Reagent objects have 10 constant values constructed from their prototype:

# The name of this Reagent
var reagent_name : String
# The temperature, in K at which this Reagent state changes between solid/liquid
var melt_point : float
# The temperature, in K at which this Reagent state changes between liquid/gas
var boil_point : float
# The temperature, in K at which this Reagent state changes between gas/plasma
var ionize_point : float
# The density, in kg/m^3 of this Reagent
var density : float
# The specific heat capacity, in kJ/(kg K) of this Reagent
var specific_heat : float
# The color this Reagent is represented by in UI
var ui_color : Color
# The color this Reagent assumes in reality
var color : Color
# The interactions this Reagent has at certain temperatures in the presence of other Reagents.
var reactions : Dictionary
# This Reagent's tags
var tags : Array

Note: the values are marked var but they should not be changed during the object's lifetime. I may eventually change this object to override Godot's _init() constructor which should in theory let me set const values at runtime

Additionally, there are three varying values:

# The temperature, in K of this Reagent
var temperature : float = -1 : set=_set_temp
# The state this Reagent is currently in (see STATES)
var state : int = -1
# The amount, in kg, there is of this Reagent
var mass : float = -1

Reagent tags include:

enum TAGS {
	THALASSOGEN,
	OCEANIC_SOLUTE,
	GREENHOUSE_GAS,
	MINERAL,
	ROCK_FORMING,
	BASE_GAS,
	NOBLE_GAS,
	POISON
}

As of now, Reagent prototypes are defined in res://gamedata/chemistry/reagents.json, though this may not be the most sustainable practice, for now it provides the expandability I want and allows for very easy introduction of new Reagents. The user is not able to edit this in runtime, however, as the current export preset I have setup will encode all text files to binary and pack them into the executable.

Clone this wiki locally