From 9a4a559f0c43e873a3f6cbe00e1eb74258290320 Mon Sep 17 00:00:00 2001 From: Sara Date: Wed, 4 Dec 2024 20:56:15 +0100 Subject: [PATCH] feat: started work on damage and combat --- src/damageable_entity.cpp | 1 + src/damageable_entity.hpp | 12 ++++++++++++ src/health.hpp | 12 ++++++++++++ src/player.cpp | 4 ++++ src/player.hpp | 6 ++++-- 5 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 src/damageable_entity.cpp create mode 100644 src/damageable_entity.hpp create mode 100644 src/health.hpp diff --git a/src/damageable_entity.cpp b/src/damageable_entity.cpp new file mode 100644 index 0000000..2c787bd --- /dev/null +++ b/src/damageable_entity.cpp @@ -0,0 +1 @@ +#include "damageable_entity.hpp" diff --git a/src/damageable_entity.hpp b/src/damageable_entity.hpp new file mode 100644 index 0000000..fcbe69d --- /dev/null +++ b/src/damageable_entity.hpp @@ -0,0 +1,12 @@ +#ifndef DAMAGEABLE_ENTITY_HPP +#define DAMAGEABLE_ENTITY_HPP + +#include +namespace gd = godot; + +class DamageableEntity { +public: + virtual void damage() = 0; +}; + +#endif // !DAMAGEABLE_ENTITY_HPP diff --git a/src/health.hpp b/src/health.hpp new file mode 100644 index 0000000..35e733b --- /dev/null +++ b/src/health.hpp @@ -0,0 +1,12 @@ +#ifndef HEALTH_HPP +#define HEALTH_HPP + +#include +namespace gd = godot; + +class DamageableEntity { +public: + Health *get_health(); +}; + +#endif // !HEALTH_HPP diff --git a/src/player.cpp b/src/player.cpp index c574dc6..1773a58 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -49,6 +49,10 @@ void Player::_physics_process(double delta [[maybe_unused]]) { this->move_and_slide(); } +void Player::damage() { + +} + void Player::process_transform_camera(double delta) { this->camera_parent->set_global_position(this->get_global_position()); float const camera_speed{float(delta) * (this->anim_tree->match_tags(PlayerAnimTree::Aim) ? this->AIMING_CAMERA_ROTATION_SPEED : this->CAMERA_ROTATION_SPEED)}; diff --git a/src/player.hpp b/src/player.hpp index 6017746..fd32138 100644 --- a/src/player.hpp +++ b/src/player.hpp @@ -1,19 +1,21 @@ #ifndef TR_PLAYER_HPP #define TR_PLAYER_HPP -#include "utils/player_input.hpp" +#include "damageable_entity.hpp" #include "player_anim_tree.hpp" +#include "utils/player_input.hpp" #include #include namespace gd = godot; -class Player : public gd::CharacterBody3D { +class Player : public gd::CharacterBody3D, public DamageableEntity { GDCLASS(Player, gd::CharacterBody3D); static void _bind_methods(); public: virtual void _ready() override; virtual void _process(double delta) override; virtual void _physics_process(double delta) override; + virtual void damage() override; void process_transform_camera(double delta); void process_rotate(double delta);