Initial CActorContraption and weapon imps

This commit is contained in:
Phillip Stephens 2017-05-18 03:58:15 -07:00
parent 1f25becf8e
commit 40a0d8395a
16 changed files with 241 additions and 53 deletions

View File

@ -27,7 +27,7 @@ namespace urde
void ViewManager::BuildTestPART(urde::IObjectStore& objStore) void ViewManager::BuildTestPART(urde::IObjectStore& objStore)
{ {
m_modelTest = objStore.GetObj("MP1/Shared/CMDL_B2B41738.blend"); // m_modelTest = objStore.GetObj("MP1/Shared/CMDL_B2B41738.blend");
#if 0 #if 0
SObjectTag samusCharSet = m_projManager.TagFromPath(_S("MP1/Shared/ANCS_77289A4A.*")); SObjectTag samusCharSet = m_projManager.TagFromPath(_S("MP1/Shared/ANCS_77289A4A.*"));
SObjectTag platModel = m_projManager.TagFromPath(_S("MP1/Shared/CMDL_6FA561D0.blend")); SObjectTag platModel = m_projManager.TagFromPath(_S("MP1/Shared/CMDL_6FA561D0.blend"));

View File

@ -15,41 +15,41 @@
enum class EUserEventType enum class EUserEventType
{ {
Projectile, Projectile = 0,
EggLay, EggLay = 1,
LoopedSoundStop, LoopedSoundStop = 2,
AlignTargetPos, AlignTargetPos = 3,
AlignTargetRot, AlignTargetRot = 4,
ChangeMaterial, ChangeMaterial = 5,
Delete, Delete = 6,
GenerateEnd, GenerateEnd = 7,
DamageOn, DamageOn = 8,
DamageOff, DamageOff = 9,
AlignTargetPosStart, AlignTargetPosStart = 10,
DeGenerate, DeGenerate = 11,
Landing, Landing = 12,
TakeOff, TakeOff = 13,
FadeIn, FadeIn = 14,
FadeOut, FadeOut = 15,
ScreenShake, ScreenShake = 16,
BeginAction, BeginAction = 17,
EndAction, EndAction = 18,
BecomeRagDoll, BecomeRagDoll = 19,
IkLock, IkLock = 20,
IkRelease, IkRelease = 21,
BreakLockOn, BreakLockOn = 22,
BecomeShootThrough, BecomeShootThrough = 23,
RemoveCollision, RemoveCollision = 24,
ObjectPickUp, ObjectPickUp = 25,
ObjectDrop, ObjectDrop = 26,
EventStart, EventStart = 27,
EventStop, EventStop = 28,
Activate, Activate = 29,
Deactivate, Deactivate = 30,
SoundPlay, SoundPlay = 31,
SoundStop, SoundStop = 32,
EffectOn, EffectOn = 33,
EffectOff EffectOff = 34
}; };
namespace urde namespace urde

View File

@ -41,7 +41,7 @@ class CLight
float x30_angleC; float x30_angleC;
float x34_angleL; float x34_angleL;
float x38_angleQ; float x38_angleQ;
u32 x3c_ = 0; u32 x3c_priority = 0;
u32 x40_loadedIdx = 0; u32 x40_loadedIdx = 0;
float x44_cachedRadius; float x44_cachedRadius;
float x48_cachedIntensity; float x48_cachedIntensity;

View File

@ -1,5 +1,6 @@
#include "MP1/World/CActorContraption.hpp" #include "MP1/World/CActorContraption.hpp"
#include "Weapon/CFlameThrower.hpp" #include "Weapon/CFlameThrower.hpp"
#include "Character/CInt32POINode.hpp"
#include "GameGlobalObjects.hpp" #include "GameGlobalObjects.hpp"
#include "CSimplePool.hpp" #include "CSimplePool.hpp"
#include "CStateManager.hpp" #include "CStateManager.hpp"
@ -30,14 +31,38 @@ void MP1::CActorContraption::Think(float dt, CStateManager& mgr)
{ {
CScriptActor::Think(dt, mgr); CScriptActor::Think(dt, mgr);
for (const std::pair<TUniqueId, std::string>& uid : x2ec_children) for (const std::pair<TUniqueId, std::string>& uid : x2e4_children)
{ {
CFlameThrower* act = static_cast<CFlameThrower*>(mgr.ObjectById(uid.first)); CFlameThrower* act = static_cast<CFlameThrower*>(mgr.ObjectById(uid.first));
if (act && act->GetActive()) if (act && act->GetActive())
{
act->SetTransform(x34_transform * act->GetScaledLocatorTransform(uid.second)); act->SetTransform(x34_transform * act->GetScaledLocatorTransform(uid.second));
}
} }
} }
void MP1::CActorContraption::DoUserAnimEvent(CStateManager& mgr, CInt32POINode& node, EUserEventType evType)
{
if (evType == EUserEventType::DamageOff)
{
for (const std::pair<TUniqueId, std::string>& uid : x2e4_children)
{
CFlameThrower* act = static_cast<CFlameThrower*>(mgr.ObjectById(uid.first));
if (act && act->GetX400_25())
act->Reset(mgr, false);
}
}
else if (evType == EUserEventType::DamageOn)
{
CFlameThrower* fl = CreateFlameThrower(node.GetLocatorName(), mgr);
if (fl && fl->GetX400_25())
fl->Fire(GetTransform(), mgr, false);
}
else
CActor::DoUserAnimEvent(mgr, node, evType);
}
CFlameThrower* MP1::CActorContraption::CreateFlameThrower(const std::string&, CStateManager&)
{
return nullptr;
}
} }

