godot-cpp-utils
A collection of utility classes, functions and macros for use with Godot and GDExtension.
Loading...
Searching...
No Matches
player.hpp
1#ifndef UTILS_PLAYER_HPP
2#define UTILS_PLAYER_HPP
3
4#include <cstdint>
5#include <optional>
6#include <godot_cpp/variant/transform3d.hpp>
7
8namespace gd = godot;
9
10namespace godot { class Node; }
11
12namespace utils {
13class PlayerInput;
14
19class IPlayer {
20friend class GameRoot3D;
21public:
26 virtual void setup_player_input(PlayerInput *input) = 0;
28 virtual gd::Node *to_node() = 0;
30 virtual void spawn_at_position(gd::Transform3D const &at) = 0;
31
32 uint32_t get_player_id();
33
34private:
35 std::optional<uint32_t> player_id{std::nullopt};
36};
37}
38
39#endif // !UTILS_PLAYER_HPP
40
The root of a game.
Definition game_root.hpp:28
Interface required for player nodes.
Definition player.hpp:19
virtual void setup_player_input(PlayerInput *input)=0
Called by GameRoot3D when this player is instantiated or assigned a new PlayerInput.
virtual void spawn_at_position(gd::Transform3D const &at)=0
Spawn the player at a given transform, usually the global transform of a SpawnPoint3D.
uint32_t get_player_id()
Returns the player id assigned to this instance.
Definition player.cpp:4
virtual gd::Node * to_node()=0
Convert IPlayer instance to node.
An event-driven input observer.
Definition player_input.hpp:18