Fixes some burn reactions deleting energy (#28659)

* makes energy production make sense

* Build Rust library

* Build Rust library

* Build Rust library

* Build Rust library

* Build Rust library

* Build Rust library

---------

Co-authored-by: paradisess13[bot] <165046124+paradisess13[bot]@users.noreply.github.com>
This commit is contained in:
Migratingcocofruit
2025-03-30 21:42:18 +00:00
committed by GitHub
co-authored by paradisess13[bot] <165046124+paradisess13[bot]@users.noreply.github.com>
parent 722a77c929
commit e261e35907
9 changed files with 19 additions and 12 deletions
+5
View File
@@ -157,6 +157,11 @@
/// The coefficient c for a function of the form: 1 - (a / (x + c)^2) which gives a decomposition rate of 0.5 at 50000 Kelvin
/// And a decomposition rate close to 0 at 1400 Kelvin
#define N2O_DECOMPOSITION_COEFFICIENT_C 115930.77913
/// Agent B starts working at this temperature
#define AGENT_B_CONVERSION_MIN_TEMP 900
/// Agent B released this much energy per mole of CO2 converted to O2
#define AGENT_B_CONVERSION_ENERGY_RELEASED 20000
// From milla/src/model.rs, line 126
#define ATMOS_MODE_SPACE 0 //! Tile is exposed to space and loses air every second
#define ATMOS_MODE_SEALED 1 //! Tile has no special behaviour
@@ -560,16 +560,20 @@ What are the archived variables for?
/datum/gas_mixture/proc/react(atom/dump_location)
var/reacting = FALSE //set to TRUE if a notable reaction occured (used by pipe_network)
if((private_agent_b > MINIMUM_MOLE_COUNT) && private_temperature > 900)
if((private_agent_b > MINIMUM_MOLE_COUNT) && private_temperature > AGENT_B_CONVERSION_MIN_TEMP)
if(private_toxins > MINIMUM_HEAT_CAPACITY && private_carbon_dioxide > MINIMUM_HEAT_CAPACITY)
var/reaction_rate = min(private_carbon_dioxide * 0.75, private_toxins * 0.25, private_agent_b * 0.05)
var/old_heat_capacity = heat_capacity()
var/energy_released = reaction_rate * AGENT_B_CONVERSION_ENERGY_RELEASED
private_carbon_dioxide -= reaction_rate
private_oxygen += reaction_rate
private_agent_b -= reaction_rate * 0.05
private_temperature += (reaction_rate * 20000) / heat_capacity()
var/new_heat_capacity = heat_capacity()
if(new_heat_capacity > MINIMUM_HEAT_CAPACITY)
private_temperature = (private_temperature * old_heat_capacity + energy_released) / new_heat_capacity
reacting = TRUE
+8 -10
View File
@@ -560,10 +560,9 @@ pub(crate) fn react(my_next_tile: &mut Tile, hotspot_step: bool) {
my_next_tile
.gases
.set_agent_b(my_next_tile.gases.agent_b() - co2_converted * 0.05);
// Recalculate existing thermal energy to account for the change in heat capacity.
// Recalculate heat capacity.
cached_heat_capacity = fraction * my_next_tile.heat_capacity();
thermal_energy = cached_temperature * cached_heat_capacity;
// THEN we can add in the new thermal energy.
// Add in the new thermal energy.
thermal_energy += AGENT_B_CONVERSION_ENERGY * co2_converted;
// Recalculate temperature for any subsequent reactions.
cached_temperature = thermal_energy / cached_heat_capacity;
@@ -588,10 +587,9 @@ pub(crate) fn react(my_next_tile: &mut Tile, hotspot_step: bool) {
.gases
.set_oxygen(my_next_tile.gases.oxygen() + nitrous_decomposed / 2.0);
// Recalculate existing thermal energy to account for the change in heat capacity.
// Recalculate heat capacity.
cached_heat_capacity = fraction * my_next_tile.heat_capacity();
thermal_energy = cached_temperature * cached_heat_capacity;
// THEN we can add in the new thermal energy.
// Add in the new thermal energy.
thermal_energy += NITROUS_BREAKDOWN_ENERGY * nitrous_decomposed;
// Recalculate temperature for any subsequent reactions.
cached_temperature = thermal_energy / cached_heat_capacity;
@@ -634,9 +632,8 @@ pub(crate) fn react(my_next_tile: &mut Tile, hotspot_step: bool) {
.gases
.set_oxygen(my_next_tile.gases.oxygen() - plasma_burnt * PLASMA_BURN_OXYGEN_PER_PLASMA);
// Recalculate existing thermal energy to account for the change in heat capacity.
// Recalculate heat capacity.
cached_heat_capacity = fraction * my_next_tile.heat_capacity();
thermal_energy = cached_temperature * cached_heat_capacity;
// THEN we can add in the new thermal energy.
thermal_energy += PLASMA_BURN_ENERGY * plasma_burnt;
// Recalculate temperature for any subsequent reactions.
@@ -681,8 +678,9 @@ pub(crate) fn apply_tile_mode(
if my_next_tile.temperature() > SPACE_COOLING_THRESHOLD {
let excess_thermal_energy = my_next_tile.thermal_energy
- SPACE_COOLING_THRESHOLD * my_next_tile.heat_capacity();
let cooling = (SPACE_COOLING_FLAT + SPACE_COOLING_TEMPERATURE_RATIO * my_next_tile.temperature())
.min(excess_thermal_energy);
let cooling = (SPACE_COOLING_FLAT
+ SPACE_COOLING_TEMPERATURE_RATIO * my_next_tile.temperature())
.min(excess_thermal_energy);
my_next_tile.thermal_energy -= cooling;
}
}
BIN
View File
Binary file not shown.
Binary file not shown.
BIN
View File
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.