View File

@ -6,12 +6,13 @@
namespace urde namespace urde
{ {
class CFlameThrower;
namespace MP1 namespace MP1
{ {
class CActorContraption : public CScriptActor class CActorContraption : public CScriptActor
{ {
/* AKA Why Zoid?!?!?!? */ /* AKA Why Zoid?!?!?!? */
std::vector<std::pair<TUniqueId, std::string>> x2ec_children; std::vector<std::pair<TUniqueId, std::string>> x2e4_children;
TToken<CGenDescription> x300_flameThrowerGen; TToken<CGenDescription> x300_flameThrowerGen;
ResId x308_partId; ResId x308_partId;
CDamageInfo x30c_dInfo; CDamageInfo x30c_dInfo;
@ -23,6 +24,8 @@ public:
void Accept(IVisitor &visitor); void Accept(IVisitor &visitor);
void Think(float, CStateManager &); void Think(float, CStateManager &);
void DoUserAnimEvent(CStateManager &, CInt32POINode &, EUserEventType);
CFlameThrower* CreateFlameThrower(const std::string&, CStateManager&);
}; };
} }
} }

View File

@ -10,7 +10,7 @@ public:
CBeamProjectile(const TToken<CWeaponDescription>&, const std::string&, EWeaponType, const zeus::CTransform&, int, CBeamProjectile(const TToken<CWeaponDescription>&, const std::string&, EWeaponType, const zeus::CTransform&, int,
float, float, EMaterialTypes, const CDamageInfo&, TUniqueId, TAreaId, TUniqueId, u32, bool); float, float, EMaterialTypes, const CDamageInfo&, TUniqueId, TAreaId, TUniqueId, u32, bool);
virtual void Accept(IVisitor &visitor); void Accept(IVisitor &visitor);
float GetMaxRadius() const; float GetMaxRadius() const;
zeus::CVector3f GetSurfaceNormal() const; zeus::CVector3f GetSurfaceNormal() const;
void GetDamageType() const; void GetDamageType() const;

View File

@ -23,4 +23,13 @@ CFlameThrower::CFlameThrower(const TToken<CWeaponDescription>& wDesc, const std:
void CFlameThrower::Accept(IVisitor& visitor) { visitor.Visit(this); } void CFlameThrower::Accept(IVisitor& visitor) { visitor.Visit(this); }
void CFlameThrower::SetTransform(const zeus::CTransform& xf) { x2e8_ = xf; } void CFlameThrower::SetTransform(const zeus::CTransform& xf) { x2e8_ = xf; }
void CFlameThrower::Reset(CStateManager&, bool)
{
}
void CFlameThrower::Fire(const zeus::CTransform&, CStateManager&, bool)
{
}
} }

View File

