fix: rng is now reference counted

main
Sara 2024-06-11 09:09:11 +02:00
parent 4e231f5be3
commit d680ebf55f
2 changed files with 3 additions and 3 deletions

View File

@ -166,7 +166,7 @@ void GameRoot3D::unregister_spawn_point(SpawnPoint3D *spawn_point) {
void GameRoot3D::place_player_at_spawnpoint(IPlayer *player) {
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());
}
@ -253,7 +253,7 @@ gd::Ref<GameState> GameRoot3D::get_game_state_prototype() const {
}
gd::RandomNumberGenerator &GameRoot3D::get_rng() {
return this->rng;
return *this->rng.ptr();
}
void GameRoot3D::grab_singleton() {

View File

@ -142,7 +142,7 @@ private:
*
* `&get_rng()`
*/
gd::RandomNumberGenerator rng{};
gd::Ref<gd::RandomNumberGenerator> rng{};
/*! All currently active levels.
*
* Each identified by their resource paths.