diff --git a/Runtime/Particle/CCollisionResponseData.cpp b/Runtime/Particle/CCollisionResponseData.cpp new file mode 100644 index 000000000..c2089ac06 --- /dev/null +++ b/Runtime/Particle/CCollisionResponseData.cpp @@ -0,0 +1,15 @@ +#include "CCollisionResponseData.hpp" + +namespace pshag +{ +CCollisionResponseData::CCollisionResponseData(CInputStream& in, CSimplePool* resPool) +{ +} + +std::unique_ptr FCollisionResponseDataFactory(const SObjectTag& tag, CInputStream& in, const CVParamTransfer& vparms) +{ + CSimplePool* sp = static_cast(static_cast*>(vparms.GetObj())->GetParam()); + return TToken::GetIObjObjectFor(std::unique_ptr(new CCollisionResponseData(in, sp))); +} + +} diff --git a/Runtime/Particle/CCollisionResponseData.hpp b/Runtime/Particle/CCollisionResponseData.hpp new file mode 100644 index 000000000..c98349a42 --- /dev/null +++ b/Runtime/Particle/CCollisionResponseData.hpp @@ -0,0 +1,22 @@ +#ifndef __PSHAG_CCOLLISIONRESPONSEDATA_HPP__ +#define __PSHAG_CCOLLISIONRESPONSEDATA_HPP__ + +#include "RetroTypes.hpp" +#include "IObj.hpp" +#include "CToken.hpp" +#include "IOStreams.hpp" + +namespace pshag +{ +class CSimplePool; + +class CCollisionResponseData +{ +public: + CCollisionResponseData(CInputStream& in, CSimplePool* resPool); +}; + +std::unique_ptr FCollisionResponseDataFactory(const SObjectTag& tag, CInputStream& in, const CVParamTransfer& vparms); +} + +#endif // __PSHAG_CCOLLISIONRESPONSEDATA_HPP__ diff --git a/Runtime/Particle/CMakeLists.txt b/Runtime/Particle/CMakeLists.txt index 3adb20c92..8da7406f4 100644 --- a/Runtime/Particle/CMakeLists.txt +++ b/Runtime/Particle/CMakeLists.txt @@ -20,6 +20,8 @@ add_library(RuntimeCommonParticle CParticleElectricDataFactory.hpp CParticleElectricDataFactory.cpp CParticleElectric.hpp CParticleElectric.cpp CParticleGen.hpp CParticleGen.cpp + CProjectileWeaponDataFactory.hpp CProjectileWeaponDataFactory.cpp + CCollisionResponseData.hpp CCollisionResponseData.cpp CDecalManager.hpp CDecalManager.cpp CSpawnSystemKeyframeData.hpp CSpawnSystemKeyframeData.cpp CWarp.hpp CWarp.cpp diff --git a/Runtime/Particle/CParticleDataFactory.hpp b/Runtime/Particle/CParticleDataFactory.hpp index e42420bae..429675fd2 100644 --- a/Runtime/Particle/CParticleDataFactory.hpp +++ b/Runtime/Particle/CParticleDataFactory.hpp @@ -51,6 +51,7 @@ class CParticleDataFactory friend class CDecalDataFactory; friend class CParticleElectricDataFactory; friend class CParticleSwooshDataFactory; + friend class CProjectileWeaponDataFactory; static SParticleModel GetModel(CInputStream& in, CSimplePool* resPool); static SChildGeneratorDesc GetChildGeneratorDesc(TResId res, CSimplePool* resPool, const std::vector& tracker); diff --git a/Runtime/Particle/CParticleSwooshDataFactory.cpp b/Runtime/Particle/CParticleSwooshDataFactory.cpp index 2185b68a5..159fb3493 100644 --- a/Runtime/Particle/CParticleSwooshDataFactory.cpp +++ b/Runtime/Particle/CParticleSwooshDataFactory.cpp @@ -122,7 +122,7 @@ bool CParticleSwooshDataFactory::CreateWPSM(CSwooshDescription* desc, CInputStre default: { uint32_t clsName = clsId.toUint32(); - Log.report(LogVisor::FatalError, "Unknown SSWH class %.4s @%" PRIi64, &clsName, in.position()); + Log.report(LogVisor::FatalError, "Unknown SWSH class %.4s @%" PRIi64, &clsName, in.position()); return false; } } diff --git a/Runtime/Particle/CProjectileWeaponDataFactory.cpp b/Runtime/Particle/CProjectileWeaponDataFactory.cpp new file mode 100644 index 000000000..c1987f0fb --- /dev/null +++ b/Runtime/Particle/CProjectileWeaponDataFactory.cpp @@ -0,0 +1,161 @@ +#include "CProjectileWeaponDataFactory.hpp" +#include "CWeaponDescription.hpp" +#include "CCollisionResponseData.hpp" +#include "CRandom16.hpp" +#include "CSimplePool.hpp" + +namespace pshag +{ +static LogVisor::LogModule Log("Retro::CProjectileWeaponDataFactory"); + +using CPF = CParticleDataFactory; + +CWeaponDescription*CProjectileWeaponDataFactory::GetGeneratorDesc(CInputStream& in, CSimplePool* resPool) +{ + return CreateGeneratorDescription(in, resPool); +} + +CWeaponDescription* CProjectileWeaponDataFactory::CreateGeneratorDescription(CInputStream& in, CSimplePool* resPool) +{ + FourCC clsId = CPF::GetClassID(in); + if (clsId == FOURCC('WPSM')) + { + CWeaponDescription* desc = new CWeaponDescription; + CreateWPSM(desc, in, resPool); + } + + return nullptr; +} + +bool CProjectileWeaponDataFactory::CreateWPSM(CWeaponDescription* desc, CInputStream& in, CSimplePool* resPool) +{ + CRandom16 rand; + FourCC clsId = CPF::GetClassID(in); + + while(clsId != SBIG('_END')) + { + switch(clsId) + { + case SBIG('IORN'): + desc->x0_IORN.reset(CPF::GetVectorElement(in)); + break; + case SBIG('IVEC'): + desc->x4_IVEC.reset(CPF::GetVectorElement(in)); + break; + case SBIG('PSVM'): + desc->xc_PSVM.reset(CPF::GetModVectorElement(in)); + break; + case SBIG('VMD2'): + desc->x10_VMD2 = CPF::GetBool(in); + break; + case SBIG('PSLT'): + desc->x14_PSLT.reset(CPF::GetIntElement(in)); + break; + case SBIG('PCSL'): + desc->x18_PCSL.reset(CPF::GetVectorElement(in)); + break; + case SBIG('PCOL'): + desc->x1c_PCOL.reset(CPF::GetColorElement(in)); + break; + case SBIG('POFS'): + desc->x20_POFS.reset(CPF::GetVectorElement(in)); + break; + case SBIG('OFST'): + desc->x24_OFST.reset(CPF::GetVectorElement(in)); + break; + case SBIG('APSO'): + desc->x28_APSO = CPF::GetBool(in); + break; + case SBIG('HOMG'): + desc->x29_HOMG = CPF::GetBool(in); + break; + case SBIG('AP11'): + desc->x2a_AP11 = CPF::GetBool(in); + break; + case SBIG('AP21'): + desc->x2c_AS11 = CPF::GetBool(in); + break; + case SBIG('AS12'): + desc->x2d_AS12 = CPF::GetBool(in); + break; + case SBIG('AS13'): + desc->x2e_AS13 = CPF::GetBool(in); + break; + case SBIG('TRAT'): + desc->x30_TRAT.reset(CPF::GetRealElement(in)); + break; + case SBIG('APSM'): + { + std::vector tracker; + tracker.reserve(8); + desc->x34_APSM = CPF::GetChildGeneratorDesc(in, resPool, tracker); + break; + } + case SBIG('APS2'): + { + std::vector tracker; + tracker.reserve(8); + desc->x44_APS2 = CPF::GetChildGeneratorDesc(in, resPool, tracker); + break; + } + case SBIG('ASW1'): + desc->x54_ASW1 = CPF::GetSwooshGeneratorDesc(in, resPool); + break; + case SBIG('ASW2'): + desc->x64_ASW2 = CPF::GetSwooshGeneratorDesc(in, resPool); + break; + case SBIG('ASW3'): + desc->x74_ASW3 = CPF::GetSwooshGeneratorDesc(in, resPool); + break; + case SBIG('OHEF'): + desc->x84_OHEF = CPF::GetModel(in, resPool); + break; + case SBIG('COLR'): + { + FourCC cid = CPF::GetClassID(in); + if (cid == SBIG('NONE')) + break; + TResId id = CPF::GetInt(in); + if (id) + desc->x94_COLR = {resPool->GetObj({FOURCC('CRSC'), id}), true}; + break; + } + case SBIG('EWTR'): + desc->xa4_EWTR = CPF::GetBool(in); + break; + case SBIG('LWTR'): + desc->xa5_LWTR = CPF::GetBool(in); + break; + case SBIG('SWTR'): + desc->xa6_SWTR = CPF::GetBool(in); + break; + case SBIG('PJFX'): + { + FourCC cid = CPF::GetClassID(in); + if (cid != FOURCC('CNST')) + { + Log.report(LogVisor::FatalError, "PJFX element does not begin with CNST"); + return false; + } + desc->xa8_PJFX = CPF::GetInt(in); + break; + } + default: + { + uint32_t clsName = clsId.toUint32(); + Log.report(LogVisor::FatalError, "Unknown WPSM class %.4s @%" PRIi64, &clsName, in.position()); + return false; + } + } + clsId = CPF::GetClassID(in); + } + return true; +} + +std::unique_ptr FProjectileWeaponDataFactory(const SObjectTag& tag, CInputStream& in, const CVParamTransfer& vparms) +{ + CSimplePool* sp = static_cast(static_cast*>(vparms.GetObj())->GetParam()); + return TToken::GetIObjObjectFor(std::unique_ptr(CProjectileWeaponDataFactory::GetGeneratorDesc(in, sp))); +} + +} diff --git a/Runtime/Particle/CProjectileWeaponDataFactory.hpp b/Runtime/Particle/CProjectileWeaponDataFactory.hpp new file mode 100644 index 000000000..1b4a5f5ea --- /dev/null +++ b/Runtime/Particle/CProjectileWeaponDataFactory.hpp @@ -0,0 +1,24 @@ +#ifndef __PSHAG_CPROJECTILEWEAPONDATAFACTORY_HPP__ +#define __PSHAG_CPROJECTILEWEAPONDATAFACTORY_HPP__ + +#include "RetroTypes.hpp" +#include "IObj.hpp" +#include "CToken.hpp" +#include "IOStreams.hpp" + +namespace pshag +{ +class CWeaponDescription; +class CSimplePool; +class CProjectileWeaponDataFactory +{ + static CWeaponDescription* CreateGeneratorDescription(CInputStream& in, CSimplePool* resPool); + static bool CreateWPSM(CWeaponDescription* desc, CInputStream& in, CSimplePool* resPool); +public: + static CWeaponDescription* GetGeneratorDesc(CInputStream& in, CSimplePool* resPool); +}; + +std::unique_ptr FProjectileWeaponDataFactory(const SObjectTag& tag, CInputStream& in, const CVParamTransfer& vparms); +} + +#endif // __PSHAG_CPROJECTILEWEAPONDATAFACTORY_HPP__ diff --git a/Runtime/Particle/CWeaponDescription.hpp b/Runtime/Particle/CWeaponDescription.hpp index 3ccf5facd..47edcb3b2 100644 --- a/Runtime/Particle/CWeaponDescription.hpp +++ b/Runtime/Particle/CWeaponDescription.hpp @@ -10,6 +10,14 @@ namespace pshag { +class CCollisionResponseData; + +struct SCollisionResponseData +{ + TToken m_res; + bool m_found = false; +}; + class CWeaponDescription { public: @@ -37,7 +45,7 @@ public: SSwooshGeneratorDesc x64_ASW2; SSwooshGeneratorDesc x74_ASW3; SParticleModel x84_OHEF; - //x94_COLR; + SCollisionResponseData x94_COLR; bool xa4_EWTR; bool xa5_LWTR; bool xa6_SWTR;