Table of Contents

Class WeatherExposureTemplate

Namespace
FishMMO.Shared.Weather
Assembly
FishMMO.Shared.dll

A state the weather can put a character into — wet, chilled, wind-burnt — and the buff that goes with it. Static content: what the weather has to be doing, how long it takes to build and to wear off, and what it applies. Never any runtime state; the levels live on WeatherExposureController, one set per character.

[CreateAssetMenu(fileName = "New Weather Exposure", menuName = "FishMMO/Weather/Exposure State", order = 6)]
public class WeatherExposureTemplate : CachedScriptableObject<WeatherExposureTemplate>, ICachedObject
Inheritance
Object
ScriptableObject
WeatherExposureTemplate
Implements
Inherited Members
ScriptableObject.SetDirty()
ScriptableObject.CreateInstance<T>()
Object.GetEntityId()
Object.MemberwiseClone()
Object.GetInstanceID()
Object.GetHashCode()
Object.InstantiateAsync<T>(T)
Object.InstantiateAsync<T>(T, Transform)
Object.InstantiateAsync<T>(T, Vector3, Quaternion)
Object.InstantiateAsync<T>(T, Transform, Vector3, Quaternion)
Object.Instantiate(Object, Vector3, Quaternion)
Object.Instantiate(Object, Vector3, Quaternion, Transform)
Object.Instantiate(Object)
Object.Instantiate(Object, Scene)
Object.Instantiate<T>(T, InstantiateParameters)
Object.Instantiate<T>(T, Vector3, Quaternion, InstantiateParameters)
Object.Instantiate(Object, Transform)
Object.Instantiate<T>(T)
Object.Instantiate<T>(T, Vector3, Quaternion)
Object.Instantiate<T>(T, Vector3, Quaternion, Transform)
Object.Instantiate<T>(T, Transform)
Object.Destroy(Object)
Object.DestroyImmediate(Object)
Object.DontDestroyOnLoad(Object)
Object.DestroyObject(Object)
Object.FindObjectsOfType<T>()
Object.FindObjectsByType<T>(FindObjectsSortMode)
Object.FindObjectsByType<T>(FindObjectsInactive, FindObjectsSortMode)
Object.FindObjectOfType<T>()
Object.FindFirstObjectByType<T>()
Object.FindAnyObjectByType<T>()
Object.FindFirstObjectByType<T>(FindObjectsInactive)
Object.FindAnyObjectByType<T>(FindObjectsInactive)
Object.FindObjectsByType<T>()
Object.FindObjectsByType<T>(FindObjectsInactive)
Object.ToString()
Object.name
Object.hideFlags

Remarks

It reads the weather, not the layer that caused it. A template names inputs and a temperature response, and is evaluated against the blended WeatherReading where the character is standing. So a state does not care whether the rain came from the biome's background, a storm cell overhead or a GM's preset — only that rain is falling on this spot.

And it can read the physics, not only the look of it. A term reads either a channel of the blended weather or one of the driver's air properties — the pressure field, the humidity, the instability, the real wind (see WeatherExposureInput). The second kind is what lets a state exist that has no visible weather at all: saturated air with nothing falling out of it, or a deep low that can only be felt.

The temperature it reads is the physical one. Temperature carries the biome's climate, the body's distance from its suns, its atmosphere's greenhouse, the latitude and the season — so Chilled comes on by itself on a world far from its star, at a high latitude, in its winter, without anybody authoring a cold region.

Shelter protects. The drive is scaled by how exposed the character is, so standing under a roof stops the rain wetting them, while ShelterProtection at 0 marks a state a roof is no defence against — cold air is still cold indoors.

Fields

ApplyAt

[Tooltip("The level at or above which the buff is applied.")]
[Range(0, 1)]
public float ApplyAt

Field Value

float

Buff

[Header("What it does")]
[Tooltip("The buff applied while the state is held. Optional: a state with no buff is still tracked, and can still feed a recipe.")]
public BaseBuffTemplate Buff

Field Value

BaseBuffTemplate

Description

[Tooltip("Shown in tooltips and logs. The asset's name is used when this is empty.")]
public string Description

Field Value

string

ReleaseAt

