diff --git a/src/player_character.cpp b/src/player_character.cpp index ff9da94..6a62956 100644 --- a/src/player_character.cpp +++ b/src/player_character.cpp @@ -12,6 +12,7 @@ void PlayerCharacter::_bind_methods() { void PlayerCharacter::_enter_tree() { GDGAMEONLY(); this->nav_agent = this->get_node("NavigationAgent3D"); this->target_rotation = this->get_global_transform().get_basis().get_quaternion(); + this->health = this->get_node("Health"); } void PlayerCharacter::_process(double delta_time) { GDGAMEONLY(); @@ -51,6 +52,14 @@ Ref PlayerCharacter::get_rotation_speed_curve() const { return this->rotation_speed_curve; } +Health *PlayerCharacter::get_health() { + return this->health; +} + +Health const *PlayerCharacter::get_health() const { + return this->health; +} + void PlayerCharacter::process_ai(double delta_time) { this->velocity_target = this->nav_agent->get_velocity(); } diff --git a/src/player_character.hpp b/src/player_character.hpp index fbb8038..e683c47 100644 --- a/src/player_character.hpp +++ b/src/player_character.hpp @@ -2,12 +2,14 @@ #define PLAYER_CHARACTER_HPP #include "godot_cpp/classes/curve.hpp" +#include "health.hpp" #include namespace godot { class NavigationAgent3D; -class PlayerCharacter : public CharacterBody3D { +class PlayerCharacter : public CharacterBody3D, + public IHealthEntity { GDCLASS(PlayerCharacter, CharacterBody3D); static void _bind_methods(); public: @@ -20,6 +22,9 @@ public: void set_rotation_speed_curve(Ref curve); Ref get_rotation_speed_curve() const; + + virtual Health *get_health() override; + virtual Health const *get_health() const override; protected: void process_ai(double delta_time); void process_rotation(double delta_time); @@ -28,6 +33,7 @@ private: Basis target_rotation{}; NavigationAgent3D *nav_agent{nullptr}; bool mode_manual{false}; + Health *health{nullptr}; Ref rotation_speed_curve{};