stuff
This commit is contained in:
+8
-36
@@ -14,22 +14,8 @@ class Character;
|
||||
class CharacterManager;
|
||||
class CharacterBody;
|
||||
class BodyComponent;
|
||||
|
||||
struct Hitbox {
|
||||
t transform;
|
||||
int damage = 0;
|
||||
float knockback = 0.0f;
|
||||
bool active = false;
|
||||
std::set<Character*> hitTargets;
|
||||
|
||||
bool CanHit(Character* target) const {
|
||||
return target && hitTargets.find(target) == hitTargets.end();
|
||||
}
|
||||
|
||||
void RegisterHit(Character* target) {
|
||||
if (target) hitTargets.insert(target);
|
||||
}
|
||||
};
|
||||
class Ragdoll;
|
||||
class Physics;
|
||||
|
||||
class Action {
|
||||
public:
|
||||
@@ -52,7 +38,6 @@ public:
|
||||
|
||||
class CharacterBody : public t_package {
|
||||
public:
|
||||
int Health = 100;
|
||||
Rig* rig = nullptr;
|
||||
|
||||
std::vector<Animator*> animators;
|
||||
@@ -135,16 +120,14 @@ class Character : public Object, public Renderable {
|
||||
public:
|
||||
CharacterMind* mind = nullptr;
|
||||
CharacterBody* body = nullptr;
|
||||
Ragdoll* ragdoll = nullptr; // when set, physics drives the rig instead of the animators
|
||||
SurfaceTexture surface;
|
||||
glm::vec4 colorOverride = glm::vec4(0.0f); // rgb + strength (0 = keep the rig's own texture)
|
||||
float visualScale = 1.4f; // rig is ~1.8 tall natively; hitbox is 2.5
|
||||
float metallic = 0.0f;
|
||||
float roughness = 0.7f;
|
||||
float ao = 1.0f;
|
||||
float turnSpeed = 12.0f;
|
||||
float punchDamage = 12.0f;
|
||||
float punchReach = 1.15f;
|
||||
float punchAnimationSpeed = 0.6f;
|
||||
glm::vec3 punchHitboxSize = glm::vec3(1.1f, 1.5f, 1.4f);
|
||||
|
||||
void PressInput(char letter);
|
||||
void ReleaseInput(char letter);
|
||||
@@ -152,37 +135,26 @@ public:
|
||||
glm::vec3 GetMovementDirection(const glm::vec3& forward, const glm::vec3& right) const;
|
||||
void SetTurnDirection(const glm::vec3& direction);
|
||||
const glm::vec3& GetTurnDirection() const { return turnDirection; }
|
||||
void SetPunchAnimation(Animation* animation);
|
||||
void SetPunchLooping(bool looping);
|
||||
void Punch(const glm::vec3& lookDirection = glm::vec3(0.0f));
|
||||
void SetWalking(bool walking);
|
||||
glm::vec3 GetForwardDirection() const;
|
||||
const Hitbox& GetPunchHitbox() const { return punchHitbox; }
|
||||
void EnableRagdoll(Physics& physics);
|
||||
|
||||
Character();
|
||||
void Render(Shader& shader) override;
|
||||
bool GetWorldBounds(BoundingBox& bounds) const override;
|
||||
|
||||
void Step(float dt) {
|
||||
if (punchLookLocked && punchAnimator && punchAnimator->isPlaying)
|
||||
turnDirection = punchLookDirection;
|
||||
if (ragdoll) return;
|
||||
TurnToDirection(dt);
|
||||
punchHitbox.active = false;
|
||||
body->Step(dt);
|
||||
}
|
||||
|
||||
private:
|
||||
friend class CharacterManager;
|
||||
|
||||
void TurnToDirection(float dt);
|
||||
void OnPunchAnimationEnd();
|
||||
glm::mat4 GetRigMatrix() const;
|
||||
|
||||
std::set<char> inputLetters;
|
||||
glm::vec3 turnDirection = glm::vec3(0.0f);
|
||||
Animation* punchAnimation = nullptr;
|
||||
Animator* punchAnimator = nullptr;
|
||||
Hitbox punchHitbox;
|
||||
glm::vec3 punchLookDirection = glm::vec3(0.0f);
|
||||
bool punchLookLocked = false;
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user