@ -14,14 +14,25 @@ class CFlameThrower : public CGameProjectile
zeus::CAABox x318_ = zeus::CAABox::skNullBox; zeus::CAABox x318_ = zeus::CAABox::skNullBox;
TToken<CGenDescription> x33c_flameDesc; TToken<CGenDescription> x33c_flameDesc;
std::unique_ptr<CElementGen> x348_flameGen; std::unique_ptr<CElementGen> x348_flameGen;
union
{
struct
{
bool x400_25 : 1;
};
u32 _dummy = 0;
};
public: public:
CFlameThrower(const TToken<CWeaponDescription>& wDesc, const std::string& name, EWeaponType wType, CFlameThrower(const TToken<CWeaponDescription>& wDesc, const std::string& name, EWeaponType wType,
const CFlameInfo& flameInfo, const zeus::CTransform& xf, EMaterialTypes matType, const CFlameInfo& flameInfo, const zeus::CTransform& xf, EMaterialTypes matType,
const CDamageInfo& dInfo, TUniqueId owner, TAreaId aId, TUniqueId uid, u32 w1); const CDamageInfo& dInfo, TUniqueId owner, TAreaId aId, TUniqueId uid, u32 w1);
void Accept(IVisitor &visitor); void Accept(IVisitor &visitor);
void SetTransform(const zeus::CTransform& xf); void SetTransform(const zeus::CTransform& xf);
void Reset(CStateManager&, bool);
void Fire(const zeus::CTransform&, CStateManager&, bool);
bool GetX400_25() const { return x400_25; }
}; };
} }
#endif // __URDE_CFLAMETHROWER_HPP__ #endif // __URDE_CFLAMETHROWER_HPP__

View File

@ -1,4 +1,7 @@
#include "Weapon/CGameProjectile.hpp" #include "Weapon/CGameProjectile.hpp"
#include "Graphics/CLight.hpp"
#include "World/CGameLight.hpp"
#include "CStateManager.hpp"
#include "TCastTo.hpp" #include "TCastTo.hpp"
namespace urde namespace urde
@ -16,6 +19,35 @@ CGameProjectile::CGameProjectile(bool active, const TToken<CWeaponDescription>&,
{ {
} }
void CGameProjectile::Accept(urde::IVisitor& visitor) { visitor.Visit(this); }
void CGameProjectile::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId /*uid*/, CStateManager& mgr)
{
if (msg == EScriptObjectMessage::InternalMessage15)
{
if (!x2e4_27_)
{
x2e4_27_ = true;
x2e4_26_ = true;
}
}
else if (msg == EScriptObjectMessage::InternalMessage16)
{
if (!x2e4_26_)
x2e4_26_ = true;
}
else if (msg == EScriptObjectMessage::InternalMessage17)
{
if (x2e4_26_)
{
x2e4_26_ = false;
x2e4_27_ = false;
}
}
else if (msg == EScriptObjectMessage::Deleted)
DeleteProjectileLight(mgr);
}
CWeapon::EProjectileAttrib CGameProjectile::GetBeamAttribType(EWeaponType wType) CWeapon::EProjectileAttrib CGameProjectile::GetBeamAttribType(EWeaponType wType)
{ {
if (wType == EWeaponType::Ice) if (wType == EWeaponType::Ice)
@ -30,9 +62,25 @@ CWeapon::EProjectileAttrib CGameProjectile::GetBeamAttribType(EWeaponType wType)
return EProjectileAttrib::None; return EProjectileAttrib::None;
} }
void CGameProjectile::Accept(urde::IVisitor& visitor) void CGameProjectile::DeleteProjectileLight(CStateManager& mgr)
{
if (x2c8_projectileLight != kInvalidUniqueId)
{
mgr.FreeScriptObject(x2c8_projectileLight);
x2c8_projectileLight = kInvalidUniqueId;
}
}
void CGameProjectile::CreateProjectileLight(const std::string& name, const CLight& light, CStateManager& mgr)
{
DeleteProjectileLight(mgr);
x2c8_projectileLight = mgr.AllocateUniqueId();
mgr.AddObject(new CGameLight(x2c8_projectileLight, GetAreaId(), GetActive(), name, GetTransform(), GetUniqueId(),
light, x2cc_, 0, 0.f));
}
void CGameProjectile::Chase(float dt, CStateManager& mgr)
{ {
visitor.Visit(this);
} }
} }

View File

