mirror of
https://github.com/Relintai/sfw.git
synced 2024-11-08 07:52:09 +01:00
Removed the RandomNumberGenerator class.
This commit is contained in:
parent
74e4151ea7
commit
f48208c855
@ -1,29 +0,0 @@
|
||||
/*************************************************************************/
|
||||
/* random_number_generator.cpp */
|
||||
/* From https://github.com/Relintai/pandemonium_engine (MIT) */
|
||||
/*************************************************************************/
|
||||
|
||||
#include "random_number_generator.h"
|
||||
|
||||
RandomNumberGenerator::RandomNumberGenerator() {}
|
||||
|
||||
void RandomNumberGenerator::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_seed", "seed"), &RandomNumberGenerator::set_seed);
|
||||
ClassDB::bind_method(D_METHOD("get_seed"), &RandomNumberGenerator::get_seed);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_state", "state"), &RandomNumberGenerator::set_state);
|
||||
ClassDB::bind_method(D_METHOD("get_state"), &RandomNumberGenerator::get_state);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("randi"), &RandomNumberGenerator::randi);
|
||||
ClassDB::bind_method(D_METHOD("randf"), &RandomNumberGenerator::randf);
|
||||
ClassDB::bind_method(D_METHOD("randfn", "mean", "deviation"), &RandomNumberGenerator::randfn, DEFVAL(0.0), DEFVAL(1.0));
|
||||
ClassDB::bind_method(D_METHOD("randf_range", "from", "to"), &RandomNumberGenerator::randf_range);
|
||||
ClassDB::bind_method(D_METHOD("randi_range", "from", "to"), &RandomNumberGenerator::randi_range);
|
||||
ClassDB::bind_method(D_METHOD("randomize"), &RandomNumberGenerator::randomize);
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "seed"), "set_seed", "get_seed");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "state"), "set_state", "get_state");
|
||||
// Default values are non-deterministic, override for doc generation purposes.
|
||||
ADD_PROPERTY_DEFAULT("seed", 0);
|
||||
ADD_PROPERTY_DEFAULT("state", 0);
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
#ifndef RANDOM_NUMBER_GENERATOR_H
|
||||
#define RANDOM_NUMBER_GENERATOR_H
|
||||
|
||||
/*************************************************************************/
|
||||
/* random_number_generator.h */
|
||||
/* From https://github.com/Relintai/pandemonium_engine (MIT) */
|
||||
/*************************************************************************/
|
||||
|
||||
#include "core/math/random_pcg.h"
|
||||
#include "core/object/reference.h"
|
||||
|
||||
class RandomNumberGenerator : public Reference {
|
||||
GDCLASS(RandomNumberGenerator, Reference);
|
||||
|
||||
protected:
|
||||
RandomPCG randbase;
|
||||
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
_FORCE_INLINE_ void set_seed(uint64_t seed) { randbase.seed(seed); }
|
||||
_FORCE_INLINE_ uint64_t get_seed() { return randbase.get_seed(); }
|
||||
|
||||
_FORCE_INLINE_ void set_state(uint64_t p_state) { randbase.set_state(p_state); }
|
||||
_FORCE_INLINE_ uint64_t get_state() const { return randbase.get_state(); }
|
||||
|
||||
_FORCE_INLINE_ void randomize() { randbase.randomize(); }
|
||||
|
||||
_FORCE_INLINE_ uint32_t randi() { return randbase.rand(); }
|
||||
_FORCE_INLINE_ real_t randf() { return randbase.randf(); }
|
||||
_FORCE_INLINE_ real_t randf_range(real_t from, real_t to) { return randbase.random(from, to); }
|
||||
_FORCE_INLINE_ real_t randfn(real_t mean = 0.0, real_t deviation = 1.0) { return randbase.randfn(mean, deviation); }
|
||||
|
||||
_FORCE_INLINE_ int randi_range(int from, int to) {
|
||||
return randbase.random(from, to);
|
||||
}
|
||||
|
||||
RandomNumberGenerator();
|
||||
};
|
||||
|
||||
#endif // RANDOM_NUMBER_GENERATOR_H
|
Loading…
Reference in New Issue
Block a user