Skip to content

4. Custom

Venomaus edited this page Jan 4, 2024 · 4 revisions

A bunch of custom classes are also provided, which could be useful for modding.

MersenneTwister

Provides a Random implementation of which you can export the full state of the random, and initialize a new random with this state. This is useful when you need to serialize the random, and later deserialize it into the same random where you want your randomness to remain the same.

It works similar to the .net Random, (Next, NextDouble) methods are available.

Note: the minValue and maxValue are both always "inclusive".

var random = new MersenneTwister(seed); // if no seed provided uses DateTime.Now.Ticks as seed
var state = random.SaveState(); // Get the save state
random = new MersenneTwister(state); // Restore a new random with the same state

InteractableInstanceData

Provides safe access to Interactable data, including TryGet methods for InteractableControllers and Unity objects. Use this to avoid issues when Interactables get pooled.

Clone this wiki locally