arcade-physics
Version:
Use Arcade Physics without Phaser.
316 lines • 9.23 kB
TypeScript
export default RandomDataGenerator;
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* @classdesc
* A seeded Random Data Generator.
*
* Access via `Phaser.Math.RND` which is an instance of this class pre-defined
* by Phaser. Or, create your own instance to use as you require.
*
* The `Math.RND` generator is seeded by the Game Config property value `seed`.
* If no such config property exists, a random number is used.
*
* If you create your own instance of this class you should provide a seed for it.
* If no seed is given it will use a 'random' one based on Date.now.
*
* @class RandomDataGenerator
* @memberof Phaser.Math
* @constructor
* @since 3.0.0
*
* @param {(string|string[])} [seeds] - The seeds to use for the random number generator.
*/
declare class RandomDataGenerator {
constructor(seeds: any);
/**
* Internal var.
*
* @name Phaser.Math.RandomDataGenerator#c
* @type {number}
* @default 1
* @private
* @since 3.0.0
*/
private c;
/**
* Internal var.
*
* @name Phaser.Math.RandomDataGenerator#s0
* @type {number}
* @default 0
* @private
* @since 3.0.0
*/
private s0;
/**
* Internal var.
*
* @name Phaser.Math.RandomDataGenerator#s1
* @type {number}
* @default 0
* @private
* @since 3.0.0
*/
private s1;
/**
* Internal var.
*
* @name Phaser.Math.RandomDataGenerator#s2
* @type {number}
* @default 0
* @private
* @since 3.0.0
*/
private s2;
/**
* Internal var.
*
* @name Phaser.Math.RandomDataGenerator#n
* @type {number}
* @default 0
* @private
* @since 3.2.0
*/
private n;
/**
* Signs to choose from.
*
* @name Phaser.Math.RandomDataGenerator#signs
* @type {number[]}
* @since 3.0.0
*/
signs: number[];
/**
* Private random helper.
*
* @method Phaser.Math.RandomDataGenerator#rnd
* @since 3.0.0
* @private
*
* @return {number} A random number.
*/
private rnd;
/**
* Internal method that creates a seed hash.
*
* @method Phaser.Math.RandomDataGenerator#hash
* @since 3.0.0
* @private
*
* @param {string} data - The value to hash.
*
* @return {number} The hashed value.
*/
private hash;
/**
* Initialize the state of the random data generator.
*
* @method Phaser.Math.RandomDataGenerator#init
* @since 3.0.0
*
* @param {(string|string[])} seeds - The seeds to initialize the random data generator with.
*/
init(seeds: (string | string[])): void;
/**
* Reset the seed of the random data generator.
*
* _Note_: the seed array is only processed up to the first `undefined` (or `null`) value, should such be present.
*
* @method Phaser.Math.RandomDataGenerator#sow
* @since 3.0.0
*
* @param {string[]} seeds - The array of seeds: the `toString()` of each value is used.
*/
sow(seeds: string[]): void;
/**
* Returns a random integer between 0 and 2^32.
*
* @method Phaser.Math.RandomDataGenerator#integer
* @since 3.0.0
*
* @return {number} A random integer between 0 and 2^32.
*/
integer(): number;
/**
* Returns a random real number between 0 and 1.
*
* @method Phaser.Math.RandomDataGenerator#frac
* @since 3.0.0
*
* @return {number} A random real number between 0 and 1.
*/
frac(): number;
/**
* Returns a random real number between 0 and 2^32.
*
* @method Phaser.Math.RandomDataGenerator#real
* @since 3.0.0
*
* @return {number} A random real number between 0 and 2^32.
*/
real(): number;
/**
* Returns a random integer between and including min and max.
*
* @method Phaser.Math.RandomDataGenerator#integerInRange
* @since 3.0.0
*
* @param {number} min - The minimum value in the range.
* @param {number} max - The maximum value in the range.
*
* @return {number} A random number between min and max.
*/
integerInRange(min: number, max: number): number;
/**
* Returns a random integer between and including min and max.
* This method is an alias for RandomDataGenerator.integerInRange.
*
* @method Phaser.Math.RandomDataGenerator#between
* @since 3.0.0
*
* @param {number} min - The minimum value in the range.
* @param {number} max - The maximum value in the range.
*
* @return {number} A random number between min and max.
*/
between(min: number, max: number): number;
/**
* Returns a random real number between min and max.
*
* @method Phaser.Math.RandomDataGenerator#realInRange
* @since 3.0.0
*
* @param {number} min - The minimum value in the range.
* @param {number} max - The maximum value in the range.
*
* @return {number} A random number between min and max.
*/
realInRange(min: number, max: number): number;
/**
* Returns a random real number between -1 and 1.
*
* @method Phaser.Math.RandomDataGenerator#normal
* @since 3.0.0
*
* @return {number} A random real number between -1 and 1.
*/
normal(): number;
/**
* Returns a valid RFC4122 version4 ID hex string from https://gist.github.com/1308368
*
* @method Phaser.Math.RandomDataGenerator#uuid
* @since 3.0.0
*
* @return {string} A valid RFC4122 version4 ID hex string
*/
uuid(): string;
/**
* Returns a random element from within the given array.
*
* @method Phaser.Math.RandomDataGenerator#pick
* @since 3.0.0
*
* @generic T
* @genericUse {T[]} - [array]
* @genericUse {T} - [$return]
*
* @param {T[]} array - The array to pick a random element from.
*
* @return {T} A random member of the array.
*/
pick(array: T[]): T;
/**
* Returns a sign to be used with multiplication operator.
*
* @method Phaser.Math.RandomDataGenerator#sign
* @since 3.0.0
*
* @return {number} -1 or +1.
*/
sign(): number;
/**
* Returns a random element from within the given array, favoring the earlier entries.
*
* @method Phaser.Math.RandomDataGenerator#weightedPick
* @since 3.0.0
*
* @generic T
* @genericUse {T[]} - [array]
* @genericUse {T} - [$return]
*
* @param {T[]} array - The array to pick a random element from.
*
* @return {T} A random member of the array.
*/
weightedPick(array: T[]): T;
/**
* Returns a random timestamp between min and max, or between the beginning of 2000 and the end of 2020 if min and max aren't specified.
*
* @method Phaser.Math.RandomDataGenerator#timestamp
* @since 3.0.0
*
* @param {number} min - The minimum value in the range.
* @param {number} max - The maximum value in the range.
*
* @return {number} A random timestamp between min and max.
*/
timestamp(min: number, max: number): number;
/**
* Returns a random angle between -180 and 180.
*
* @method Phaser.Math.RandomDataGenerator#angle
* @since 3.0.0
*
* @return {number} A random number between -180 and 180.
*/
angle(): number;
/**
* Returns a random rotation in radians, between -3.141 and 3.141
*
* @method Phaser.Math.RandomDataGenerator#rotation
* @since 3.0.0
*
* @return {number} A random number between -3.141 and 3.141
*/
rotation(): number;
/**
* Gets or Sets the state of the generator. This allows you to retain the values
* that the generator is using between games, i.e. in a game save file.
*
* To seed this generator with a previously saved state you can pass it as the
* `seed` value in your game config, or call this method directly after Phaser has booted.
*
* Call this method with no parameters to return the current state.
*
* If providing a state it should match the same format that this method
* returns, which is a string with a header `!rnd` followed by the `c`,
* `s0`, `s1` and `s2` values respectively, each comma-delimited.
*
* @method Phaser.Math.RandomDataGenerator#state
* @since 3.0.0
*
* @param {string} [state] - Generator state to be set.
*
* @return {string} The current state of the generator.
*/
state(state?: string | undefined): string;
/**
* Shuffles the given array, using the current seed.
*
* @method Phaser.Math.RandomDataGenerator#shuffle
* @since 3.7.0
*
* @generic T
* @genericUse {T[]} - [array,$return]
*
* @param {T[]} [array] - The array to be shuffled.
*
* @return {T[]} The shuffled array.
*/
shuffle(array?: T[] | undefined): T[];
}
//# sourceMappingURL=RandomDataGenerator.d.ts.map