2016-02-10 22:54:47 +00:00
|
|
|
#include "CParticleElectricDataFactory.hpp"
|
|
|
|
#include "CElectricDescription.hpp"
|
2016-02-13 08:23:17 +00:00
|
|
|
#include "CToken.hpp"
|
2016-02-10 22:54:47 +00:00
|
|
|
#include "CSimplePool.hpp"
|
2016-02-13 06:25:29 +00:00
|
|
|
#include "CRandom16.hpp"
|
2016-02-10 22:54:47 +00:00
|
|
|
|
2016-02-13 09:02:47 +00:00
|
|
|
namespace pshag
|
2016-02-10 22:54:47 +00:00
|
|
|
{
|
2016-02-13 08:23:17 +00:00
|
|
|
static LogVisor::LogModule Log("Retro::CParticleElectricDataFactory");
|
2016-02-10 22:54:47 +00:00
|
|
|
|
2016-02-13 06:25:29 +00:00
|
|
|
using CPF = CParticleDataFactory;
|
|
|
|
|
2016-02-10 22:54:47 +00:00
|
|
|
CElectricDescription* CParticleElectricDataFactory::GetGeneratorDesc(CInputStream &in, CSimplePool *resPool)
|
|
|
|
{
|
|
|
|
return CreateElectricDescription(in, resPool);
|
|
|
|
}
|
|
|
|
|
|
|
|
CElectricDescription* CParticleElectricDataFactory::CreateElectricDescription(CInputStream &in, CSimplePool *resPool)
|
|
|
|
{
|
2016-02-13 08:23:17 +00:00
|
|
|
FourCC cid = CPF::GetClassID(in);
|
2016-02-13 06:25:29 +00:00
|
|
|
if (cid == FOURCC('ELSM'))
|
|
|
|
{
|
2016-02-13 08:23:17 +00:00
|
|
|
CElectricDescription* desc = new CElectricDescription;
|
2016-02-13 06:25:29 +00:00
|
|
|
CreateELSM(desc, in, resPool);
|
2016-02-13 08:23:17 +00:00
|
|
|
LoadELSMTokens(desc);
|
|
|
|
return desc;
|
2016-02-13 06:25:29 +00:00
|
|
|
}
|
|
|
|
|
2016-02-10 22:54:47 +00:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2016-02-13 06:25:29 +00:00
|
|
|
bool CParticleElectricDataFactory::CreateELSM(CElectricDescription *desc, CInputStream &in, CSimplePool *resPool)
|
|
|
|
{
|
|
|
|
CRandom16 rand;
|
|
|
|
FourCC clsId = CPF::GetClassID(in);
|
|
|
|
while (clsId != SBIG('_END'))
|
|
|
|
{
|
|
|
|
CGlobalRandom gr(rand);
|
|
|
|
switch(clsId)
|
|
|
|
{
|
2016-02-13 08:23:17 +00:00
|
|
|
case SBIG('LIFE'):
|
2016-02-13 06:25:29 +00:00
|
|
|
desc->x0_LIFE.reset(CPF::GetIntElement(in));
|
|
|
|
break;
|
|
|
|
case SBIG('SLIF'):
|
|
|
|
desc->x4_SLIF.reset(CPF::GetIntElement(in));
|
|
|
|
break;
|
|
|
|
case SBIG('GRAT'):
|
|
|
|
desc->x8_GRAT.reset(CPF::GetRealElement(in));
|
|
|
|
break;
|
|
|
|
case SBIG('SCNT'):
|
|
|
|
desc->xc_SCNT.reset(CPF::GetIntElement(in));
|
|
|
|
break;
|
|
|
|
case SBIG('SSEG'):
|
|
|
|
desc->x10_SSEG.reset(CPF::GetIntElement(in));
|
|
|
|
break;
|
|
|
|
case SBIG('COLR'):
|
|
|
|
desc->x14_COLR.reset(CPF::GetColorElement(in));
|
|
|
|
break;
|
|
|
|
case SBIG('IEMT'):
|
|
|
|
desc->x18_IEMT = CPF::GetBool(in);
|
|
|
|
break;
|
|
|
|
case SBIG('FEMT'):
|
|
|
|
desc->x1c_FEMT = CPF::GetBool(in);
|
|
|
|
break;
|
|
|
|
case SBIG('AMPL'):
|
|
|
|
desc->x20_AMPL = CPF::GetBool(in);
|
|
|
|
break;
|
|
|
|
case SBIG('AMPD'):
|
|
|
|
desc->x24_AMPD = CPF::GetBool(in);
|
|
|
|
break;
|
|
|
|
case SBIG('LWD1'):
|
|
|
|
desc->x28_LWD1 = CPF::GetBool(in);
|
|
|
|
break;
|
|
|
|
case SBIG('LWD2'):
|
|
|
|
desc->x2c_LWD2 = CPF::GetBool(in);
|
|
|
|
break;
|
|
|
|
case SBIG('LWD3'):
|
|
|
|
desc->x30_LWD3 = CPF::GetBool(in);
|
|
|
|
break;
|
|
|
|
case SBIG('LCL1'):
|
|
|
|
desc->x34_LCL1.reset(CPF::GetColorElement(in));
|
|
|
|
break;
|
|
|
|
case SBIG('LCL2'):
|
|
|
|
desc->x38_LCL2.reset(CPF::GetColorElement(in));
|
|
|
|
break;
|
|
|
|
case SBIG('LCL3'):
|
|
|
|
desc->x3c_LCL3.reset(CPF::GetColorElement(in));
|
|
|
|
break;
|
|
|
|
case SBIG('SSWH'):
|
|
|
|
desc->x40_SSWH = CPF::GetSwooshGeneratorDesc(in, resPool);
|
2016-02-13 09:02:47 +00:00
|
|
|
break;
|
2016-02-13 06:25:29 +00:00
|
|
|
case SBIG('GPSM'):
|
|
|
|
{
|
|
|
|
std::vector<TResId> tracker;
|
|
|
|
tracker.reserve(8);
|
|
|
|
desc->x50_GPSM = CPF::GetChildGeneratorDesc(in, resPool, tracker);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case SBIG('EPSM'):
|
|
|
|
{
|
|
|
|
std::vector<TResId> tracker;
|
|
|
|
tracker.reserve(8);
|
|
|
|
desc->x60_EPSM = CPF::GetChildGeneratorDesc(in, resPool, tracker);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case SBIG('ZERY'):
|
|
|
|
desc->x70_ZERY = CPF::GetBool(in);
|
|
|
|
break;
|
2016-02-13 06:38:05 +00:00
|
|
|
default:
|
|
|
|
{
|
|
|
|
uint32_t clsName = clsId.toUint32();
|
|
|
|
Log.report(LogVisor::FatalError, "Unknown ELSM class %.4s @%" PRIi64, &clsName, in.position());
|
|
|
|
return false;
|
|
|
|
}
|
2016-02-13 06:25:29 +00:00
|
|
|
}
|
2016-02-13 08:23:17 +00:00
|
|
|
clsId = CPF::GetClassID(in);
|
2016-02-13 06:25:29 +00:00
|
|
|
}
|
2016-02-13 06:38:05 +00:00
|
|
|
return true;
|
2016-02-13 06:25:29 +00:00
|
|
|
}
|
|
|
|
|
2016-02-13 09:02:47 +00:00
|
|
|
std::unique_ptr<pshag::IObj> FParticleElecrticFactory(const pshag::SObjectTag &tag, pshag::CInputStream &in, const pshag::CVParamTransfer &vparms)
|
2016-02-10 22:54:47 +00:00
|
|
|
{
|
|
|
|
CSimplePool* sp = static_cast<CSimplePool*>(static_cast<TObjOwnerParam<IObjectStore*>*>(vparms.GetObj())->GetParam());
|
|
|
|
return TToken<CElectricDescription>::GetIObjObjectFor(std::unique_ptr<CElectricDescription>(CParticleElectricDataFactory::GetGeneratorDesc(in, sp)));
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|