feat: added rally rush gamemode class

This commit is contained in:
Sara 2024-05-17 15:09:23 +02:00
parent 60e6640cdd
commit 5cf006e4d7
3 changed files with 41 additions and 0 deletions

View file

@ -0,0 +1,21 @@
#include "rally_rush_game_mode.hpp"
#include "utils/godot_macros.h"
namespace godot {
void RallyRushGameMode::_bind_methods() {
#define CLASSNAME RallyRushGameMode
GDSIGNAL("key_found", PropertyInfo(Variant::INT, "total_found"));
GDSIGNAL("all_keys_found");
}
int RallyRushGameMode::get_num_found_keys() {
return this->num_keys_found;
}
void RallyRushGameMode::notify_key_found() {
++this->num_keys_found;
this->emit_signal("key_found", num_keys_found);
if(num_keys_found == 3)
this->emit_signal("all_keys_found");
}
}

View file

@ -0,0 +1,18 @@
#ifndef RALLY_RUSH_GAME_MODE_HPP
#define RALLY_RUSH_GAME_MODE_HPP
#include "utils/game_mode.hpp"
namespace godot {
class RallyRushGameMode : public GameMode {
GDCLASS(RallyRushGameMode, GameMode);
static void _bind_methods();
public:
int get_num_found_keys();
void notify_key_found();
private:
int num_keys_found{0};
};
}
#endif // !RALLY_RUSH_GAME_MODE_HPP

View file

@ -1,6 +1,7 @@
#include "register_types.h"
#include "car_physics.hpp"
#include "car_player.hpp"
#include "rally_rush_game_mode.hpp"
#include "utils/game_mode.hpp"
#include "utils/game_root.hpp"
#include "utils/game_state.hpp"
@ -28,6 +29,7 @@ void initialize_gdextension_types(ModuleInitializationLevel p_level)
ClassDB::register_class<CarPhysics>();
ClassDB::register_class<CarPlayer>();
ClassDB::register_class<RallyRushGameMode>();
}
extern "C"