metaforce/Runtime/Character/CBodyController.hpp

113 lines
4.5 KiB
C++
Raw Normal View History

2016-08-15 20:43:04 +00:00
#ifndef __URDE_CBODYCONTROLLER_HPP__
#define __URDE_CBODYCONTROLLER_HPP__
#include "RetroTypes.hpp"
#include "zeus/CQuaternion.hpp"
#include "CharacterCommon.hpp"
2017-07-10 04:55:51 +00:00
#include "CBodyStateCmdMgr.hpp"
#include "CBodyStateInfo.hpp"
2016-08-15 20:43:04 +00:00
namespace urde
{
class CActor;
class CAnimPlaybackParms;
class CFinalInput;
class CPASAnimParmData;
class CRandom16;
class CStateManager;
2017-07-10 04:55:51 +00:00
class CPASDatabase;
2016-08-15 20:43:04 +00:00
class CBodyController
{
2017-07-10 04:55:51 +00:00
CActor& x0_actor;
CBodyStateCmdMgr x4_cmdMgr;
CBodyStateInfo x2a4_bodyStateInfo;
zeus::CQuaternion x2dc_rot;
pas::ELocomotionType x2ec_locomotionType = pas::ELocomotionType::Relaxed;
pas::EFallState x2f0_fallState = pas::EFallState::Zero;
EBodyType x2f4_bodyType;
s32 x2f8_curAnim = -1;
2017-07-14 05:14:19 +00:00
float x2fc_turnSpeed;
2017-07-10 04:55:51 +00:00
union
{
struct
{
bool x300_24_animationOver : 1;
2017-07-14 05:14:19 +00:00
bool x300_25_active : 1;
bool x300_26_frozen : 1;
bool x300_27_hasBeenFrozen : 1;
2017-07-10 04:55:51 +00:00
bool x300_28_playDeathAnims : 1;
};
u32 _dummy = 0;
};
2017-07-14 05:14:19 +00:00
float x304_intoFreezeDur = 0.f;
float x308_frozenDur = 0.f;
float x30c_breakoutDur = 0.f;
float x310_timeFrozen = 0.f;
zeus::CVector3f x314_backedUpForce;
float x320_fireDur = 0.f;
float x324_electrocutionDur = 0.f;
float x328_timeOnFire = 0.f;
float x32c_timeElectrocuting = 0.f;
2017-07-10 04:55:51 +00:00
float x330_restrictedFlyerMoveSpeed = 0.f;
2016-08-15 20:43:04 +00:00
public:
2017-07-14 05:14:19 +00:00
CBodyController(CActor& owner, float turnSpeed, EBodyType bodyType);
pas::EAnimationState GetCurrentStateId() const { return x2a4_bodyStateInfo.GetCurrentStateId(); }
2017-07-10 04:55:51 +00:00
CBodyStateCmdMgr& GetCommandMgr() { return x4_cmdMgr; }
const CBodyStateCmdMgr& GetCommandMgr() const { return x4_cmdMgr; }
void SetDoDeathAnims(bool d) { x300_28_playDeathAnims = d; }
2017-07-14 05:14:19 +00:00
bool IsElectrocuting() const { return x324_electrocutionDur > 0.f; }
bool IsOnFire() const { return x320_fireDur > 0.f; }
bool IsFrozen() const { return x300_26_frozen; }
2017-07-10 04:55:51 +00:00
const CBodyStateInfo& GetBodyStateInfo() const { return x2a4_bodyStateInfo; }
2017-07-14 05:14:19 +00:00
CBodyStateInfo& BodyStateInfo() { return x2a4_bodyStateInfo; }
float GetTurnSpeed() const { return x2fc_turnSpeed; }
2017-07-10 04:55:51 +00:00
pas::ELocomotionType GetLocomotionType() const { return x2ec_locomotionType; }
CActor& GetOwner() const { return x0_actor; }
bool IsAnimationOver() const { return x300_24_animationOver; }
void EnableAnimation(bool e);
bool ShouldPlayDeathAnims() const { return x300_28_playDeathAnims; }
s32 GetCurrentAnimId() const { return x2f8_curAnim; }
2016-08-15 20:43:04 +00:00
void Activate(CStateManager&);
2017-07-14 05:14:19 +00:00
CAdditiveBodyState* GetCurrentAdditiveState()
{ return x2a4_bodyStateInfo.GetCurrentAdditiveState(); }
void SetState(pas::EAnimationState s) { x2a4_bodyStateInfo.SetState(s); }
2016-08-15 20:43:04 +00:00
void Update(float, CStateManager&);
2017-07-14 05:14:19 +00:00
bool ShouldBeHurled() const { return HasBodyState(pas::EAnimationState::Hurled); }
bool HasBodyState(pas::EAnimationState s) const;
pas::EFallState GetFallState() const { return x2f0_fallState; }
void SetFallState(pas::EFallState s) { x2f0_fallState = s; }
2016-08-15 20:43:04 +00:00
void UpdateBody(float, CStateManager&);
2017-07-14 05:14:19 +00:00
void SetAdditiveState(pas::EAnimationState s) { x2a4_bodyStateInfo.SetAdditiveState(s); }
void SetTurnSpeed(float s);
void SetCurrentAnimation(const CAnimPlaybackParms& parms, bool loop, bool noTrans);
2017-07-10 04:55:51 +00:00
float GetAnimTimeRemaining() const;
2016-08-15 20:43:04 +00:00
void SetPlaybackRate(float);
void MultiplyPlaybackRate(float);
2017-07-10 04:55:51 +00:00
void SetDeltaRotation(const zeus::CQuaternion& q) { x2dc_rot *= q; }
2016-08-15 20:43:04 +00:00
void FaceDirection(const zeus::CVector3f&, float);
2017-07-10 04:55:51 +00:00
void FaceDirection3D(const zeus::CVector3f&, const zeus::CVector3f&, float);
2017-07-14 05:14:19 +00:00
static bool HasBodyInfo(CActor& act);
2017-07-10 04:55:51 +00:00
const CPASDatabase& GetPASDatabase() const;
2016-08-15 20:43:04 +00:00
void PlayBestAnimation(const CPASAnimParmData&, CRandom16&);
void LoopBestAnimation(const CPASAnimParmData&, CRandom16&);
2017-07-14 05:14:19 +00:00
void Freeze(float intoFreezeDur, float frozenDur, float breakoutDur);
2016-08-15 20:43:04 +00:00
void UnFreeze();
2017-07-14 05:14:19 +00:00
float GetPercentageFrozen() const;
2016-08-15 20:43:04 +00:00
void SetOnFire(float);
void DouseFlames();
2017-07-14 05:14:19 +00:00
void SetElectrocuting(float dur);
2016-08-15 20:43:04 +00:00
void DouseElectrocuting();
void UpdateFrozenInfo(float, CStateManager&);
2017-07-14 05:14:19 +00:00
bool HasIceBreakoutState() const;
pas::EAnimationState GetCurrentAdditiveStateId() const
{ return x2a4_bodyStateInfo.GetCurrentAdditiveStateId(); }
2017-07-10 04:55:51 +00:00
EBodyType GetBodyType() const { return x2f4_bodyType; }
2017-07-14 05:14:19 +00:00
bool HasBeenFrozen() const { return x300_27_hasBeenFrozen; }
2017-07-10 04:55:51 +00:00
float GetRestrictedFlyerMoveSpeed() const { return x330_restrictedFlyerMoveSpeed; }
2016-08-15 20:43:04 +00:00
};
}
#endif // __URDE_CBODYCONTROLLER_HPP__