Finish CActorContraption

This commit is contained in:
Phillip Stephens 2017-05-20 00:41:49 -07:00
parent c8d09f3de7
commit 9c32213790
9 changed files with 99 additions and 43 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

@ -80,7 +80,7 @@ BOO_GLSL_BINDING_HEAD
"TBINDING0 uniform sampler2D tex;\n" "TBINDING0 uniform sampler2D tex;\n"
"void main()\n" "void main()\n"
"{\n" "{\n"
" colorOut = vtf.color * vec4(texture(tex, vtf.uv, lod).rgb, 1.0);\n" " colorOut = vtf.color * vec4(texture(tex, vtf.uv, vtf.lod).rgb, 1.0);\n"
"}\n"; "}\n";
static const char* FSAlpha = static const char* FSAlpha =
@ -98,7 +98,7 @@ BOO_GLSL_BINDING_HEAD
"TBINDING0 uniform sampler2D tex;\n" "TBINDING0 uniform sampler2D tex;\n"
"void main()\n" "void main()\n"
"{\n" "{\n"
" colorOut = vtf.color * texture(tex, vtf.uv, lod);\n" " colorOut = vtf.color * texture(tex, vtf.uv, vtf.lod);\n"
"}\n"; "}\n";
URDE_DECL_SPECIALIZE_MULTI_BLEND_SHADER(CTexturedQuadFilter) URDE_DECL_SPECIALIZE_MULTI_BLEND_SHADER(CTexturedQuadFilter)

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 "Weapon/CFlameInfo.hpp"
#include "Character/CInt32POINode.hpp" #include "Character/CInt32POINode.hpp"
#include "GameGlobalObjects.hpp" #include "GameGlobalObjects.hpp"
#include "CSimplePool.hpp" #include "CSimplePool.hpp"
@ -17,21 +18,33 @@ MP1::CActorContraption::CActorContraption(TUniqueId uid, const std::string& name
: CScriptActor(uid, name, info, xf, std::move(mData), aabox, f1, f2, matList, hInfo, dVuln, aParams, false, active, 0, : CScriptActor(uid, name, info, xf, std::move(mData), aabox, f1, f2, matList, hInfo, dVuln, aParams, false, active, 0,
1.f, false, false, false, false) 1.f, false, false, false, false)
, x300_flameThrowerGen(g_SimplePool->GetObj("FlameThrower")) , x300_flameThrowerGen(g_SimplePool->GetObj("FlameThrower"))
, x308_partId(part) , x308_flameFxId(part)
, x30c_dInfo(dInfo) , x30c_dInfo(dInfo)
{ {
} }
void MP1::CActorContraption::Accept(IVisitor& visitor) void MP1::CActorContraption::Accept(IVisitor& visitor) { visitor.Visit(this); }
void MP1::CActorContraption::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr)
{ {
visitor.Visit(this); bool curActive = GetActive();
if (msg == EScriptObjectMessage::Registered)
AddMaterial(EMaterialTypes::ScanPassthrough, mgr);
else if (msg == EScriptObjectMessage::SetToZero)
ResetFlameThrowers(mgr);
AcceptScriptMsg(msg, uid, mgr);
if (curActive == GetActive() || !GetActive())
return;
ResetFlameThrowers(mgr);
} }
void MP1::CActorContraption::Think(float dt, CStateManager& mgr) void MP1::CActorContraption::Think(float dt, CStateManager& mgr)
{ {
CScriptActor::Think(dt, mgr); CScriptActor::Think(dt, mgr);
for (const std::pair<TUniqueId, std::string>& uid : x2e4_children) for (const std::pair<TUniqueId, std::string>& uid : x2e8_children)
{ {
CFlameThrower* act = static_cast<CFlameThrower*>(mgr.ObjectById(uid.first)); CFlameThrower* act = static_cast<CFlameThrower*>(mgr.ObjectById(uid.first));
@ -40,16 +53,21 @@ void MP1::CActorContraption::Think(float dt, CStateManager& mgr)
} }
} }
void MP1::CActorContraption::ResetFlameThrowers(CStateManager& mgr)
{
for (const std::pair<TUniqueId, std::string>& uid : x2e8_children)
{
CFlameThrower* act = static_cast<CFlameThrower*>(mgr.ObjectById(uid.first));
if (act && !act->GetX400_25())
act->Reset(mgr, false);
}
}
void MP1::CActorContraption::DoUserAnimEvent(CStateManager& mgr, CInt32POINode& node, EUserEventType evType) void MP1::CActorContraption::DoUserAnimEvent(CStateManager& mgr, CInt32POINode& node, EUserEventType evType)
{ {
if (evType == EUserEventType::DamageOff) if (evType == EUserEventType::DamageOff)
{ {
for (const std::pair<TUniqueId, std::string>& uid : x2e4_children) ResetFlameThrowers(mgr);
{
CFlameThrower* act = static_cast<CFlameThrower*>(mgr.ObjectById(uid.first));
if (act && act->GetX400_25())
act->Reset(mgr, false);
}
} }
else if (evType == EUserEventType::DamageOn) else if (evType == EUserEventType::DamageOn)
{ {
@ -61,8 +79,24 @@ void MP1::CActorContraption::DoUserAnimEvent(CStateManager& mgr, CInt32POINode&
CActor::DoUserAnimEvent(mgr, node, evType); CActor::DoUserAnimEvent(mgr, node, evType);
} }
CFlameThrower* MP1::CActorContraption::CreateFlameThrower(const std::string&, CStateManager&) CFlameThrower* MP1::CActorContraption::CreateFlameThrower(const std::string& name, CStateManager& mgr)
{ {
auto it = std::find_if(x2e8_children.begin(), x2e8_children.end(),
[&name](const std::pair<TUniqueId, std::string>& p) { return p.second == name; });
if (it == x2e8_children.end())
{
TUniqueId id = mgr.AllocateUniqueId();
CFlameInfo flameInfo(6, 6, x308_flameFxId, 20, 0.5f, 1.f, 1.f);
CFlameThrower* ret = new CFlameThrower(x300_flameThrowerGen, name, EWeaponType::Missile, flameInfo,
zeus::CTransform::Identity(), EMaterialTypes::CollisionActor, x30c_dInfo,
id, GetAreaId(), GetUniqueId(), 0, -1, -1, -1);
x2e8_children.emplace_back(id, name);
mgr.AddObject(ret);
return ret;
}
return nullptr; return nullptr;
} }
} }

View File

@ -12,9 +12,9 @@ namespace MP1
class CActorContraption : public CScriptActor class CActorContraption : public CScriptActor
{ {
/* AKA Why Zoid?!?!?!? */ /* AKA Why Zoid?!?!?!? */
std::vector<std::pair<TUniqueId, std::string>> x2e4_children; std::vector<std::pair<TUniqueId, std::string>> x2e8_children;
TToken<CGenDescription> x300_flameThrowerGen; TToken<CGenDescription> x300_flameThrowerGen;
ResId x308_partId; ResId x308_flameFxId;
CDamageInfo x30c_dInfo; CDamageInfo x30c_dInfo;
public: public:
CActorContraption(TUniqueId, const std::string&, const CEntityInfo&, const zeus::CTransform&, CModelData&&, CActorContraption(TUniqueId, const std::string&, const CEntityInfo&, const zeus::CTransform&, CModelData&&,
@ -22,10 +22,11 @@ public:
const CDamageVulnerability&, const CActorParameters&, ResId, const CDamageInfo&, bool); const CDamageVulnerability&, const CActorParameters&, ResId, const CDamageInfo&, bool);
void Accept(IVisitor &visitor); void Accept(IVisitor &visitor);
void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager &);
void Think(float, CStateManager &); void Think(float, CStateManager &);
void DoUserAnimEvent(CStateManager &, CInt32POINode &, EUserEventType); void DoUserAnimEvent(CStateManager &, CInt32POINode &, EUserEventType);
CFlameThrower* CreateFlameThrower(const std::string&, CStateManager&); CFlameThrower* CreateFlameThrower(const std::string&, CStateManager&);
void ResetFlameThrowers(CStateManager& mgr);
}; };
} }
} }

