feat: started work on damage and combat
This commit is contained in:
		
							parent
							
								
									994885afea
								
							
						
					
					
						commit
						9a4a559f0c
					
				
							
								
								
									
										1
									
								
								src/damageable_entity.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								src/damageable_entity.cpp
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1 @@
 | 
				
			||||||
 | 
					#include "damageable_entity.hpp"
 | 
				
			||||||
							
								
								
									
										12
									
								
								src/damageable_entity.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								src/damageable_entity.hpp
									
									
									
									
									
										Normal 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
									
								
							
							
						
						
									
										12
									
								
								src/health.hpp
									
									
									
									
									
										Normal 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
 | 
				
			||||||
| 
						 | 
					@ -49,6 +49,10 @@ void Player::_physics_process(double delta [[maybe_unused]]) {
 | 
				
			||||||
    this->move_and_slide();
 | 
					    this->move_and_slide();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void Player::damage() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void Player::process_transform_camera(double delta) {
 | 
					void Player::process_transform_camera(double delta) {
 | 
				
			||||||
    this->camera_parent->set_global_position(this->get_global_position());
 | 
					    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)};
 | 
					    float const camera_speed{float(delta) * (this->anim_tree->match_tags(PlayerAnimTree::Aim) ? this->AIMING_CAMERA_ROTATION_SPEED : this->CAMERA_ROTATION_SPEED)};
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,19 +1,21 @@
 | 
				
			||||||
#ifndef TR_PLAYER_HPP
 | 
					#ifndef TR_PLAYER_HPP
 | 
				
			||||||
#define TR_PLAYER_HPP
 | 
					#define TR_PLAYER_HPP
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "utils/player_input.hpp"
 | 
					#include "damageable_entity.hpp"
 | 
				
			||||||
#include "player_anim_tree.hpp"
 | 
					#include "player_anim_tree.hpp"
 | 
				
			||||||
 | 
					#include "utils/player_input.hpp"
 | 
				
			||||||
#include <godot_cpp/classes/character_body3d.hpp>
 | 
					#include <godot_cpp/classes/character_body3d.hpp>
 | 
				
			||||||
#include <godot_cpp/classes/animation_node_state_machine_playback.hpp>
 | 
					#include <godot_cpp/classes/animation_node_state_machine_playback.hpp>
 | 
				
			||||||
namespace gd = godot;
 | 
					namespace gd = godot;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class Player : public gd::CharacterBody3D {
 | 
					class Player : public gd::CharacterBody3D, public DamageableEntity {
 | 
				
			||||||
    GDCLASS(Player, gd::CharacterBody3D);
 | 
					    GDCLASS(Player, gd::CharacterBody3D);
 | 
				
			||||||
    static void _bind_methods();
 | 
					    static void _bind_methods();
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
    virtual void _ready() override;
 | 
					    virtual void _ready() override;
 | 
				
			||||||
    virtual void _process(double delta) override;
 | 
					    virtual void _process(double delta) override;
 | 
				
			||||||
    virtual void _physics_process(double delta) override;
 | 
					    virtual void _physics_process(double delta) override;
 | 
				
			||||||
 | 
					    virtual void damage() override;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void process_transform_camera(double delta);
 | 
					    void process_transform_camera(double delta);
 | 
				
			||||||
    void process_rotate(double delta);
 | 
					    void process_rotate(double delta);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue