fix: rng is now reference counted
parent
4e231f5be3
commit
d680ebf55f
|
@ -166,7 +166,7 @@ void GameRoot3D::unregister_spawn_point(SpawnPoint3D *spawn_point) {
|
||||||
|
|
||||||
void GameRoot3D::place_player_at_spawnpoint(IPlayer *player) {
|
void GameRoot3D::place_player_at_spawnpoint(IPlayer *player) {
|
||||||
if(this->spawn_points.is_empty()) return;
|
if(this->spawn_points.is_empty()) return;
|
||||||
SpawnPoint3D *spawn_point = this->spawn_points[rng.randi() % this->spawn_points.size()];
|
SpawnPoint3D *spawn_point = this->spawn_points[rng->randi() % this->spawn_points.size()];
|
||||||
player->spawn_at_position(spawn_point->get_global_transform());
|
player->spawn_at_position(spawn_point->get_global_transform());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -253,7 +253,7 @@ gd::Ref<GameState> GameRoot3D::get_game_state_prototype() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
gd::RandomNumberGenerator &GameRoot3D::get_rng() {
|
gd::RandomNumberGenerator &GameRoot3D::get_rng() {
|
||||||
return this->rng;
|
return *this->rng.ptr();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameRoot3D::grab_singleton() {
|
void GameRoot3D::grab_singleton() {
|
||||||
|
|
|
@ -142,7 +142,7 @@ private:
|
||||||
*
|
*
|
||||||
* `&get_rng()`
|
* `&get_rng()`
|
||||||
*/
|
*/
|
||||||
gd::RandomNumberGenerator rng{};
|
gd::Ref<gd::RandomNumberGenerator> rng{};
|
||||||
/*! All currently active levels.
|
/*! All currently active levels.
|
||||||
*
|
*
|
||||||
* Each identified by their resource paths.
|
* Each identified by their resource paths.
|
||||||
|
|
Loading…
Reference in New Issue