@ -7,6 +7,7 @@
#include "World/CDamageInfo.hpp" #include "World/CDamageInfo.hpp"
#include "RetroTypes.hpp" #include "RetroTypes.hpp"
#include "CToken.hpp" #include "CToken.hpp"
#include "Weapon/CProjectileWeapon.hpp"
namespace urde namespace urde
{ {
@ -14,13 +15,31 @@ class CGenDescription;
class CWeaponDescription; class CWeaponDescription;
class CGameProjectile : public CWeapon class CGameProjectile : public CWeapon
{ {
//CProjectileWeapon x170_;
TUniqueId x2c8_projectileLight;
u32 x2cc_;
union
{
struct
{
bool x2e4_24_ : 1;
bool x2e4_25_ : 1;
bool x2e4_26_ : 1;
bool x2e4_27_ : 1;
bool x2e4_28_ : 1;
};
};
public: public:
CGameProjectile(bool, const TToken<CWeaponDescription>&, const std::string&, EWeaponType, const zeus::CTransform&, CGameProjectile(bool, const TToken<CWeaponDescription>&, const std::string&, EWeaponType, const zeus::CTransform&,
EMaterialTypes, const CDamageInfo&, TUniqueId, TAreaId, TUniqueId, TUniqueId, u32, bool, EMaterialTypes, const CDamageInfo&, TUniqueId, TAreaId, TUniqueId, TUniqueId, u32, bool,
const zeus::CVector3f&, const rstl::optional_object<TLockedToken<CGenDescription>>&, s16, bool); const zeus::CVector3f&, const rstl::optional_object<TLockedToken<CGenDescription>>&, s16, bool);
virtual void Accept(IVisitor &visitor); virtual void Accept(IVisitor &visitor);
void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager &);
static EProjectileAttrib GetBeamAttribType(EWeaponType wType); static EProjectileAttrib GetBeamAttribType(EWeaponType wType);
void DeleteProjectileLight(CStateManager&);
void CreateProjectileLight(const std::string&, const CLight&, CStateManager&);
void Chase(float, CStateManager&);
}; };
} }

View File

@ -1,9 +1,15 @@
#include "CProjectileWeapon.hpp" #include "CProjectileWeapon.hpp"
#include "Particle/CWeaponDescription.hpp"
namespace urde namespace urde
{ {
CRandom16 CProjectileWeapon::g_GlobalSeed = 99; CRandom16 CProjectileWeapon::g_GlobalSeed = 99;
CProjectileWeapon::CProjectileWeapon(const TToken<CWeaponDescription>& wDesc, const zeus::CVector3f&, const zeus::CTransform&,
const zeus::CVector3f&, s32)
: x4_weaponDesc(wDesc)
{
}
} }

View File

@ -3,17 +3,71 @@
#include "RetroTypes.hpp" #include "RetroTypes.hpp"
#include "CRandom16.hpp" #include "CRandom16.hpp"
#include "CToken.hpp"
#include "zeus/CVector3f.hpp"
#include "Particle/CParticleSwoosh.hpp"
#include "Particle/CElementGen.hpp"
namespace urde namespace urde
{ {
class CModel;
class CWeaponDescription;
class CProjectileWeapon class CProjectileWeapon
{ {
static CRandom16 g_GlobalSeed; static CRandom16 g_GlobalSeed;
TLockedToken<CWeaponDescription> x4_weaponDesc;
CRandom16 x10_random;
zeus::CTransform x14_;
zeus::CTransform x44_;
zeus::CVector3f x74_ = zeus::CVector3f::skZero;
zeus::CVector3f x80_ = zeus::CVector3f::skZero;
zeus::CVector3f x8c_ = zeus::CVector3f::skZero;
zeus::CVector3f x98_ = zeus::CVector3f::skOne;
zeus::CVector3f xa4_ = zeus::CVector3f::skZero;
zeus::CVector3f xb0_ = zeus::CVector3f::skZero;
zeus::CVector3f xbc_ = zeus::CVector3f::skZero;
zeus::CColor xc8_ = zeus::CColor::skWhite;
double xd0_ = 0.0;
double xd8_ = 0.0;
float xe0_;
u32 xe4_;
u32 xe8_lifetime = 0x7FFFFF;
u32 xec_ = 0;
u32 xf0_ = 0;
u32 xf4_ = 0;
u32 xf8_ = 0;
u32 xfc_ = 0;
std::unique_ptr<CElementGen> x104_particle1;
std::unique_ptr<CElementGen> x104_particle2;
TToken<CModel> x108_model;
bool x114_hasModel = false;
std::unique_ptr<CParticleSwoosh> x118_swoosh1;
std::unique_ptr<CParticleSwoosh> x11c_swoosh2;
std::unique_ptr<CParticleSwoosh> x120_swoosh3;
union
{
struct
{
bool x124_24_ : 1;
bool x124_25_ : 1;
bool x124_26_ap11 : 1;
bool x124_27_ap21 : 1;
bool x124_28_as11 : 1;
bool x124_29_as12 : 1;
bool x124_30_as13 : 1;
};
u32 _dummy = 0;
};
public: public:
CProjectileWeapon(const TToken<CWeaponDescription>& wDesc, const zeus::CVector3f&, const zeus::CTransform&,
const zeus::CVector3f&, s32);
void GetTransform();
void Update(float);
void UpdateParticleFx();
void UpdateChildParticleSystems(float);
static void SetGlobalSeed(u16 seed) { g_GlobalSeed.SetSeed(seed); } static void SetGlobalSeed(u16 seed) { g_GlobalSeed.SetSeed(seed); }
}; };
} }
#endif // __URDE_CPROJECTILEWEAPON_HPP__ #endif // __URDE_CPROJECTILEWEAPON_HPP__