[Tooltip("The level at or below which the buff is removed. Keep it under Apply at, so a state on the edge does not flicker.")]
[Range(0, 1)]
public float ReleaseAt

Field Value

float

RequireEveryTerm

[Tooltip("All terms must drive it at once (rain AND cold), instead of any one of them being enough.")]
public bool RequireEveryTerm

Field Value

bool

SecondsToClear

[Tooltip("Seconds out of it to wear off completely.")]
[Min(0.1)]
public float SecondsToClear

Field Value

float

SecondsToFull

[Header("How fast")]
[Tooltip("Seconds of the worst weather to go from nothing to fully exposed.")]
[Min(0.1)]
public float SecondsToFull

Field Value

float

ShelterProtection

[Header("Shelter")]
[Tooltip("How much a roof protects against this. 1: shelter stops it entirely. 0: shelter is no defence, which is right for cold and for fumes.")]
[Range(0, 1)]
public float ShelterProtection

Field Value

float

ShelteredRecovery

[Tooltip("Wearing off is this much faster when sheltered. 2 halves the time under a roof.")]
[Min(1)]
public float ShelteredRecovery

Field Value

float

Temperature

[Tooltip("Whether the local temperature drives this state, and which way.")]
public WeatherExposureTemperatureResponse Temperature

Field Value

WeatherExposureTemperatureResponse

TemperatureFull

[Tooltip("The temperature at which the temperature term contributes all of its weight.")]
[Range(-1, 1)]
public float TemperatureFull

Field Value

float

TemperatureOnset

[Tooltip("The temperature at which the temperature term contributes nothing. Climate scale, -1 frozen to +1 scorching.")]
[Range(-1, 1)]
public float TemperatureOnset

Field Value

float

TemperatureWeight

[Tooltip("How much of the drive the temperature is worth, against the channel terms.")]
[Range(0, 4)]
public float TemperatureWeight

Field Value

float

Terms

[Header("What the weather has to be doing")]
[Tooltip("Weather channels that drive this state. Their weights are summed, then clamped to 1.")]
public List<WeatherExposureTerm> Terms

Field Value

List<WeatherExposureTerm>

Properties

DisplayName

public string DisplayName { get; }

Property Value

string

Methods

Drive(in WeatherFrame, in WeatherAir, float, float)

Drive(in WeatherReading) with the sample's parts spelled out. For tests, and for tools that ask what some hypothetical weather would do.

public float Drive(in WeatherFrame frame, in WeatherAir air, float temperature, float exposure)

Parameters

frame WeatherFrame

The blended weather at the character's position.

air WeatherAir

What the driver says the air is doing there.

temperature float

The local physical temperature, -1..1.

exposure float

1 in the open, 0 fully sheltered.

Returns

float

Drive(in WeatherReading)

How hard the weather is pushing this state where the character stands, 0..1.

public float Drive(in WeatherReading sample)

Parameters

sample WeatherReading

The weather at the character's position, as the controller sampled it.

Returns

float

Remarks

The whole sample, deliberately, and not a handful of numbers picked out of it. Everything a term can read — the blended channels, the driver's air, the physical temperature, how sheltered the spot is — comes from one sample, taken at one place and one tick. Hand the pieces in separately and it becomes possible to pass a frame from here with an air from somewhere else, and the state would be driven by weather that never existed.

Pure: the same sample gives the same answer on the server and on the owner, which is what lets the level be predicted at all.

Step(float, float, float, float)

The level after one step, given the drive. Deterministic and frame-rate independent: the step is in seconds of simulated time, never Time.deltaTime.

public float Step(float level, float drive, float seconds, float exposure)

Parameters

level float

The level now, 0..1.

drive float

What the weather is pushing toward, 0..1.

seconds float

How much time this step covers.

exposure float

1 in the open, 0 fully sheltered; only affects wearing off.

Returns

float

Remarks

The level chases the drive rather than merely rising and falling: parked in weather that is only driving at a third, a state settles at a third and stays there, which is what "drizzle never soaks you through" means. Both rates are full-scale, so a state with SecondsToFull of 45 takes 45 seconds from nothing to soaked in the worst of it, and proportionally longer in less.