From f1dd82066a97d9d83449298eb0822de6b652d198 Mon Sep 17 00:00:00 2001 From: Luke Street Date: Thu, 20 Feb 2020 23:27:12 -0500 Subject: [PATCH] Start implementing CSnakeWeedSwarm --- Runtime/World/CSnakeWeedSwarm.cpp | 61 +++++++++++++++++++++++++++---- Runtime/World/CSnakeWeedSwarm.hpp | 49 +++++++++++++++++++++++-- Runtime/World/ScriptLoader.cpp | 20 +++++----- 3 files changed, 111 insertions(+), 19 deletions(-) diff --git a/Runtime/World/CSnakeWeedSwarm.cpp b/Runtime/World/CSnakeWeedSwarm.cpp index 0ff0e30d6..b79327cbb 100644 --- a/Runtime/World/CSnakeWeedSwarm.cpp +++ b/Runtime/World/CSnakeWeedSwarm.cpp @@ -1,19 +1,66 @@ #include "Runtime/World/CSnakeWeedSwarm.hpp" +#include "Runtime/CSimplePool.hpp" +#include "Runtime/GameGlobalObjects.hpp" +#include "Runtime/World/CActorParameters.hpp" #include "Runtime/World/CAnimationParameters.hpp" - #include "TCastTo.hpp" // Generated file, do not modify include path namespace urde { CSnakeWeedSwarm::CSnakeWeedSwarm(TUniqueId uid, bool active, std::string_view name, const CEntityInfo& info, - const zeus::CVector3f& pos, const zeus::CVector3f& scale, - const CAnimationParameters& animParms, const CActorParameters& actParms, float f1, - float f2, float f3, float f4, float f5, float f6, float f7, float f8, float f9, - float f10, float f11, float f12, float f13, float f14, const CDamageInfo&, - float /*f15*/, u32 w1, u32 w2, u32 w3, u32 w4, u32 w5, u32 w6, float f16) + const zeus::CVector3f& pos, const zeus::CVector3f& scale, const CAnimRes& animRes, + const CActorParameters& actParms, float f1, float f2, float f3, float f4, float f5, + float f6, float f7, float f8, float f9, float f10, float f11, float f12, float f13, + float f14, const CDamageInfo& dInfo, float /*f15*/, u32 sfxId1, u32 sfxId2, u32 sfxId3, + CAssetId w4, u32 w5, CAssetId w6, float f16) : CActor(uid, active, name, info, zeus::CTransform::Translate(pos), CModelData::CModelDataNull(), - CMaterialList(EMaterialTypes::Trigger, EMaterialTypes::NonSolidDamageable), actParms, kInvalidUniqueId) {} + CMaterialList(EMaterialTypes::Trigger, EMaterialTypes::NonSolidDamageable), actParms, kInvalidUniqueId) +, xe8_scale(scale) +, xf4_(f1) +, xf8_(f2) +, xfc_(f3) +, x100_(f4) +, x104_(f5) +, x108_(f6) +, x10c_(f7) +, x110_(f8) +, x114_(f9) +, x118_(f10) +, x11c_(std::cos(zeus::degToRad(f11))) +, x120_(f12) +, x124_(f13) +, x128_(f14) +, x15c_dInfo(dInfo) +, x1d0_sfx1(CSfxManager::TranslateSFXID(sfxId1)) +, x1d2_sfx2(CSfxManager::TranslateSFXID(sfxId2)) +, x1d4_sfx3(CSfxManager::TranslateSFXID(sfxId3)) +, x1fc_(w5) +, x200_(f16) { + SetActorLights(actParms.GetLightParameters().MakeActorLights()); + x1b4_modelData.emplace_back(std::make_unique(animRes)); + x1b4_modelData.emplace_back(std::make_unique(animRes)); + x1b4_modelData.emplace_back(std::make_unique(animRes)); + x1b4_modelData.emplace_back(std::make_unique(animRes)); + if (actParms.GetXRayAssets().first.IsValid()) { + for (int i = 0; i < 4; ++i) + x1b4_modelData[i]->SetXRayModel(actParms.GetXRayAssets()); + x13c_xbf_modelAssetDirty = true; + } + if (actParms.GetThermalAssets().first.IsValid()) { + for (int i = 0; i < 4; ++i) + x1b4_modelData[i]->SetInfraModel(actParms.GetThermalAssets()); + x13c_xbf_modelAssetDirty = true; + } + if (w4.IsValid()) { + x1dc_ = g_SimplePool->GetObj({FOURCC('PART'), w4}); + x1ec_ = std::make_unique(x1dc_); + } + if (w6.IsValid()) { + x1dc_ = g_SimplePool->GetObj({FOURCC('PART'), w6}); + x1f4_ = std::make_unique(x1dc_); + } +} void CSnakeWeedSwarm::Accept(urde::IVisitor& visitor) { visitor.Visit(this); } diff --git a/Runtime/World/CSnakeWeedSwarm.hpp b/Runtime/World/CSnakeWeedSwarm.hpp index 10d6b5b16..c05bc1ac2 100644 --- a/Runtime/World/CSnakeWeedSwarm.hpp +++ b/Runtime/World/CSnakeWeedSwarm.hpp @@ -1,19 +1,62 @@ #pragma once #include "Runtime/Collision/CCollisionSurface.hpp" +#include "Runtime/Particle/CElementGen.hpp" #include "Runtime/World/CActor.hpp" +#include "Runtime/World/CDamageInfo.hpp" namespace urde { class CAnimationParameters; class CSnakeWeedSwarm : public CActor { + zeus::CVector3f xe8_scale; + float xf4_; + float xf8_; + float xfc_; + float x100_; + float x104_; + float x108_; + float x10c_; + float x110_; + float x114_; + float x118_; + float x11c_; + float x120_; + float x124_; + float x128_; + u32 x12c_ = 0; + // x130_ + u32 x134_ = 0; + u32 x138_ = 0; + u32 x13c_ = 0; + bool x13c_xbf_modelAssetDirty : 1; + zeus::CAABox x144_ = zeus::skInvertedBox; + CDamageInfo x15c_dInfo; + // x178_ = 0 + // x19c_ = 0 + rstl::reserved_vector, 4> x1b4_modelData; + // x1c8_ = ptr to 0x10 sz? + // x1cc_ = ptr to 0x10 sz? + u16 x1d0_sfx1; + u16 x1d2_sfx2; + u16 x1d4_sfx3; + u32 x1d8_ = 0; + TLockedToken x1dc_; + // TLockedToken x1e4_; both assign to x1dc_? + std::unique_ptr x1ec_; + std::unique_ptr x1f4_; + u32 x1fc_; + float x200_; + float x204_ = 0.f; + public: CSnakeWeedSwarm(TUniqueId, bool, std::string_view, const CEntityInfo&, const zeus::CVector3f&, const zeus::CVector3f&, - const CAnimationParameters&, const CActorParameters&, float, float, float, float, float, float, float, - float, float, float, float, float, float, float, const CDamageInfo&, float, u32, u32, u32, u32, u32, - u32, float); + const CAnimRes&, const CActorParameters&, float, float, float, float, float, float, float, float, + float, float, float, float, float, float, const CDamageInfo&, float, u32, u32, u32, CAssetId, u32, + CAssetId, float); void Accept(IVisitor&) override; void ApplyRadiusDamage(const zeus::CVector3f& pos, const CDamageInfo& info, CStateManager& stateMgr) {} + std::optional GetTouchBounds() const override { /* FIXME check flags */ return x144_; } }; } // namespace urde diff --git a/Runtime/World/ScriptLoader.cpp b/Runtime/World/ScriptLoader.cpp index 195be25a1..0150f974a 100644 --- a/Runtime/World/ScriptLoader.cpp +++ b/Runtime/World/ScriptLoader.cpp @@ -3026,16 +3026,18 @@ CEntity* ScriptLoader::LoadSnakeWeedSwarm(CStateManager& mgr, CInputStream& in, float f14 = in.readFloatBig(); CDamageInfo dInfo(in); float f15 = in.readFloatBig(); - u32 w4 = in.readUint32Big(); - u32 w5 = in.readUint32Big(); - u32 w6 = in.readUint32Big(); - u32 w7 = (propCount < 29 ? -1 : in.readUint32Big()); - u32 w8 = (propCount < 29 ? -1 : in.readUint32Big()); - u32 w9 = (propCount < 29 ? -1 : in.readUint32Big()); - u32 f16 = (propCount < 29 ? 0.f : in.readFloatBig()); + u32 w1 = in.readUint32Big(); + u32 w2 = in.readUint32Big(); + u32 w3 = in.readUint32Big(); + CAssetId w4 = (propCount < 29 ? -1 : in.readUint32Big()); + u32 w5 = (propCount < 29 ? -1 : in.readUint32Big()); + CAssetId w6 = (propCount < 29 ? -1 : in.readUint32Big()); + float f16 = (propCount < 29 ? 0.f : in.readFloatBig()); - return new CSnakeWeedSwarm(mgr.AllocateUniqueId(), active, name, info, pos, scale, animParms, actParms, f1, f2, f3, - f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, dInfo, f15, w4, w5, w6, w7, w8, w9, f16); + CAnimRes animRes(animParms.GetACSFile(), animParms.GetCharacter(), zeus::skOne3f, animParms.GetInitialAnimation(), + true); + return new CSnakeWeedSwarm(mgr.AllocateUniqueId(), active, name, info, pos, scale, animRes, actParms, f1, f2, f3, f4, + f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, dInfo, f15, w1, w2, w3, w4, w5, w6, f16); } CEntity* ScriptLoader::LoadActorContraption(CStateManager& mgr, CInputStream& in, int propCount,