GTG Thermal Framework
Climate per server New
The same windows show a desert hot and a winter cold, if the world’s climate says so. The framework sets that climate on the server: from a file at start, from the Game Master during the session.
Who sets what
| When | Who | What happens |
|---|---|---|
| Server start | The file GTG_ThermalClimate.json | Air minimum and maximum for every map. The sun is set to its fixed range, the sky follows the air. |
| During the session | The Game Master | Two sliders under Scenario properties > Weather: air temperature minimum and maximum, −40 to 80 degrees. |
| After a restart | The file again | The Game Master’s values are not stored; the file applies again. |
All of it runs on the server only. The values go into the world’s TimeAndWeatherManagerEntity, and the game sends them to every player, so every player’s thermal picture uses the same climate.
The server file
At its first start the server writes the file into its profile folder ($profile:). On a rented server that is usually the folder where the settings files of other mods are, for example profile/GTG_ThermalClimate.json
inside the folder given with -profile. In single player and when you host from the game, it is your own profile folder. The file as the server writes it:
{
/* ~~~~~~~~~~~~~~~~~~ GTG THERMAL FRAMEWORK - SERVER CLIMATE ~~~~~~~~~~~~~~~~~~ */
/* Air temperature for the thermal picture, the same for every map on this server. */
/* The server reads this file at start and sends the values to every player. */
/* AirMin = coldest air of the day (night), AirMax = warmest air of the day, in degrees C. */
/* Allowed: -40 to 80. The sky follows the air by itself, the sun heating is fixed. */
/* A Game Master can still change both values during the session (Scenario properties > Weather). */
/* After a server restart this file applies again. */
"AirMin": 12,
"AirMax": 28
}
| Rule | What it means |
|---|---|
| Comments are allowed | Blocks /* ... */ and whole lines starting with // are removed before the JSON is read. |
| Limits | Values outside −40 to 80 are clamped. If the minimum is above the maximum, the two are swapped. |
| A broken file is never overwritten | The server uses the defaults (12 and 28) and says why in its log. Fix the file and restart. |
| Every map | The file wins over a scenario that brings its own temperature values. One server, one climate. |
At start the server writes one line to its log, with the values and where they came from:
[GTG_THERMAL] Server climate: air 0 .. 10 C, sun fixed 0 .. 1000 ($profile:GTG_ThermalClimate.json: from the file)
The other endings are file created with the defaults, file could not be read (check the JSON format), defaults used and AirMin or AirMax missing in the file, defaults used.
About ten seconds after the start the server checks once more: if something other than the Game Master has changed the climate by then (a scenario, a loaded save), the file is applied again and the log says so.
What the framework writes into the world
From two air values the framework derives the rest. The sky radiates much colder than the air; with the defaults it lands on the −15 degrees the materials were calibrated with:
static const float SKY_BELOW_AIR_MIN = 27;
static const float SKY_BELOW_AIR_MAX = 43;
protected static void ApplyTemperature(TimeAndWeatherManagerEntity tm, float airMin, float airMax)
{
float skyMin = airMin - SKY_BELOW_AIR_MIN;
float skyMax = Math.Max(airMax - SKY_BELOW_AIR_MAX, skyMin);
tm.SetOverrideTemperature(true);
tm.SetTemperatureOverrideValues(airMin, airMax, skyMin, skyMax, WATER_MIN, WATER_MAX);
}
// at start, after the air: the sun is always the same
tm.SetOverrideSunIrradiance(true);
tm.SetSunIrradianceOverrideValues(DEFAULT_SUN_MIN, DEFAULT_SUN_MAX); // 0 .. 1000
After every change the engine’s temperature table is computed again with ForceTemperatureTableRecompute(). That is expensive, so several changes in quick succession are collected and computed once, 0.6 seconds later.
A mission with its own climate
A scenario script of your own can set the air on the server, for example a desert mission at 25 to 48 degrees. Call it after the game has started: the start applies the server file first, and the check ten seconds later leaves your values alone once you have set them.
// server only; values in degrees C, clamped to -40 .. 80
if (Replication.IsServer())
GTG_ThermalClimate.SetAir(25, 48);
// read the current air range (any machine)
float airMin = GTG_ThermalClimate.GetAirMin();
float airMax = GTG_ThermalClimate.GetAirMax();
OnGameStart() of the game mode, so in your own game mode call SetAir after super.OnGameStart(), or later.