2018-11-05 06:12:53 +00:00
|
|
|
#pragma once
|
2019-09-22 21:52:05 +00:00
|
|
|
|
|
|
|
#include <bitset>
|
|
|
|
|
|
|
|
#include "Runtime/RetroTypes.hpp"
|
|
|
|
#include "Runtime/rstl.hpp"
|
|
|
|
#include "Runtime/Character/CharacterCommon.hpp"
|
|
|
|
#include "Runtime/Weapon/WeaponCommon.hpp"
|
|
|
|
|
|
|
|
#include <zeus/CVector3f.hpp>
|
2018-11-05 06:12:53 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
namespace urde {
|
2018-11-05 06:12:53 +00:00
|
|
|
class CDamageInfo;
|
2019-09-22 21:52:05 +00:00
|
|
|
class CPatterned;
|
2018-11-05 06:12:53 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
enum class EKnockBackType { Direct, Radius };
|
2018-11-05 06:12:53 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
enum class EKnockBackVariant { Small, Medium, Large };
|
2018-11-05 06:12:53 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
enum class EKnockBackWeaponType {
|
|
|
|
Invalid = -1,
|
|
|
|
Power,
|
|
|
|
PowerCharged,
|
|
|
|
PowerComboed,
|
|
|
|
PowerComboedDirect,
|
|
|
|
Wave,
|
|
|
|
WaveCharged,
|
|
|
|
WaveComboed,
|
|
|
|
WaveComboedDirect,
|
|
|
|
Ice,
|
|
|
|
IceCharged,
|
|
|
|
IceComboed,
|
|
|
|
IceComboedDirect,
|
|
|
|
Plasma,
|
|
|
|
PlasmaCharged,
|
|
|
|
PlasmaComboed,
|
|
|
|
Missile,
|
|
|
|
Bomb,
|
|
|
|
PowerBomb,
|
|
|
|
Phazon
|
2018-11-05 06:12:53 +00:00
|
|
|
};
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
enum class EKnockBackCharacterState { Alive, Dead, FrozenAlive, FrozenDead };
|
2018-11-05 06:12:53 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
enum class EKnockBackAnimationState { Invalid = -1, None, Flinch, KnockBack, Hurled, Fall };
|
2018-11-05 06:12:53 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
enum class EKnockBackAnimationFollowUp {
|
|
|
|
Invalid = -1,
|
|
|
|
None,
|
|
|
|
Freeze,
|
|
|
|
Shock,
|
|
|
|
Burn,
|
|
|
|
PhazeOut,
|
|
|
|
Death,
|
|
|
|
ExplodeDeath,
|
|
|
|
IceDeath,
|
|
|
|
BurnDeath,
|
|
|
|
LaggedBurnDeath
|
2018-11-05 06:12:53 +00:00
|
|
|
};
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
class CKnockBackController {
|
2018-11-05 06:12:53 +00:00
|
|
|
public:
|
2018-12-08 05:30:43 +00:00
|
|
|
struct KnockBackParms {
|
2020-04-11 05:50:10 +00:00
|
|
|
EKnockBackAnimationState x0_animState = EKnockBackAnimationState::None;
|
|
|
|
EKnockBackAnimationFollowUp x4_animFollowup = EKnockBackAnimationFollowUp::None;
|
|
|
|
float x8_followupDuration = 0.f;
|
|
|
|
float xc_intoFreezeDur = 0.f;
|
2018-12-08 05:30:43 +00:00
|
|
|
};
|
|
|
|
|
2018-11-05 06:12:53 +00:00
|
|
|
private:
|
2018-12-08 05:30:43 +00:00
|
|
|
friend class CPatterned;
|
|
|
|
EKnockBackVariant x0_variant;
|
2020-04-11 05:50:10 +00:00
|
|
|
KnockBackParms x4_activeParms{};
|
2018-12-08 05:30:43 +00:00
|
|
|
EWeaponType x14_deferWeaponType = EWeaponType::None;
|
|
|
|
EKnockBackAnimationState x18_minAnimState = EKnockBackAnimationState::None;
|
|
|
|
EKnockBackAnimationState x1c_maxAnimState = EKnockBackAnimationState::Fall;
|
|
|
|
u32 x20_impulseDurationIdx = 0;
|
2018-12-27 06:26:34 +00:00
|
|
|
rstl::reserved_vector<std::pair<float, float>, 5> x24_;
|
2018-12-08 05:30:43 +00:00
|
|
|
zeus::CVector3f x50_impulseDir;
|
|
|
|
float x5c_impulseMag = 0.f;
|
|
|
|
float x60_impulseRemTime = 0.f;
|
|
|
|
float x64_flinchRemTime = 0.f;
|
|
|
|
float x68_deferRemTime = 0.f;
|
|
|
|
u32 x6c_ = 0;
|
|
|
|
u32 x70_ = 0;
|
|
|
|
u32 x74_ = 0;
|
|
|
|
pas::ESeverity x7c_severity = pas::ESeverity::One;
|
2020-04-17 17:17:01 +00:00
|
|
|
std::bitset<5> x80_availableStates{0b11111};
|
2020-04-20 04:57:50 +00:00
|
|
|
bool x81_24_autoResetImpulse : 1 = true;
|
|
|
|
bool x81_25_enableFreeze : 1 = true;
|
|
|
|
bool x81_26_enableShock : 1 = false;
|
|
|
|
bool x81_27_enableBurn : 1 = true;
|
|
|
|
bool x81_28_enableBurnDeath : 1 = true;
|
|
|
|
bool x81_29_enableExplodeDeath : 1 = true;
|
|
|
|
bool x81_30_enableLaggedBurnDeath : 1 = true;
|
|
|
|
bool x81_31_ : 1 = true;
|
|
|
|
bool x82_24_ : 1 = true;
|
|
|
|
bool x82_25_inDeferredKnockBack : 1 = false;
|
|
|
|
bool x82_26_locomotionDuringElectrocution : 1 = false;
|
2018-12-08 05:30:43 +00:00
|
|
|
void ApplyImpulse(float dt, CPatterned& parent);
|
|
|
|
bool TickDeferredTimer(float dt);
|
2020-04-17 04:58:27 +00:00
|
|
|
EKnockBackCharacterState GetKnockBackCharacterState(const CPatterned& parent) const;
|
2020-04-17 05:03:10 +00:00
|
|
|
void ValidateState(const CPatterned& parent);
|
2020-04-17 05:05:47 +00:00
|
|
|
float CalculateExtraHurlVelocity(CStateManager& mgr, float magnitude, float kbResistance) const;
|
2018-12-08 05:30:43 +00:00
|
|
|
void DoKnockBackAnimation(const zeus::CVector3f& backVec, CStateManager& mgr, CPatterned& parent, float magnitude);
|
2020-04-17 05:03:10 +00:00
|
|
|
void ResetKnockBackImpulse(const CPatterned& parent, const zeus::CVector3f& backVec, float magnitude);
|
2018-12-08 05:30:43 +00:00
|
|
|
void DoDeferredKnockBack(CStateManager& mgr, CPatterned& parent);
|
|
|
|
EKnockBackWeaponType GetKnockBackWeaponType(const CDamageInfo& info, EWeaponType wType, EKnockBackType type);
|
2020-04-17 05:03:10 +00:00
|
|
|
void SelectDamageState(const CPatterned& parent, const CDamageInfo& info, EWeaponType wType, EKnockBackType type);
|
2018-12-08 05:30:43 +00:00
|
|
|
|
2018-11-05 06:12:53 +00:00
|
|
|
public:
|
2018-12-08 05:30:43 +00:00
|
|
|
explicit CKnockBackController(EKnockBackVariant variant);
|
|
|
|
void SetKnockBackVariant(EKnockBackVariant v) { x0_variant = v; }
|
|
|
|
void DeferKnockBack(EWeaponType tp) {
|
|
|
|
x14_deferWeaponType = tp;
|
|
|
|
x68_deferRemTime = 0.05f;
|
|
|
|
}
|
|
|
|
void sub80233d40(int i, float f1, float f2);
|
|
|
|
void SetAutoResetImpulse(bool b);
|
|
|
|
void SetImpulseDurationIdx(u32 i) { x20_impulseDurationIdx = i; }
|
|
|
|
void SetAnimationStateRange(EKnockBackAnimationState a, EKnockBackAnimationState b) {
|
|
|
|
x18_minAnimState = a;
|
|
|
|
x1c_maxAnimState = b;
|
|
|
|
}
|
|
|
|
void Update(float dt, CStateManager& mgr, CPatterned& parent);
|
|
|
|
void KnockBack(const zeus::CVector3f& backVec, CStateManager& mgr, CPatterned& parent, const CDamageInfo& info,
|
|
|
|
EKnockBackType type, float magnitude);
|
2020-03-13 08:11:17 +00:00
|
|
|
void SetSeverity(pas::ESeverity v) { x7c_severity = v; }
|
2018-12-08 05:30:43 +00:00
|
|
|
void SetEnableFreeze(bool b) { x81_25_enableFreeze = b; }
|
|
|
|
void SetEnableShock(bool b) { x81_26_enableShock = b; }
|
|
|
|
void SetEnableBurn(bool b) { x81_27_enableBurn = b; }
|
|
|
|
void SetEnableBurnDeath(bool b) { x81_28_enableBurnDeath = b; }
|
|
|
|
void SetEnableExplodeDeath(bool b) { x81_29_enableExplodeDeath = b; }
|
|
|
|
void SetEnableLaggedBurnDeath(bool b) { x81_30_enableLaggedBurnDeath = b; }
|
|
|
|
void SetX81_31(bool b) { x81_31_ = b; }
|
|
|
|
void SetX82_24(bool b) { x82_24_ = b; }
|
|
|
|
void SetLocomotionDuringElectrocution(bool b) { x82_26_locomotionDuringElectrocution = b; }
|
|
|
|
const KnockBackParms& GetActiveParms() const { return x4_activeParms; }
|
|
|
|
EKnockBackVariant GetVariant() const { return x0_variant; }
|
|
|
|
float GetFlinchRemTime() const { return x64_flinchRemTime; }
|
2018-12-13 07:39:16 +00:00
|
|
|
void SetAvailableState(EKnockBackAnimationState s, bool b) { x80_availableStates.set(size_t(s), b); }
|
|
|
|
bool TestAvailableState(EKnockBackAnimationState s) const { return x80_availableStates.test(size_t(s)); }
|
2018-11-05 06:12:53 +00:00
|
|
|
};
|
|
|
|
|
2020-03-13 08:11:17 +00:00
|
|
|
} // namespace urde
|