View File

@ -0,0 +1,17 @@
#include "Weapon/CFlameInfo.hpp"
namespace urde
{
CFlameInfo::CFlameInfo(s32 w1, s32 w2, ResId flameFxId, s32 w3, float f1, float f2, float f3)
: x0_(w1)
, x4_(w2)
, x8_flameFxId(flameFxId)
, xc_(w3)
, x10_(f1)
, x18_(f2)
, x1c_(f3)
{
}
}

View File

@ -7,12 +7,18 @@ namespace urde
{ {
class CFlameInfo class CFlameInfo
{ {
s32 x0_;
s32 x4_;
ResId x8_flameFxId; ResId x8_flameFxId;
s32 xc_;
float x10_;
float x18_;
float x1c_;
public: public:
CFlameInfo(s32, u32, s32, s32, float, float, float); CFlameInfo(s32, s32, ResId, s32, float, float, float);
void GetAttributes() const; void GetAttributes() const;
void GetLength() const; float GetLength() const;
ResId GetFlameFxId() const { return x8_flameFxId; } ResId GetFlameFxId() const { return x8_flameFxId; }
}; };
} }

View File

@ -10,7 +10,8 @@ const zeus::CVector3f CFlameThrower::kLightOffset(0, 3.f, 2.f);
CFlameThrower::CFlameThrower(const TToken<CWeaponDescription>& wDesc, const std::string& name, EWeaponType wType, CFlameThrower::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, u32 w2,
s16 sId, u32 w3)
: CGameProjectile(false, wDesc, name, wType, xf, matType, dInfo, owner, aId, uid, kInvalidUniqueId, w1, false, : CGameProjectile(false, wDesc, name, wType, xf, matType, dInfo, owner, aId, uid, kInvalidUniqueId, w1, false,
zeus::CVector3f(1.f), {}, -1, false) zeus::CVector3f(1.f), {}, -1, false)
, x2e8_(xf) , x2e8_(xf)
@ -24,12 +25,7 @@ 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::Reset(CStateManager&, bool) {}
{
}
void CFlameThrower::Fire(const zeus::CTransform&, CStateManager&, bool)
{
} void CFlameThrower::Fire(const zeus::CTransform&, CStateManager&, bool) {}
} }

View File

@ -23,12 +23,14 @@ class CFlameThrower : public CGameProjectile
}; };
u32 _dummy = 0; 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, u32 w2, s16 sId,
u32 w3);
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 Reset(CStateManager&, bool);
void Fire(const zeus::CTransform&, CStateManager&, bool); void Fire(const zeus::CTransform&, CStateManager&, bool);

View File

@ -10,20 +10,20 @@ enum class EWeaponType
{ {
None = -1, None = -1,
Power = 0, Power = 0,
Ice, Ice = 1,
Wave, Wave = 2,
Plasma, Plasma = 3,
Bomb, Bomb = 4,
PowerBomb, PowerBomb = 5,
Missile, Missile = 6,
BoostBall, BoostBall = 7,
Phazon, Phazon = 8,
AI, AI = 9,
PoisonWater, PoisonWater = 10,
Lava, Lava = 11,
Hot, Hot = 12,
Unused1, Unused1 = 13,
Unused2 Unused2 = 14
}; };
} }
#endif // __URDE_WEAPONCOMMON_HPP__ #endif // __URDE_WEAPONCOMMON_HPP__