2016-02-13 19:05:59 +00:00
|
|
|
#include "CProjectileWeaponDataFactory.hpp"
|
|
|
|
#include "CWeaponDescription.hpp"
|
2016-07-28 07:33:55 +00:00
|
|
|
#include "Collision/CCollisionResponseData.hpp"
|
2016-02-17 05:20:34 +00:00
|
|
|
#include "CElectricDescription.hpp"
|
|
|
|
#include "CSwooshDescription.hpp"
|
|
|
|
#include "CGenDescription.hpp"
|
2016-03-04 23:04:53 +00:00
|
|
|
#include "Graphics/CModel.hpp"
|
2016-02-13 19:05:59 +00:00
|
|
|
#include "CRandom16.hpp"
|
|
|
|
#include "CSimplePool.hpp"
|
|
|
|
|
2016-03-04 23:04:53 +00:00
|
|
|
namespace urde
|
2016-02-13 19:05:59 +00:00
|
|
|
{
|
2016-03-04 23:04:53 +00:00
|
|
|
static logvisor::Module Log("urde::CProjectileWeaponDataFactory");
|
2016-02-13 19:05:59 +00:00
|
|
|
|
|
|
|
using CPF = CParticleDataFactory;
|
|
|
|
|
2017-02-13 21:29:00 +00:00
|
|
|
CWeaponDescription* CProjectileWeaponDataFactory::GetGeneratorDesc(CInputStream& in, CSimplePool* resPool)
|
2016-02-13 19:05:59 +00:00
|
|
|
{
|
|
|
|
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)
|
|
|
|
{
|
2016-02-15 08:23:50 +00:00
|
|
|
CRandom16 rand{99};
|
|
|
|
CGlobalRandom gr{rand};
|
2016-02-13 19:05:59 +00:00
|
|
|
FourCC clsId = CPF::GetClassID(in);
|
|
|
|
|
2017-02-13 21:29:00 +00:00
|
|
|
while (clsId != SBIG('_END'))
|
2016-02-13 19:05:59 +00:00
|
|
|
{
|
2017-02-13 21:29:00 +00:00
|
|
|
switch (clsId)
|
2016-02-13 19:05:59 +00:00
|
|
|
{
|
|
|
|
case SBIG('IORN'):
|
|
|
|
desc->x0_IORN.reset(CPF::GetVectorElement(in));
|
2017-02-13 21:29:00 +00:00
|
|
|
break;
|
2016-02-13 19:05:59 +00:00
|
|
|
case SBIG('IVEC'):
|
|
|
|
desc->x4_IVEC.reset(CPF::GetVectorElement(in));
|
2017-02-13 21:29:00 +00:00
|
|
|
break;
|
2016-02-13 19:05:59 +00:00
|
|
|
case SBIG('PSVM'):
|
|
|
|
desc->xc_PSVM.reset(CPF::GetModVectorElement(in));
|
2017-02-13 21:29:00 +00:00
|
|
|
break;
|
2016-02-13 19:05:59 +00:00
|
|
|
case SBIG('VMD2'):
|
|
|
|
desc->x10_VMD2 = CPF::GetBool(in);
|
2017-02-13 21:29:00 +00:00
|
|
|
break;
|
2016-02-13 19:05:59 +00:00
|
|
|
case SBIG('PSLT'):
|
|
|
|
desc->x14_PSLT.reset(CPF::GetIntElement(in));
|
2017-02-13 21:29:00 +00:00
|
|
|
break;
|
2016-02-13 19:05:59 +00:00
|
|
|
case SBIG('PCSL'):
|
|
|
|
desc->x18_PCSL.reset(CPF::GetVectorElement(in));
|
2017-02-13 21:29:00 +00:00
|
|
|
break;
|
2016-02-13 19:05:59 +00:00
|
|
|
case SBIG('PCOL'):
|
|
|
|
desc->x1c_PCOL.reset(CPF::GetColorElement(in));
|
2017-02-13 21:29:00 +00:00
|
|
|
break;
|
2016-02-13 19:05:59 +00:00
|
|
|
case SBIG('POFS'):
|
2017-02-13 21:29:00 +00:00
|
|
|
desc->x20_POFS.reset(CPF::GetVectorElement(in));
|
|
|
|
break;
|
2016-02-13 19:05:59 +00:00
|
|
|
case SBIG('OFST'):
|
|
|
|
desc->x24_OFST.reset(CPF::GetVectorElement(in));
|
2017-02-13 21:29:00 +00:00
|
|
|
break;
|
2016-02-13 19:05:59 +00:00
|
|
|
case SBIG('APSO'):
|
|
|
|
desc->x28_APSO = CPF::GetBool(in);
|
2017-02-13 21:29:00 +00:00
|
|
|
break;
|
2016-02-13 19:05:59 +00:00
|
|
|
case SBIG('HOMG'):
|
|
|
|
desc->x29_HOMG = CPF::GetBool(in);
|
2017-02-13 21:29:00 +00:00
|
|
|
break;
|
2016-02-13 19:05:59 +00:00
|
|
|
case SBIG('AP11'):
|
|
|
|
desc->x2a_AP11 = CPF::GetBool(in);
|
2017-02-13 21:29:00 +00:00
|
|
|
break;
|
2016-02-13 19:05:59 +00:00
|
|
|
case SBIG('AP21'):
|
2016-02-23 02:08:13 +00:00
|
|
|
desc->x2b_AP21 = CPF::GetBool(in);
|
2017-02-13 21:29:00 +00:00
|
|
|
break;
|
2016-02-23 02:08:13 +00:00
|
|
|
case SBIG('AS11'):
|
2016-02-13 19:05:59 +00:00
|
|
|
desc->x2c_AS11 = CPF::GetBool(in);
|
2017-02-13 21:29:00 +00:00
|
|
|
break;
|
2016-02-13 19:05:59 +00:00
|
|
|
case SBIG('AS12'):
|
|
|
|
desc->x2d_AS12 = CPF::GetBool(in);
|
2017-02-13 21:29:00 +00:00
|
|
|
break;
|
2016-02-13 19:05:59 +00:00
|
|
|
case SBIG('AS13'):
|
|
|
|
desc->x2e_AS13 = CPF::GetBool(in);
|
2017-02-13 21:29:00 +00:00
|
|
|
break;
|
2016-02-13 19:05:59 +00:00
|
|
|
case SBIG('TRAT'):
|
|
|
|
desc->x30_TRAT.reset(CPF::GetRealElement(in));
|
2017-02-13 21:29:00 +00:00
|
|
|
break;
|
2016-02-13 19:05:59 +00:00
|
|
|
case SBIG('APSM'):
|
|
|
|
{
|
2016-04-14 21:42:47 +00:00
|
|
|
std::vector<ResId> tracker;
|
2016-02-13 19:05:59 +00:00
|
|
|
tracker.reserve(8);
|
|
|
|
desc->x34_APSM = CPF::GetChildGeneratorDesc(in, resPool, tracker);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case SBIG('APS2'):
|
|
|
|
{
|
2016-04-14 21:42:47 +00:00
|
|
|
std::vector<ResId> tracker;
|
2016-02-13 19:05:59 +00:00
|
|
|
tracker.reserve(8);
|
|
|
|
desc->x44_APS2 = CPF::GetChildGeneratorDesc(in, resPool, tracker);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case SBIG('ASW1'):
|
|
|
|
desc->x54_ASW1 = CPF::GetSwooshGeneratorDesc(in, resPool);
|
2017-02-13 21:29:00 +00:00
|
|
|
break;
|
2016-02-13 19:05:59 +00:00
|
|
|
case SBIG('ASW2'):
|
|
|
|
desc->x64_ASW2 = CPF::GetSwooshGeneratorDesc(in, resPool);
|
2017-02-13 21:29:00 +00:00
|
|
|
break;
|
2016-02-13 19:05:59 +00:00
|
|
|
case SBIG('ASW3'):
|
|
|
|
desc->x74_ASW3 = CPF::GetSwooshGeneratorDesc(in, resPool);
|
2017-02-13 21:29:00 +00:00
|
|
|
break;
|
2016-02-13 19:05:59 +00:00
|
|
|
case SBIG('OHEF'):
|
|
|
|
desc->x84_OHEF = CPF::GetModel(in, resPool);
|
2017-02-13 21:29:00 +00:00
|
|
|
break;
|
2016-02-13 19:05:59 +00:00
|
|
|
case SBIG('COLR'):
|
|
|
|
{
|
|
|
|
FourCC cid = CPF::GetClassID(in);
|
|
|
|
if (cid == SBIG('NONE'))
|
|
|
|
break;
|
2016-04-14 21:42:47 +00:00
|
|
|
ResId id = CPF::GetInt(in);
|
2016-02-13 19:05:59 +00:00
|
|
|
if (id)
|
|
|
|
desc->x94_COLR = {resPool->GetObj({FOURCC('CRSC'), id}), true};
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case SBIG('EWTR'):
|
|
|
|
desc->xa4_EWTR = CPF::GetBool(in);
|
2017-02-13 21:29:00 +00:00
|
|
|
break;
|
2016-02-13 19:05:59 +00:00
|
|
|
case SBIG('LWTR'):
|
|
|
|
desc->xa5_LWTR = CPF::GetBool(in);
|
2017-02-13 21:29:00 +00:00
|
|
|
break;
|
2016-02-13 19:05:59 +00:00
|
|
|
case SBIG('SWTR'):
|
|
|
|
desc->xa6_SWTR = CPF::GetBool(in);
|
2017-02-13 21:29:00 +00:00
|
|
|
break;
|
2016-02-13 19:05:59 +00:00
|
|
|
case SBIG('PJFX'):
|
|
|
|
{
|
|
|
|
FourCC cid = CPF::GetClassID(in);
|
2016-02-13 19:11:00 +00:00
|
|
|
if (cid == FOURCC('NONE'))
|
|
|
|
break;
|
|
|
|
|
2016-02-13 19:05:59 +00:00
|
|
|
desc->xa8_PJFX = CPF::GetInt(in);
|
|
|
|
break;
|
|
|
|
}
|
2016-03-29 00:07:38 +00:00
|
|
|
case SBIG('RNGE'):
|
|
|
|
desc->xac_RNGE.reset(CPF::GetRealElement(in));
|
2017-02-13 21:29:00 +00:00
|
|
|
break;
|
2016-03-29 00:07:38 +00:00
|
|
|
case SBIG('FOFF'):
|
|
|
|
desc->xb0_FOFF.reset(CPF::GetRealElement(in));
|
2017-02-13 21:29:00 +00:00
|
|
|
break;
|
2016-02-13 19:05:59 +00:00
|
|
|
default:
|
|
|
|
{
|
|
|
|
uint32_t clsName = clsId.toUint32();
|
2016-03-04 23:04:53 +00:00
|
|
|
Log.report(logvisor::Fatal, "Unknown WPSM class %.4s @%" PRIi64, &clsName, in.position());
|
2016-02-13 19:05:59 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
clsId = CPF::GetClassID(in);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-02-13 21:29:00 +00:00
|
|
|
CFactoryFnReturn FProjectileWeaponDataFactory(const SObjectTag& tag, CInputStream& in, const CVParamTransfer& vparms,
|
|
|
|
CObjectReference*)
|
2016-02-13 19:05:59 +00:00
|
|
|
{
|
2016-12-23 06:41:39 +00:00
|
|
|
CSimplePool* sp = vparms.GetOwnedObj<CSimplePool*>();
|
2017-02-13 21:29:00 +00:00
|
|
|
return TToken<CWeaponDescription>::GetIObjObjectFor(
|
|
|
|
std::unique_ptr<CWeaponDescription>(CProjectileWeaponDataFactory::GetGeneratorDesc(in, sp)));
|
2016-02-13 19:05:59 +00:00
|
|
|
}
|
|
|
|
}
|