From 9c32213790b4796cc58ffdc7c31b3876426f82c9 Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Sat, 20 May 2017 00:41:49 -0700 Subject: [PATCH] Finish CActorContraption --- Editor/ViewManager.cpp | 2 +- .../Shaders/CTexturedQuadFilterGLSL.cpp | 4 +- Runtime/MP1/World/CActorContraption.cpp | 56 +++++++++++++++---- Runtime/MP1/World/CActorContraption.hpp | 7 ++- Runtime/Weapon/CFlameInfo.cpp | 17 ++++++ Runtime/Weapon/CFlameInfo.hpp | 10 +++- Runtime/Weapon/CFlameThrower.cpp | 12 ++-- Runtime/Weapon/CFlameThrower.hpp | 6 +- Runtime/Weapon/WeaponCommon.hpp | 28 +++++----- 9 files changed, 99 insertions(+), 43 deletions(-) diff --git a/Editor/ViewManager.cpp b/Editor/ViewManager.cpp index 77cd05b1d..8e0fab78a 100644 --- a/Editor/ViewManager.cpp +++ b/Editor/ViewManager.cpp @@ -27,7 +27,7 @@ namespace urde 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 SObjectTag samusCharSet = m_projManager.TagFromPath(_S("MP1/Shared/ANCS_77289A4A.*")); SObjectTag platModel = m_projManager.TagFromPath(_S("MP1/Shared/CMDL_6FA561D0.blend")); diff --git a/Runtime/Graphics/Shaders/CTexturedQuadFilterGLSL.cpp b/Runtime/Graphics/Shaders/CTexturedQuadFilterGLSL.cpp index 26644d74c..9e4131301 100644 --- a/Runtime/Graphics/Shaders/CTexturedQuadFilterGLSL.cpp +++ b/Runtime/Graphics/Shaders/CTexturedQuadFilterGLSL.cpp @@ -80,7 +80,7 @@ BOO_GLSL_BINDING_HEAD "TBINDING0 uniform sampler2D tex;\n" "void main()\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"; static const char* FSAlpha = @@ -98,7 +98,7 @@ BOO_GLSL_BINDING_HEAD "TBINDING0 uniform sampler2D tex;\n" "void main()\n" "{\n" -" colorOut = vtf.color * texture(tex, vtf.uv, lod);\n" +" colorOut = vtf.color * texture(tex, vtf.uv, vtf.lod);\n" "}\n"; URDE_DECL_SPECIALIZE_MULTI_BLEND_SHADER(CTexturedQuadFilter) diff --git a/Runtime/MP1/World/CActorContraption.cpp b/Runtime/MP1/World/CActorContraption.cpp index f4c254070..4cad703a7 100644 --- a/Runtime/MP1/World/CActorContraption.cpp +++ b/Runtime/MP1/World/CActorContraption.cpp @@ -1,5 +1,6 @@ #include "MP1/World/CActorContraption.hpp" #include "Weapon/CFlameThrower.hpp" +#include "Weapon/CFlameInfo.hpp" #include "Character/CInt32POINode.hpp" #include "GameGlobalObjects.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, 1.f, false, false, false, false) , x300_flameThrowerGen(g_SimplePool->GetObj("FlameThrower")) -, x308_partId(part) +, x308_flameFxId(part) , 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) { CScriptActor::Think(dt, mgr); - for (const std::pair& uid : x2e4_children) + for (const std::pair& uid : x2e8_children) { CFlameThrower* act = static_cast(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& uid : x2e8_children) + { + CFlameThrower* act = static_cast(mgr.ObjectById(uid.first)); + if (act && !act->GetX400_25()) + act->Reset(mgr, false); + } +} + void MP1::CActorContraption::DoUserAnimEvent(CStateManager& mgr, CInt32POINode& node, EUserEventType evType) { if (evType == EUserEventType::DamageOff) { - for (const std::pair& uid : x2e4_children) - { - CFlameThrower* act = static_cast(mgr.ObjectById(uid.first)); - if (act && act->GetX400_25()) - act->Reset(mgr, false); - } + ResetFlameThrowers(mgr); } else if (evType == EUserEventType::DamageOn) { @@ -61,8 +79,24 @@ void MP1::CActorContraption::DoUserAnimEvent(CStateManager& mgr, CInt32POINode& 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& 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; } } diff --git a/Runtime/MP1/World/CActorContraption.hpp b/Runtime/MP1/World/CActorContraption.hpp index e68834dfb..eafe49345 100644 --- a/Runtime/MP1/World/CActorContraption.hpp +++ b/Runtime/MP1/World/CActorContraption.hpp @@ -12,9 +12,9 @@ namespace MP1 class CActorContraption : public CScriptActor { /* AKA Why Zoid?!?!?!? */ - std::vector> x2e4_children; + std::vector> x2e8_children; TToken x300_flameThrowerGen; - ResId x308_partId; + ResId x308_flameFxId; CDamageInfo x30c_dInfo; public: CActorContraption(TUniqueId, const std::string&, const CEntityInfo&, const zeus::CTransform&, CModelData&&, @@ -22,10 +22,11 @@ public: const CDamageVulnerability&, const CActorParameters&, ResId, const CDamageInfo&, bool); void Accept(IVisitor &visitor); - + void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager &); void Think(float, CStateManager &); void DoUserAnimEvent(CStateManager &, CInt32POINode &, EUserEventType); CFlameThrower* CreateFlameThrower(const std::string&, CStateManager&); + void ResetFlameThrowers(CStateManager& mgr); }; } } diff --git a/Runtime/Weapon/CFlameInfo.cpp b/Runtime/Weapon/CFlameInfo.cpp index e69de29bb..a7ed88b5e 100644 --- a/Runtime/Weapon/CFlameInfo.cpp +++ b/Runtime/Weapon/CFlameInfo.cpp @@ -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) +{ +} + +} diff --git a/Runtime/Weapon/CFlameInfo.hpp b/Runtime/Weapon/CFlameInfo.hpp index f27f3b158..a13afb190 100644 --- a/Runtime/Weapon/CFlameInfo.hpp +++ b/Runtime/Weapon/CFlameInfo.hpp @@ -7,12 +7,18 @@ namespace urde { class CFlameInfo { + s32 x0_; + s32 x4_; ResId x8_flameFxId; + s32 xc_; + float x10_; + float x18_; + float x1c_; public: - CFlameInfo(s32, u32, s32, s32, float, float, float); + CFlameInfo(s32, s32, ResId, s32, float, float, float); void GetAttributes() const; - void GetLength() const; + float GetLength() const; ResId GetFlameFxId() const { return x8_flameFxId; } }; } diff --git a/Runtime/Weapon/CFlameThrower.cpp b/Runtime/Weapon/CFlameThrower.cpp index 682083929..37b0bcfe5 100644 --- a/Runtime/Weapon/CFlameThrower.cpp +++ b/Runtime/Weapon/CFlameThrower.cpp @@ -10,7 +10,8 @@ const zeus::CVector3f CFlameThrower::kLightOffset(0, 3.f, 2.f); CFlameThrower::CFlameThrower(const TToken& wDesc, const std::string& name, EWeaponType wType, 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, zeus::CVector3f(1.f), {}, -1, false) , 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::Reset(CStateManager&, bool) -{ -} - -void CFlameThrower::Fire(const zeus::CTransform&, CStateManager&, bool) -{ +void CFlameThrower::Reset(CStateManager&, bool) {} -} +void CFlameThrower::Fire(const zeus::CTransform&, CStateManager&, bool) {} } diff --git a/Runtime/Weapon/CFlameThrower.hpp b/Runtime/Weapon/CFlameThrower.hpp index 4978dc4c9..8251cfeca 100644 --- a/Runtime/Weapon/CFlameThrower.hpp +++ b/Runtime/Weapon/CFlameThrower.hpp @@ -23,12 +23,14 @@ class CFlameThrower : public CGameProjectile }; u32 _dummy = 0; }; + public: CFlameThrower(const TToken& wDesc, const std::string& name, EWeaponType wType, 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 Reset(CStateManager&, bool); void Fire(const zeus::CTransform&, CStateManager&, bool); diff --git a/Runtime/Weapon/WeaponCommon.hpp b/Runtime/Weapon/WeaponCommon.hpp index 68d02772c..fdb8563f6 100644 --- a/Runtime/Weapon/WeaponCommon.hpp +++ b/Runtime/Weapon/WeaponCommon.hpp @@ -10,20 +10,20 @@ enum class EWeaponType { None = -1, Power = 0, - Ice, - Wave, - Plasma, - Bomb, - PowerBomb, - Missile, - BoostBall, - Phazon, - AI, - PoisonWater, - Lava, - Hot, - Unused1, - Unused2 + Ice = 1, + Wave = 2, + Plasma = 3, + Bomb = 4, + PowerBomb = 5, + Missile = 6, + BoostBall = 7, + Phazon = 8, + AI = 9, + PoisonWater = 10, + Lava = 11, + Hot = 12, + Unused1 = 13, + Unused2 = 14 }; } #endif // __URDE_WEAPONCOMMON_HPP__