feat: started work on damage and combat

main
Sara 2024-12-04 20:56:15 +01:00
parent 994885afea
commit 9a4a559f0c
5 changed files with 33 additions and 2 deletions

View File

@ -0,0 +1 @@
#include "damageable_entity.hpp"

12
src/damageable_entity.hpp Normal file
View File

@ -0,0 +1,12 @@
#ifndef DAMAGEABLE_ENTITY_HPP
#define DAMAGEABLE_ENTITY_HPP
#include <godot_cpp/classes/node.hpp>
namespace gd = godot;
class DamageableEntity {
public:
virtual void damage() = 0;
};
#endif // !DAMAGEABLE_ENTITY_HPP

12
src/health.hpp Normal file
View File

@ -0,0 +1,12 @@
#ifndef HEALTH_HPP
#define HEALTH_HPP
#include <godot_cpp/classes/node.hpp>
namespace gd = godot;
class DamageableEntity {
public:
Health *get_health();
};
#endif // !HEALTH_HPP

View File

@ -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)};

View File

@ -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 <godot_cpp/classes/character_body3d.hpp>
#include <godot_cpp/classes/animation_node_state_machine_playback.hpp>
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);