Compare commits
2 Commits
2ac9e8399f
...
4ce27c38c6
Author | SHA1 | Date |
---|---|---|
Sara | 4ce27c38c6 | |
Sara | 67abbadbf1 |
2
Doxyfile
2
Doxyfile
|
@ -582,7 +582,7 @@ RESOLVE_UNNAMED_PARAMS = YES
|
|||
# section is generated. This option has no effect if EXTRACT_ALL is enabled.
|
||||
# The default value is: NO.
|
||||
|
||||
HIDE_UNDOC_MEMBERS = NO
|
||||
HIDE_UNDOC_MEMBERS = YES
|
||||
|
||||
# If the HIDE_UNDOC_CLASSES tag is set to YES, doxygen will hide all
|
||||
# undocumented classes that are normally visible in the class hierarchy. If set
|
||||
|
|
|
@ -11,6 +11,7 @@ namespace utils {
|
|||
*
|
||||
* Inheriting classes are intended to keep only data that is relevant for the duration of the current session/match. Use GameState instead if you want data to be saved between sessions.
|
||||
* Will be destroyed when a level is loaded that does not match the same game mode class.
|
||||
* The current active game mode can be gotten from the GameRoot3D singleton instance.
|
||||
*/
|
||||
class GameMode : public gd::Node {
|
||||
GDCLASS(GameMode, gd::Node);
|
||||
|
|
|
@ -44,6 +44,8 @@ void GameRoot3D::_enter_tree() { GDGAMEONLY();
|
|||
|
||||
void GameRoot3D::_ready() { GDGAMEONLY();
|
||||
this->load_level(this->first_boot_level);
|
||||
// TODO: try load save data from file.
|
||||
this->game_state = this->game_state_prototype->duplicate(true);
|
||||
}
|
||||
|
||||
void GameRoot3D::_exit_tree() { GDGAMEONLY();
|
||||
|
@ -250,6 +252,10 @@ gd::Ref<GameState> GameRoot3D::get_game_state_prototype() const {
|
|||
return this->game_state_prototype;
|
||||
}
|
||||
|
||||
gd::RandomNumberGenerator &GameRoot3D::get_rng() {
|
||||
return this->rng;
|
||||
}
|
||||
|
||||
void GameRoot3D::grab_singleton() {
|
||||
if(GameRoot3D::has_singleton()) {
|
||||
this->set_process_mode(PROCESS_MODE_DISABLED);
|
||||
|
|
|
@ -109,6 +109,7 @@ public:
|
|||
gd::Ref<gd::PackedScene> get_first_boot_level() const;
|
||||
void set_game_state_prototype(gd::Ref<GameState> game_state);
|
||||
gd::Ref<GameState> get_game_state_prototype() const;
|
||||
gd::RandomNumberGenerator &get_rng();
|
||||
protected:
|
||||
//! Attempt to make 'this' the current singleton instance.
|
||||
void grab_singleton();
|
||||
|
@ -127,22 +128,57 @@ protected:
|
|||
static bool is_valid_level(gd::Ref<gd::PackedScene> &level);
|
||||
private:
|
||||
static GameRoot3D *singleton_instance;
|
||||
|
||||
uint32_t next_player_id{1}; //!< Next available player ID. Default is 1 because 0 is the "invalid" player id.
|
||||
gd::HashMap<uint32_t, gd::Pair<PlayerInput*, IPlayer*>> players{}; //!< all players by id by input device.
|
||||
|
||||
gd::RandomNumberGenerator rng{}; //!< Global random number generator.
|
||||
gd::HashMap<gd::StringName, Level3D*> levels{}; //!< all currently active levels identified by their resource paths.
|
||||
gd::Vector<SpawnPoint3D*> spawn_points{}; //!< all currently available spawn points.
|
||||
GameMode *game_mode{}; //!< current active gamemode.
|
||||
/*! Next available player ID.
|
||||
*
|
||||
* Default is 1 because 0 is the "invalid" player id.
|
||||
*/
|
||||
uint32_t next_player_id{1};
|
||||
/*! All players by id by input device.
|
||||
*
|
||||
* `get_players()`
|
||||
*/
|
||||
gd::HashMap<uint32_t, gd::Pair<PlayerInput*, IPlayer*>> players{};
|
||||
/*! Global random number generator.
|
||||
*
|
||||
* `&get_rng()`
|
||||
*/
|
||||
gd::RandomNumberGenerator rng{};
|
||||
/*! All currently active levels.
|
||||
*
|
||||
* Each identified by their resource paths.
|
||||
*
|
||||
* `&get_levels()`
|
||||
*/
|
||||
gd::HashMap<gd::StringName, Level3D*> levels{};
|
||||
/*! All currently available spawn points.
|
||||
*/
|
||||
gd::Vector<SpawnPoint3D*> spawn_points{};
|
||||
/*! Current active gamemode.
|
||||
*
|
||||
* Replaced when a level is loaded that references a different game mode.
|
||||
*
|
||||
* `*get_game_mode()`
|
||||
*/
|
||||
GameMode *game_mode{};
|
||||
/*! Active game state.
|
||||
*
|
||||
* Will be assigned loaded save data, or game_state_prototype if no save data is found.
|
||||
*
|
||||
* `*get_game_mode()`
|
||||
*/
|
||||
gd::Ref<GameState> game_state{};
|
||||
|
||||
gd::Ref<gd::PackedScene> first_boot_level{}; //!< The level to boot into on startup.
|
||||
gd::Ref<GameState> game_state_prototype{}; //!< The default game state data used for game_state if no save data is available.
|
||||
/*! The level to boot into on startup.
|
||||
*
|
||||
* `get_first_boot_level()` `set_first_boot_level(value)`
|
||||
*/
|
||||
gd::Ref<gd::PackedScene> first_boot_level{};
|
||||
/*! The default game state data.
|
||||
*
|
||||
* Duplicated and assigned to game_state if no save data is available.
|
||||
*
|
||||
* `get_game_state_prototype()` `set_game_state_prototype(value)`
|
||||
*/
|
||||
gd::Ref<GameState> game_state_prototype{};
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue