2016-04-25 05:03:38 +00:00
|
|
|
#ifndef __URDE_CPATTERNED_HPP__
|
|
|
|
#define __URDE_CPATTERNED_HPP__
|
|
|
|
|
|
|
|
#include "CAi.hpp"
|
2016-08-15 20:43:04 +00:00
|
|
|
#include "Character/CBodyController.hpp"
|
2018-09-07 23:51:07 +00:00
|
|
|
#include "Character/CSteeringBehaviors.hpp"
|
|
|
|
#include "Graphics/CVertexMorphEffect.hpp"
|
|
|
|
#include "Particle/CGenDescription.hpp"
|
|
|
|
#include "Particle/CElectricDescription.hpp"
|
2017-06-12 04:23:34 +00:00
|
|
|
#include "TCastTo.hpp"
|
2018-09-07 23:51:07 +00:00
|
|
|
#include "CDamageInfo.hpp"
|
2016-04-25 05:03:38 +00:00
|
|
|
|
2018-09-14 00:49:34 +00:00
|
|
|
#ifndef DEFINE_PATTERNED
|
|
|
|
#define DEFINE_PATTERNED(type) static constexpr ECharacter CharacterType = ECharacter::type;
|
|
|
|
#endif
|
|
|
|
|
2016-04-25 05:03:38 +00:00
|
|
|
namespace urde
|
|
|
|
{
|
|
|
|
class CPatternedInfo;
|
2018-09-14 00:49:34 +00:00
|
|
|
class CProjectileInfo;
|
2018-09-07 23:51:07 +00:00
|
|
|
class CPatternedUnknown2
|
|
|
|
{
|
|
|
|
friend class CPatterned;
|
|
|
|
u8 x80_ = 0;
|
|
|
|
union
|
|
|
|
{
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
bool x81_24_ : 1;
|
|
|
|
bool x81_25_ : 1;
|
|
|
|
bool x81_26_ : 1;
|
|
|
|
bool x81_27_ : 1;
|
|
|
|
bool x81_28_ : 1;
|
|
|
|
bool x81_29_ : 1;
|
|
|
|
bool x81_30_ : 1;
|
|
|
|
bool x81_31_ : 1;
|
|
|
|
bool x82_24_ : 1;
|
|
|
|
bool x82_25_ : 1;
|
|
|
|
bool x82_26_ : 1;
|
|
|
|
};
|
|
|
|
u32 dummy = 0;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2016-04-25 05:03:38 +00:00
|
|
|
class CPatterned : public CAi
|
|
|
|
{
|
|
|
|
public:
|
2018-09-07 23:51:07 +00:00
|
|
|
static const zeus::CColor skDamageColor;
|
2017-06-12 04:23:34 +00:00
|
|
|
enum class ECharacter
|
2016-04-25 05:03:38 +00:00
|
|
|
{
|
2017-06-12 04:23:34 +00:00
|
|
|
AtomicAlpha = 0,
|
|
|
|
AtomicBeta = 1,
|
|
|
|
Babygoth = 2,
|
|
|
|
Beetle = 3,
|
|
|
|
BloodFlower = 4,
|
|
|
|
Burrower = 5,
|
|
|
|
ChozoGhost = 6,
|
|
|
|
Drone = 7,
|
|
|
|
ElitePirate = 8,
|
|
|
|
EyeBall = 9,
|
|
|
|
FireFlea = 10,
|
|
|
|
Flaahgra = 11,
|
|
|
|
FlaahgraTentacle = 12,
|
|
|
|
FlickerBat = 13,
|
|
|
|
FlyingPirate = 14,
|
|
|
|
IceSheeegoth = 15,
|
|
|
|
JellyZap = 16,
|
|
|
|
Magdolite = 17,
|
|
|
|
Metaree = 18,
|
|
|
|
Metroid = 19,
|
|
|
|
MetroidBeta = 20,
|
|
|
|
MetroidPrimeExo = 21,
|
|
|
|
MetroidPrimeEssence = 22,
|
|
|
|
NewIntroBoss = 23,
|
|
|
|
Parasite = 24,
|
|
|
|
PuddleSpore = 27,
|
|
|
|
PuddleToad = 28,
|
|
|
|
Puffer = 29,
|
|
|
|
Ridley = 30,
|
|
|
|
Ripper = 31,
|
|
|
|
Seedling = 32,
|
|
|
|
SpacePirate = 34,
|
|
|
|
SpankWeed = 35,
|
|
|
|
PhazonHealingNodule = 35,
|
|
|
|
Thardus = 36,
|
|
|
|
ThardusRockProjectile = 37,
|
|
|
|
Tryclops = 38,
|
|
|
|
WarWasp = 39,
|
|
|
|
EnergyBall = 40
|
2016-04-25 05:03:38 +00:00
|
|
|
};
|
|
|
|
enum class EFlavorType
|
|
|
|
{
|
2016-05-18 03:57:43 +00:00
|
|
|
Zero = 0,
|
|
|
|
One = 1
|
2016-04-25 05:03:38 +00:00
|
|
|
};
|
|
|
|
enum class EMovementType
|
|
|
|
{
|
2016-04-25 05:46:28 +00:00
|
|
|
Ground = 0,
|
|
|
|
Flyer = 1
|
2016-04-25 05:03:38 +00:00
|
|
|
};
|
|
|
|
enum class EColliderType
|
|
|
|
{
|
2017-08-21 00:29:59 +00:00
|
|
|
Zero = 0,
|
2016-04-25 05:46:28 +00:00
|
|
|
One = 1
|
2016-04-25 05:03:38 +00:00
|
|
|
};
|
2016-12-19 18:27:58 +00:00
|
|
|
|
2017-08-21 00:29:59 +00:00
|
|
|
protected:
|
2018-09-07 23:51:07 +00:00
|
|
|
u32 x2d8_ = -1;
|
|
|
|
TUniqueId x2dc_ = kInvalidUniqueId;
|
2018-09-16 23:22:35 +00:00
|
|
|
zeus::CVector3f x2e0_destPos;
|
2018-09-07 23:51:07 +00:00
|
|
|
zeus::CVector3f x2ec_;
|
|
|
|
float x2f8_ = 0.f;
|
|
|
|
float x2fc_minAttackRange;
|
|
|
|
float x300_maxAttackRange;
|
|
|
|
float x304_averageAttackTime;
|
|
|
|
float x308_attackTimeVariation;
|
|
|
|
u32 x30c_ = 0;
|
|
|
|
zeus::CVector3f x310_;
|
2018-09-14 00:49:34 +00:00
|
|
|
zeus::CVector3f x31c_;
|
2017-07-10 04:55:51 +00:00
|
|
|
union
|
|
|
|
{
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
bool x328_24_ : 1;
|
|
|
|
bool x328_25_ : 1;
|
|
|
|
bool x328_26_ : 1;
|
|
|
|
bool x328_27_onGround : 1;
|
|
|
|
};
|
|
|
|
u32 _dummy = 0;
|
|
|
|
};
|
2017-07-14 05:14:19 +00:00
|
|
|
|
2018-09-07 23:51:07 +00:00
|
|
|
u32 x32c_;
|
|
|
|
CStateMachineState x330_stateMachineState;
|
|
|
|
ECharacter x34c_character;
|
|
|
|
zeus::CVector3f x350_;
|
|
|
|
zeus::CVector3f x35c_;
|
|
|
|
zeus::CVector3f x368_;
|
|
|
|
u32 x374_ = 0;
|
|
|
|
u32 x378_ = 2;
|
|
|
|
u32 x37c_ = 1;
|
|
|
|
u32 x380_ = 0;
|
|
|
|
u32 x384_ = 0;
|
|
|
|
s32 x388_anim;
|
|
|
|
/*x38c_*/
|
|
|
|
u32 x390_ = 0;
|
|
|
|
u32 x394_ = 0;
|
|
|
|
u32 x398_ = 0;
|
|
|
|
u32 x39c_ = 0;
|
|
|
|
zeus::CVector3f x3a0_;
|
|
|
|
TUniqueId x3ac_ = kInvalidUniqueId;
|
|
|
|
float x3b0_ = 1.f;
|
|
|
|
float x3b4_speed;
|
|
|
|
float x3b8_turnSpeed;
|
|
|
|
float x3bc_detectionRange;
|
|
|
|
float x3c0_detectionHeightRange;
|
|
|
|
float x3c4_detectionAngle;
|
|
|
|
float x3c8_leashRadius;
|
|
|
|
float x3cc_playerLeashRadius;
|
|
|
|
float x3d0_playerLeashTime;
|
2018-09-14 00:49:34 +00:00
|
|
|
float x3d4_curPlayerLeashTime = 0.f;
|
2018-09-07 23:51:07 +00:00
|
|
|
float x3d8_;
|
|
|
|
float x3dc_;
|
|
|
|
float x3e0_;
|
|
|
|
float x3e4_ = 0.f;
|
|
|
|
float x3e8_ = 0.f;
|
|
|
|
float x3ec_ = 0.f;
|
|
|
|
float x3f0_ = 0.f;
|
|
|
|
float x3f4_ = 0.f;
|
|
|
|
u32 x3f8_ = 0;
|
|
|
|
EFlavorType x3fc_flavor;
|
2017-08-25 06:18:09 +00:00
|
|
|
|
|
|
|
union
|
|
|
|
{
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
bool x400_24_ : 1;
|
|
|
|
bool x400_25_ : 1; // t
|
|
|
|
bool x400_26_ : 1;
|
|
|
|
bool x400_27_ : 1;
|
|
|
|
bool x400_28_ : 1;
|
|
|
|
bool x400_29_ : 1;
|
|
|
|
bool x400_30_ : 1;
|
|
|
|
bool x400_31_ : 1; // r25 == 1
|
|
|
|
bool x401_24_ : 1;
|
|
|
|
bool x401_25_ : 1;
|
|
|
|
bool x401_26_ : 1;
|
|
|
|
bool x401_27_ : 1;
|
|
|
|
bool x401_28_ : 1;
|
|
|
|
bool x401_29_ : 1;
|
|
|
|
bool x401_30_ : 1;
|
|
|
|
bool x401_31_ : 1;
|
|
|
|
bool x402_24_ : 1;
|
|
|
|
bool x402_25_ : 1;
|
|
|
|
bool x402_26_ : 1;
|
|
|
|
bool x402_27_ : 1;
|
|
|
|
bool x402_28_ : 1;
|
|
|
|
bool x402_29_ : 1; // t
|
|
|
|
bool x402_30_ : 1;
|
|
|
|
bool x402_31_ : 1;
|
|
|
|
bool x403_24_ : 1;
|
|
|
|
bool x403_25_ : 1; // t
|
|
|
|
bool x403_26_ : 1; // t
|
|
|
|
};
|
|
|
|
u32 _dummy2 = 0;
|
|
|
|
};
|
|
|
|
|
2018-09-14 00:49:34 +00:00
|
|
|
CDamageInfo x404_contactDamage;
|
2018-09-16 23:22:35 +00:00
|
|
|
float x420_curDamageTime = 0.f;
|
2018-09-07 23:51:07 +00:00
|
|
|
float x424_damageWaitTime;
|
|
|
|
float x428_ = -1.f;
|
|
|
|
zeus::CColor x42c_ = zeus::CColor::skBlack;
|
|
|
|
zeus::CColor x430_ = skDamageColor;
|
2018-09-14 00:49:34 +00:00
|
|
|
zeus::CVector3f x434_posDelta;
|
|
|
|
zeus::CQuaternion x440_rotDelta;
|
2018-09-07 23:51:07 +00:00
|
|
|
CSteeringBehaviors x45c_;
|
2017-08-21 00:29:59 +00:00
|
|
|
std::unique_ptr<CBodyController> x450_bodyController;
|
2018-09-07 23:51:07 +00:00
|
|
|
u32 x454_deathSfx;
|
|
|
|
u32 x458_iceShatterSfx;
|
2017-08-21 00:29:59 +00:00
|
|
|
|
2018-09-07 23:51:07 +00:00
|
|
|
CPatternedUnknown2 x460_;
|
|
|
|
zeus::CVector3f x4e4_;
|
|
|
|
float x4f0_ = 0.f;
|
|
|
|
float x4f4_;
|
|
|
|
float x4f8_;
|
|
|
|
float x4fc_;
|
2017-08-25 06:18:09 +00:00
|
|
|
float x500_ = 0.f;
|
|
|
|
float x504_damageDur = 0.f;
|
2018-09-07 23:51:07 +00:00
|
|
|
EColliderType x508_colliderType;
|
|
|
|
float x50c_thermalMag;
|
|
|
|
std::unique_ptr<CVertexMorphEffect> x510_;
|
|
|
|
zeus::CVector3f x514_;
|
|
|
|
std::experimental::optional<TLockedToken<CGenDescription>> x520_;
|
|
|
|
std::experimental::optional<TLockedToken<CElectricDescription>> x530_;
|
|
|
|
zeus::CVector3f x540_;
|
|
|
|
std::experimental::optional<TLockedToken<CGenDescription>> x54c_;
|
2018-09-14 00:49:34 +00:00
|
|
|
zeus::CVector3f x55c_;
|
2016-04-25 05:03:38 +00:00
|
|
|
public:
|
2017-11-13 06:19:18 +00:00
|
|
|
CPatterned(ECharacter character, TUniqueId uid, std::string_view name, EFlavorType flavor, const CEntityInfo& info,
|
2016-12-19 18:27:58 +00:00
|
|
|
const zeus::CTransform& xf, CModelData&& mData, const CPatternedInfo& pinfo,
|
|
|
|
CPatterned::EMovementType movement, EColliderType collider, EBodyType body,
|
2017-07-05 18:34:12 +00:00
|
|
|
const CActorParameters& params, int variant);
|
2016-04-25 05:03:38 +00:00
|
|
|
|
2018-09-14 00:49:34 +00:00
|
|
|
void Accept(IVisitor&);
|
|
|
|
void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&);
|
2018-09-16 23:22:35 +00:00
|
|
|
void PreThink(float, CStateManager& mgr) { CEntity::Think(x500_, mgr); }
|
2018-09-07 23:51:07 +00:00
|
|
|
void Think(float, CStateManager&);
|
2018-09-14 00:49:34 +00:00
|
|
|
void PreRender(CStateManager&, const zeus::CFrustum&);
|
|
|
|
|
2018-09-07 23:51:07 +00:00
|
|
|
void Touch(CActor&, CStateManager&);
|
2018-09-14 00:49:34 +00:00
|
|
|
std::experimental::optional<zeus::CAABox> GetTouchBounds() const;
|
|
|
|
bool CanRenderUnsorted(const CStateManager& mgr) const;
|
2018-09-07 23:51:07 +00:00
|
|
|
zeus::CVector3f GetOrbitPosition(const CStateManager& mgr) const
|
|
|
|
{
|
|
|
|
return GetAimPosition(mgr, 0.f);
|
|
|
|
}
|
|
|
|
|
|
|
|
zeus::CVector3f GetAimPosition(const CStateManager& mgr, float) const;
|
2017-06-12 04:23:34 +00:00
|
|
|
|
2018-09-14 00:49:34 +00:00
|
|
|
void Death(CStateManager&, const zeus::CVector3f&, EStateMsg) {}
|
|
|
|
void KnockBack(const zeus::CVector3f&, CStateManager&, const CDamageInfo& info, EKnockBackType, bool, float) {}
|
|
|
|
void TakeDamage(const zeus::CVector3f&, float) { x428_ = 0.33f;}
|
|
|
|
bool FixedRandom(CStateManager&, float) { return x330_stateMachineState.GetRandom() < x330_stateMachineState.x14_; }
|
|
|
|
bool Random(CStateManager&, float dt) { return x330_stateMachineState.GetRandom() < dt; }
|
|
|
|
//bool FixedDelay(CStateManager&, float dt) { return x330_stateMachineState.GetDelay() == dt; }
|
|
|
|
|
|
|
|
bool Default() { return true; }
|
|
|
|
virtual bool KnockbackWhenFrozen() const { return true;}
|
|
|
|
virtual void sub8007ace8(CStateManager&) {}
|
|
|
|
virtual void sub8007ab34(CStateManager&) {}
|
|
|
|
virtual void Burn(float, float) {}
|
|
|
|
virtual void Shock(float, float) {}
|
|
|
|
virtual void ThinkAboutMove(float);
|
|
|
|
virtual void GetSearchPath() {}
|
2018-09-16 23:22:35 +00:00
|
|
|
virtual CDamageInfo GetContactDamage() const { return x404_contactDamage; }
|
2018-09-14 00:49:34 +00:00
|
|
|
virtual u8 GetModelAlphau8(const CStateManager&) const { return u8(x42c_.a * 255);}
|
|
|
|
virtual bool IsOnGround() const { return x328_27_onGround; }
|
|
|
|
virtual float GetGravityConstant() const { return 24.525002f; }
|
|
|
|
virtual CProjectileInfo* GetProjectileInfo() { return nullptr; }
|
|
|
|
virtual void PhazeOut(CStateManager&) {}
|
|
|
|
virtual TLockedToken<CGenDescription>& GetX520() { return x520_.value(); }
|
|
|
|
float GetDamageDuration() const { return x504_damageDur; }
|
|
|
|
zeus::CVector3f GetGunEyePos() const;
|
|
|
|
|
|
|
|
void BuildBodyController(EBodyType);
|
|
|
|
const CBodyController* GetBodyController() const { return x450_bodyController.get(); }
|
|
|
|
CBodyController* BodyController() { return x450_bodyController.get(); }
|
|
|
|
void SetupPlayerCollision(bool);
|
|
|
|
|
|
|
|
|
2018-09-16 23:22:35 +00:00
|
|
|
void SetDestPos(const zeus::CVector3f& pos) { x2e0_destPos = pos; }
|
2018-09-14 00:49:34 +00:00
|
|
|
void sub8007a68c(float, CStateManager&) {}
|
|
|
|
float sub80078a88();
|
|
|
|
void sub8007a5b8(float) {}
|
|
|
|
|
|
|
|
bool GetX328_26() const { return x328_26_; }
|
|
|
|
bool GetX402_28() const { return x402_28_; }
|
|
|
|
|
|
|
|
//region Casting Functions
|
|
|
|
|
2017-06-12 04:23:34 +00:00
|
|
|
template <class T>
|
|
|
|
static T* CastTo(CEntity* ent)
|
|
|
|
{
|
|
|
|
if (TCastToPtr<CPatterned> patterned = ent)
|
2017-08-31 02:42:37 +00:00
|
|
|
return CastTo<T>(patterned.GetPtr());
|
2017-06-12 04:23:34 +00:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class T>
|
|
|
|
static const T* CastTo(const CEntity* ent)
|
|
|
|
{
|
|
|
|
if (TCastToConstPtr<CPatterned> patterned = ent)
|
2017-08-31 02:42:37 +00:00
|
|
|
return CastTo<T>(patterned.GetPtr());
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class T>
|
|
|
|
static T* CastTo(CPatterned* patterned)
|
|
|
|
{
|
|
|
|
if (patterned->x34c_character == T::CharacterType)
|
|
|
|
return static_cast<T*>(patterned);
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class T>
|
|
|
|
static const T* CastTo(const CPatterned* patterned)
|
|
|
|
{
|
|
|
|
if (patterned->x34c_character == T::CharacterType)
|
|
|
|
return static_cast<const T*>(patterned);
|
2017-06-12 04:23:34 +00:00
|
|
|
return nullptr;
|
|
|
|
}
|
2017-07-10 04:55:51 +00:00
|
|
|
|
2018-09-14 00:49:34 +00:00
|
|
|
//endregion
|
2016-04-25 05:46:28 +00:00
|
|
|
};
|
2016-04-25 05:03:38 +00:00
|
|
|
}
|
|
|
|
|
2016-04-25 05:46:28 +00:00
|
|
|
#endif // CPATTERNED_HPP
|