feat: tunnels game mode now enables getting player
This commit is contained in:
parent
1fdfca5bb7
commit
5ab4540cc5
|
@ -1,6 +1,24 @@
|
||||||
#include "tunnels_game_mode.hpp"
|
#include "tunnels_game_mode.hpp"
|
||||||
|
#include "godot_cpp/variant/utility_functions.hpp"
|
||||||
|
#include "utils/game_root.hpp"
|
||||||
|
#include "utils/godot_macros.h"
|
||||||
|
#include <godot_cpp/classes/node.hpp>
|
||||||
|
|
||||||
namespace godot {
|
namespace godot {
|
||||||
void TunnelsGameMode::_bind_methods() {
|
void TunnelsGameMode::_bind_methods() {
|
||||||
|
#define CLASSNAME TunnelsGameMode
|
||||||
|
GDFUNCTION_ARGS(on_player_spawned, "player");
|
||||||
|
}
|
||||||
|
|
||||||
|
void TunnelsGameMode::_begin() {
|
||||||
|
GameRoot::get_singleton()->connect("player_spawned", Callable(this, "on_player_spawned"));
|
||||||
|
}
|
||||||
|
|
||||||
|
void TunnelsGameMode::on_player_spawned(Node *player) {
|
||||||
|
this->player = Object::cast_to<TunnelsPlayer>(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
TunnelsPlayer *TunnelsGameMode::get_player_instance() const {
|
||||||
|
return this->player;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
#ifndef TUNNELS_GAME_MODE_HPP
|
#ifndef TUNNELS_GAME_MODE_HPP
|
||||||
#define TUNNELS_GAME_MODE_HPP
|
#define TUNNELS_GAME_MODE_HPP
|
||||||
|
|
||||||
|
#include "tunnels_game_state.hpp"
|
||||||
|
#include "tunnels_player.hpp"
|
||||||
#include "utils/game_mode.hpp"
|
#include "utils/game_mode.hpp"
|
||||||
|
|
||||||
namespace godot {
|
namespace godot {
|
||||||
|
@ -8,6 +10,13 @@ class TunnelsGameMode : public GameMode {
|
||||||
GDCLASS(TunnelsGameMode, GameMode)
|
GDCLASS(TunnelsGameMode, GameMode)
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
public:
|
public:
|
||||||
|
virtual void _begin() override;
|
||||||
|
|
||||||
|
void on_player_spawned(Node *player);
|
||||||
|
|
||||||
|
TunnelsPlayer *get_player_instance() const;
|
||||||
|
private:
|
||||||
|
TunnelsPlayer *player{nullptr};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue