Skip to content

1681-engine / index / WeatherEntry

Interface: WeatherEntry<K> ​

Defined in: src/ambient/weather.ts:20

Weather rolled from wall time alone, so two players standing in the same place are rained on together without a packet between them. Pure and deterministic: the same key, time and table give the same sky on every machine.

Time is cut into slots; each slot rolls one entry of a weighted list from a hash of the key and the slot number, and a change of kind fades out at the end of its slot and in at the start of the next. Places can share one sky: a key listed in a skies group takes its kind from the group's roll (so the rain does not stop at a map's edge) and only its strength from its own list. The kind 'clear' means no weather and has no strength.

ts
const TABLE: WeatherTable = {
  slotMs: 12 * 60_000,
  fadeMs: 40_000,
  places: { meadow: [{ kind: 'clear', weight: 4 }, { kind: 'rain', weight: 3, intensity: [0.4, 1] }] },
};
const w = weatherAt('meadow', serverNow(), TABLE); // { kind: 'rain', intensity: 0.7 }

Type Parameters ​

Type ParameterDefault type
K extends stringstring

Properties ​

intensity? ​

ts
optional intensity?: readonly [number, number];

Defined in: src/ambient/weather.ts:24

The strength range rolled for this kind, [lo, hi] in 0..1 (default [1, 1]).


kind ​

ts
kind: "clear" | K;

Defined in: src/ambient/weather.ts:21


weight ​

ts
weight: number;

Defined in: src/ambient/weather.ts:22

Released under the MIT License.