View File

@ -6,10 +6,11 @@ namespace urde
{ {
CWeapon::CWeapon(TUniqueId uid, TAreaId aid, bool active, TUniqueId, EWeaponType, const std::string& name, CWeapon::CWeapon(TUniqueId uid, TAreaId aid, bool active, TUniqueId, EWeaponType, const std::string& name,
const zeus::CTransform& xf, const CMaterialFilter&, const CMaterialList& mList, const CDamageInfo&, const zeus::CTransform& xf, const CMaterialFilter& filter, const CMaterialList& mList, const CDamageInfo&,
EProjectileAttrib, CModelData&& mData) EProjectileAttrib, CModelData&& mData)
: CActor(uid, active, name, CEntityInfo(aid, CEntity::NullConnectionList), xf, std::move(mData), mList, : CActor(uid, active, name, CEntityInfo(aid, CEntity::NullConnectionList), xf, std::move(mData), mList,
CActorParameters::None(), kInvalidUniqueId) CActorParameters::None(), kInvalidUniqueId)
, xf8_(filter)
{ {
} }

View File

@ -3,6 +3,7 @@
#include "World/CActor.hpp" #include "World/CActor.hpp"
#include "Weapon/WeaponCommon.hpp" #include "Weapon/WeaponCommon.hpp"
#include "World/CDamageInfo.hpp"
#include "Collision/CMaterialFilter.hpp" #include "Collision/CMaterialFilter.hpp"
namespace urde namespace urde
@ -24,6 +25,17 @@ public:
private: private:
EProjectileAttrib xe8_projectileAttribs; EProjectileAttrib xe8_projectileAttribs;
TUniqueId xec_uid;
EWeaponType xf0_weaponType;
u32 xf4_;
CMaterialFilter xf8_;
u32 x10c_;
CDamageInfo x110_;
CDamageInfo x12c_;
float x148_;
float x14c_;
float x150_;
float x154_;
public: public:
CWeapon(TUniqueId, TAreaId, bool, TUniqueId, EWeaponType, const std::string&, const zeus::CTransform&, CWeapon(TUniqueId, TAreaId, bool, TUniqueId, EWeaponType, const std::string&, const zeus::CTransform&,
const CMaterialFilter&, const CMaterialList&, const CDamageInfo&, EProjectileAttrib, CModelData&&); const CMaterialFilter&, const CMaterialList&, const CDamageInfo&, EProjectileAttrib, CModelData&&);

View File

@ -10,7 +10,7 @@ CGameLight::CGameLight(TUniqueId uid, TAreaId aid, bool active, const std::strin
TUniqueId parentId, const CLight& light, u32 w1, u32 w2, float f1) TUniqueId parentId, const CLight& light, u32 w1, u32 w2, float f1)
: CActor(uid, active, name, CEntityInfo(aid, CEntity::NullConnectionList), xf, : CActor(uid, active, name, CEntityInfo(aid, CEntity::NullConnectionList), xf,
CModelData::CModelDataNull(), CMaterialList(), CActorParameters::None(), kInvalidUniqueId), CModelData::CModelDataNull(), CMaterialList(), CActorParameters::None(), kInvalidUniqueId),
xe8_parentId(parentId), xec_light(light), x13c_(w1), x140_(w2), x144_lifeTime(f1) xe8_parentId(parentId), xec_light(light), x13c_loadedIdx(w1), x140_priority(w2), x144_lifeTime(f1)
{ {
xec_light.GetRadius(); xec_light.GetRadius();
xec_light.GetIntensity(); xec_light.GetIntensity();
@ -34,8 +34,8 @@ void CGameLight::Think(float dt, CStateManager& mgr)
void CGameLight::SetLightPriorityAndId() void CGameLight::SetLightPriorityAndId()
{ {
xec_light.x3c_ = x140_; xec_light.x3c_priority = x140_priority;
xec_light.x40_loadedIdx = x13c_; xec_light.x40_loadedIdx = x13c_loadedIdx;
} }
void CGameLight::SetLight(const CLight& light) void CGameLight::SetLight(const CLight& light)

View File

@ -9,8 +9,8 @@ class CGameLight : public CActor
{ {
TUniqueId xe8_parentId; TUniqueId xe8_parentId;
CLight xec_light; CLight xec_light;
u32 x13c_; u32 x13c_loadedIdx;
u32 x140_; u32 x140_priority;
float x144_lifeTime; float x144_lifeTime;
public: public: