Fix RNG state not being restorable
Created by: MidZik
In the current code, it is not possible to save and restore an RNG state after it has produced any random numbers.
This PR fixes that by exposing the RNG state through the state
property.
This change also breaks compatibility for the sake of standardizing the RNG API: the seed
property was removed, and a seed
method was added in its place. It wouldn't make sense that the state of an RNG was accessed through its seed
property, since the seed is only used to initialize the RNG. It also makes sense for seed
to be a method, since initializing an RNG from arbitrary input is called seeding it.
Finally, the rand_seed
global function has been removed where possible. Seeding and state have been properly separated, so it doesn't make sense to "return a new seed", and since the input expects a seed, returning the state to use as the next seed wouldn't make much sense either. rand_seed
is kept in VisualScript because removing it would be a migration nightmare, so it has been marked as deprecated.
Edit: Updated to match latest implementation.
Added last_seed
property that will return the last value the RNG was seeded with.