generated from Persson-dev/Godot-Xmake
refactor player
This commit is contained in:
@@ -1,17 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
#include <blitz/common/Types.h>
|
||||
#include <godot_cpp/classes/animation_tree.hpp>
|
||||
#include <godot_cpp/classes/character_body3d.hpp>
|
||||
#include <godot_cpp/classes/node3d.hpp>
|
||||
#include <blitz/common/Types.h>
|
||||
|
||||
namespace blitz {
|
||||
|
||||
class World;
|
||||
class PlayerController;
|
||||
|
||||
class Player : public godot::Node {
|
||||
class Player : public godot::CharacterBody3D {
|
||||
|
||||
GDCLASS(Player, godot::Node);
|
||||
GDCLASS(Player, godot::CharacterBody3D);
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
@@ -39,9 +40,7 @@ class Player : public godot::Node {
|
||||
|
||||
protected:
|
||||
godot::Node3D* m_Mesh;
|
||||
godot::Node3D* m_Head;
|
||||
godot::AnimationTree* m_AnimationTree;
|
||||
godot::CharacterBody3D* m_Player;
|
||||
|
||||
godot::Vector3 m_SnapVector;
|
||||
PeerID m_PeerId;
|
||||
@@ -51,5 +50,6 @@ class Player : public godot::Node {
|
||||
void BlendAnimation(const godot::String& a_AnimationName, float a_Goal, float a_Delta);
|
||||
|
||||
friend class World;
|
||||
friend class PlayerController;
|
||||
};
|
||||
} // namespace blitz
|
||||
|
||||
@@ -5,29 +5,31 @@
|
||||
|
||||
namespace blitz {
|
||||
|
||||
class FirstPersonPlayer : public Player {
|
||||
GDCLASS(FirstPersonPlayer, godot::Node)
|
||||
class PlayerController : public godot::Node {
|
||||
GDCLASS(PlayerController, godot::Node)
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
FirstPersonPlayer();
|
||||
~FirstPersonPlayer();
|
||||
PlayerController();
|
||||
~PlayerController();
|
||||
|
||||
// Godot overrides
|
||||
void _unhandled_input(const godot::Ref<godot::InputEvent>&);
|
||||
void _physics_process(float delta) override;
|
||||
void _process(float delta);
|
||||
void _ready();
|
||||
|
||||
private:
|
||||
godot::Camera3D* m_Camera;
|
||||
float m_BobTime;
|
||||
float m_Speed;
|
||||
Player* m_Player;
|
||||
godot::Node3D* m_Head;
|
||||
|
||||
void UpdateBobbing(float delta);
|
||||
void UpdateFOV(float delta);
|
||||
void UpdateCamera(const godot::InputEventMouseMotion&);
|
||||
void UpdatePosition(float delta);
|
||||
void UpdateVelocity(float delta);
|
||||
void Shoot();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user