diff --git a/src/rally_rush_game_mode.cpp b/src/rally_rush_game_mode.cpp index 78f0fad..e9983de 100644 --- a/src/rally_rush_game_mode.cpp +++ b/src/rally_rush_game_mode.cpp @@ -1,5 +1,8 @@ #include "rally_rush_game_mode.hpp" +#include "godot_cpp/classes/resource_loader.hpp" +#include "utils/game_root.hpp" #include "utils/godot_macros.h" +#include "utils/level.hpp" namespace godot { void RallyRushGameMode::_bind_methods() { @@ -18,4 +21,18 @@ void RallyRushGameMode::notify_key_found() { if(num_keys_found == 3) this->emit_signal("all_keys_found"); } + +void RallyRushGameMode::notify_player_death() { + GameRoot3D *root = GameRoot3D::get_singleton(); + HashMap levels = root->get_levels(); + for(KeyValue &kvp : levels) + if(kvp.value->is_inside_tree()) + kvp.value->queue_free(); + root->get_levels().clear(); + root->load_level(ResourceLoader::get_singleton()->load("res://game_end_screen.tscn")); + root->reset_game_mode(); +} + +void RallyRushGameMode::notify_player_escaped() { +} } diff --git a/src/rally_rush_game_mode.hpp b/src/rally_rush_game_mode.hpp index f8c5f0d..d106682 100644 --- a/src/rally_rush_game_mode.hpp +++ b/src/rally_rush_game_mode.hpp @@ -10,6 +10,8 @@ class RallyRushGameMode : public GameMode { public: int get_num_found_keys(); void notify_key_found(); + void notify_player_death(); + void notify_player_escaped(); private: int num_keys_found{0}; }; diff --git a/src/register_types.cpp b/src/register_types.cpp index 9a0bc7f..6850255 100644 --- a/src/register_types.cpp +++ b/src/register_types.cpp @@ -1,9 +1,12 @@ #include "register_types.h" #include "car_physics.hpp" #include "car_player.hpp" +#include "end_screen.hpp" #include "game_ui.hpp" #include "key_pickup.hpp" +#include "menu_ui.hpp" #include "rally_rush_game_mode.hpp" +#include "turret.hpp" #include "utils/game_mode.hpp" #include "utils/game_root.hpp" #include "utils/game_state.hpp" @@ -34,6 +37,9 @@ void initialize_gdextension_types(ModuleInitializationLevel p_level) ClassDB::register_class(); ClassDB::register_class(); ClassDB::register_class(); + ClassDB::register_class(); + ClassDB::register_class(); + ClassDB::register_class(); } extern "C"