metaforce/DataSpec/DNACommon/ParticleCommon.hpp

1617 lines
38 KiB
C++
Raw Normal View History

2016-02-02 04:29:58 +00:00
#ifndef __COMMON_PARTICLECOMMON_HPP__
#define __COMMON_PARTICLECOMMON_HPP__
#include "DNACommon.hpp"
2016-02-13 09:02:47 +00:00
namespace DataSpec
2016-02-02 04:29:58 +00:00
{
namespace DNAParticle
{
2016-03-04 23:04:53 +00:00
extern logvisor::Module LogModule;
2016-02-02 04:29:58 +00:00
struct IElement : BigYAML
{
Delete _d;
virtual ~IElement() = default;
2016-02-02 23:41:55 +00:00
virtual const char* ClassID() const=0;
2016-02-02 04:29:58 +00:00
};
struct IRealElement : IElement {Delete _d;};
struct RealElementFactory : BigYAML
{
Delete _d;
std::unique_ptr<IRealElement> m_elem;
2016-02-04 00:55:39 +00:00
operator bool() const {return m_elem.operator bool();}
2016-02-02 04:29:58 +00:00
2016-03-04 23:04:53 +00:00
void read(athena::io::YAMLDocReader& r);
void write(athena::io::YAMLDocWriter& w) const;
2016-02-02 04:29:58 +00:00
size_t binarySize(size_t __isz) const;
2016-03-04 23:04:53 +00:00
void read(athena::io::IStreamReader& r);
void write(athena::io::IStreamWriter& w) const;
2016-02-02 04:29:58 +00:00
};
struct IIntElement : IElement {Delete _d;};
struct IntElementFactory : BigYAML
{
Delete _d;
std::unique_ptr<IIntElement> m_elem;
2016-02-04 00:55:39 +00:00
operator bool() const {return m_elem.operator bool();}
2016-02-02 04:29:58 +00:00
2016-03-04 23:04:53 +00:00
void read(athena::io::YAMLDocReader& r);
void write(athena::io::YAMLDocWriter& w) const;
2016-02-02 04:29:58 +00:00
size_t binarySize(size_t __isz) const;
2016-03-04 23:04:53 +00:00
void read(athena::io::IStreamReader& r);
void write(athena::io::IStreamWriter& w) const;
2016-02-02 04:29:58 +00:00
};
2016-02-02 08:22:01 +00:00
struct IVectorElement : IElement {Delete _d;};
struct VectorElementFactory : BigYAML
{
Delete _d;
std::unique_ptr<IVectorElement> m_elem;
2016-02-04 00:55:39 +00:00
operator bool() const {return m_elem.operator bool();}
2016-02-02 08:22:01 +00:00
2016-03-04 23:04:53 +00:00
void read(athena::io::YAMLDocReader& r);
void write(athena::io::YAMLDocWriter& w) const;
2016-02-02 08:22:01 +00:00
size_t binarySize(size_t __isz) const;
2016-03-04 23:04:53 +00:00
void read(athena::io::IStreamReader& r);
void write(athena::io::IStreamWriter& w) const;
2016-02-02 08:22:01 +00:00
};
struct IColorElement : IElement {Delete _d;};
struct ColorElementFactory : BigYAML
{
Delete _d;
std::unique_ptr<IColorElement> m_elem;
2016-02-04 00:55:39 +00:00
operator bool() const {return m_elem.operator bool();}
2016-02-02 08:22:01 +00:00
2016-03-04 23:04:53 +00:00
void read(athena::io::YAMLDocReader& r);
void write(athena::io::YAMLDocWriter& w) const;
2016-02-02 08:22:01 +00:00
size_t binarySize(size_t __isz) const;
2016-03-04 23:04:53 +00:00
void read(athena::io::IStreamReader& r);
void write(athena::io::IStreamWriter& w) const;
2016-02-02 08:22:01 +00:00
};
struct IModVectorElement : IElement {Delete _d;};
struct ModVectorElementFactory : BigYAML
{
Delete _d;
std::unique_ptr<IModVectorElement> m_elem;
2016-02-04 00:55:39 +00:00
operator bool() const {return m_elem.operator bool();}
2016-02-02 08:22:01 +00:00
2016-03-04 23:04:53 +00:00
void read(athena::io::YAMLDocReader& r);
void write(athena::io::YAMLDocWriter& w) const;
2016-02-02 08:22:01 +00:00
size_t binarySize(size_t __isz) const;
2016-03-04 23:04:53 +00:00
void read(athena::io::IStreamReader& r);
void write(athena::io::IStreamWriter& w) const;
2016-02-02 08:22:01 +00:00
};
struct IEmitterElement : IElement {Delete _d;};
struct EmitterElementFactory : BigYAML
{
Delete _d;
std::unique_ptr<IEmitterElement> m_elem;
2016-02-04 00:55:39 +00:00
operator bool() const {return m_elem.operator bool();}
2016-03-04 23:04:53 +00:00
void read(athena::io::YAMLDocReader& r);
void write(athena::io::YAMLDocWriter& w) const;
size_t binarySize(size_t __isz) const;
2016-03-04 23:04:53 +00:00
void read(athena::io::IStreamReader& r);
void write(athena::io::IStreamWriter& w) const;
};
2016-10-02 22:41:36 +00:00
struct IUVElement : IElement
{
Delete _d;
virtual void gatherDependencies(std::vector<hecl::ProjectPath>& pathsOut) const=0;
};
2016-02-02 08:22:01 +00:00
2016-03-02 22:37:10 +00:00
struct BoolHelper : IElement
{
Delete _d;
bool value = false;
operator bool() const {return value;}
BoolHelper& operator=(bool val) {value = val; return *this;}
2016-03-04 23:04:53 +00:00
void read(athena::io::YAMLDocReader& r)
2016-03-02 22:37:10 +00:00
{
value = r.readBool(nullptr);
}
2016-03-04 23:04:53 +00:00
void write(athena::io::YAMLDocWriter& w) const
2016-03-02 22:37:10 +00:00
{
w.writeBool(nullptr, value);
}
size_t binarySize(size_t __isz) const
{
return __isz + 5;
}
2016-03-04 23:04:53 +00:00
void read(athena::io::IStreamReader& r)
2016-03-02 22:37:10 +00:00
{
uint32_t clsId;
r.readBytesToBuf(&clsId, 4);
if (clsId == SBIG('CNST'))
value = r.readBool();
else
value = false;
}
2016-03-04 23:04:53 +00:00
void write(athena::io::IStreamWriter& w) const
2016-03-02 22:37:10 +00:00
{
w.writeBytes((atInt8*)"CNST", 4);
w.writeBool(value);
}
const char* ClassID() const {return "BoolHelper";}
};
2016-02-02 04:29:58 +00:00
struct RELifetimeTween : IRealElement
{
DECL_YAML
RealElementFactory a;
RealElementFactory b;
2016-02-02 23:41:55 +00:00
const char* ClassID() const {return "LFTW";}
2016-02-02 04:29:58 +00:00
};
struct REConstant : IRealElement
{
2016-02-04 00:55:39 +00:00
Delete _d;
2016-02-02 04:29:58 +00:00
Value<float> val;
2016-02-04 00:55:39 +00:00
2016-03-04 23:04:53 +00:00
void read(athena::io::YAMLDocReader& r)
2016-02-04 00:55:39 +00:00
{
val = r.readFloat(nullptr);
}
2016-03-04 23:04:53 +00:00
void write(athena::io::YAMLDocWriter& w) const
2016-02-04 00:55:39 +00:00
{
w.writeFloat(nullptr, val);
}
size_t binarySize(size_t __isz) const
{
return __isz + 4;
}
2016-03-04 23:04:53 +00:00
void read(athena::io::IStreamReader& r)
2016-02-04 00:55:39 +00:00
{
val = r.readFloatBig();
}
2016-03-04 23:04:53 +00:00
void write(athena::io::IStreamWriter& w) const
2016-02-04 00:55:39 +00:00
{
w.writeFloatBig(val);
}
2016-02-02 23:41:55 +00:00
const char* ClassID() const {return "CNST";}
2016-02-02 04:29:58 +00:00
};
struct RETimeChain : IRealElement
{
DECL_YAML
RealElementFactory a;
RealElementFactory b;
2016-03-02 22:37:10 +00:00
IntElementFactory thresholdFrame;
2016-02-02 23:41:55 +00:00
const char* ClassID() const {return "CHAN";}
2016-02-02 04:29:58 +00:00
};
struct REAdd : IRealElement
{
DECL_YAML
RealElementFactory a;
RealElementFactory b;
2016-02-02 23:41:55 +00:00
const char* ClassID() const {return "ADD_";}
2016-02-02 04:29:58 +00:00
};
struct REClamp : IRealElement
{
DECL_YAML
2016-03-02 22:37:10 +00:00
RealElementFactory min;
RealElementFactory max;
RealElementFactory val;
2016-02-02 23:41:55 +00:00
const char* ClassID() const {return "CLMP";}
2016-02-02 04:29:58 +00:00
};
struct REKeyframeEmitter : IRealElement
{
DECL_YAML
2016-03-02 22:37:10 +00:00
Value<atUint32> percentageTween;
Value<atUint32> unk1;
Value<bool> loop;
Value<atUint8> unk2;
Value<atUint32> loopEnd;
Value<atUint32> loopStart;
2016-02-02 04:29:58 +00:00
Value<atUint32> count;
Vector<float, DNA_COUNT(count)> keys;
2016-03-02 22:37:10 +00:00
const char* ClassID() const {return percentageTween ? "KEYP" : "KEYE";}
2016-02-02 04:29:58 +00:00
};
struct REInitialRandom : IRealElement
{
DECL_YAML
RealElementFactory a;
RealElementFactory b;
2016-02-02 23:41:55 +00:00
const char* ClassID() const {return "IRND";}
2016-02-02 04:29:58 +00:00
};
struct RERandom : IRealElement
{
DECL_YAML
RealElementFactory a;
RealElementFactory b;
2016-02-02 23:41:55 +00:00
const char* ClassID() const {return "RAND";}
2016-02-02 04:29:58 +00:00
};
struct REMultiply : IRealElement
{
DECL_YAML
RealElementFactory a;
RealElementFactory b;
2016-02-02 23:41:55 +00:00
const char* ClassID() const {return "MULT";}
2016-02-02 04:29:58 +00:00
};
struct REPulse : IRealElement
{
DECL_YAML
2016-03-02 22:37:10 +00:00
IntElementFactory aDuration;
IntElementFactory bDuration;
RealElementFactory a;
RealElementFactory b;
2016-02-02 23:41:55 +00:00
const char* ClassID() const {return "PULS";}
2016-02-02 04:29:58 +00:00
};
struct RETimeScale : IRealElement
{
DECL_YAML
2016-03-02 22:37:10 +00:00
RealElementFactory dv;
2016-02-02 23:41:55 +00:00
const char* ClassID() const {return "SCAL";}
2016-02-02 04:29:58 +00:00
};
struct RELifetimePercent : IRealElement
{
DECL_YAML
2016-03-02 22:37:10 +00:00
RealElementFactory percent;
2016-02-02 23:41:55 +00:00
const char* ClassID() const {return "RLPT";}
2016-02-02 04:29:58 +00:00
};
struct RESineWave : IRealElement
{
DECL_YAML
2016-03-02 22:37:10 +00:00
RealElementFactory magnitude;
RealElementFactory linearAngle;
RealElementFactory constantAngle;
2016-02-02 23:41:55 +00:00
const char* ClassID() const {return "SINE";}
2016-02-02 04:29:58 +00:00
};
2016-03-02 22:37:10 +00:00
struct REInitialSwitch : IRealElement
2016-02-04 00:55:39 +00:00
{
DECL_YAML
RealElementFactory a;
RealElementFactory b;
const char* ClassID() const {return "ISWT";}
};
struct RECompareLessThan : IRealElement
{
DECL_YAML
2016-03-02 22:37:10 +00:00
RealElementFactory ca;
RealElementFactory cb;
RealElementFactory pass;
RealElementFactory fail;
2016-02-04 00:55:39 +00:00
const char* ClassID() const {return "CLTN";}
};
struct RECompareEquals : IRealElement
{
DECL_YAML
2016-03-02 22:37:10 +00:00
RealElementFactory ca;
RealElementFactory cb;
RealElementFactory pass;
RealElementFactory fail;
2016-02-04 00:55:39 +00:00
const char* ClassID() const {return "CEQL";}
};
2016-03-02 22:37:10 +00:00
struct REParticleAdvanceParam1 : IRealElement
2016-02-04 00:55:39 +00:00
{
DECL_YAML
const char* ClassID() const {return "PAP1";}
};
2016-03-02 22:37:10 +00:00
struct REParticleAdvanceParam2 : IRealElement
2016-02-04 00:55:39 +00:00
{
DECL_YAML
const char* ClassID() const {return "PAP2";}
};
2016-03-02 22:37:10 +00:00
struct REParticleAdvanceParam3 : IRealElement
2016-02-04 00:55:39 +00:00
{
DECL_YAML
const char* ClassID() const {return "PAP3";}
};
2016-03-02 22:37:10 +00:00
struct REParticleAdvanceParam4 : IRealElement
2016-02-04 00:55:39 +00:00
{
DECL_YAML
const char* ClassID() const {return "PAP4";}
};
2016-03-02 22:37:10 +00:00
struct REParticleAdvanceParam5 : IRealElement
2016-02-04 00:55:39 +00:00
{
DECL_YAML
const char* ClassID() const {return "PAP5";}
};
2016-03-02 22:37:10 +00:00
struct REParticleAdvanceParam6 : IRealElement
2016-02-04 00:55:39 +00:00
{
DECL_YAML
const char* ClassID() const {return "PAP6";}
};
2016-03-02 22:37:10 +00:00
struct REParticleAdvanceParam7 : IRealElement
2016-02-04 00:55:39 +00:00
{
DECL_YAML
const char* ClassID() const {return "PAP7";}
};
2016-03-02 22:37:10 +00:00
struct REParticleAdvanceParam8 : IRealElement
2016-02-04 00:55:39 +00:00
{
DECL_YAML
const char* ClassID() const {return "PAP8";}
};
2016-03-02 22:37:10 +00:00
struct REParticleSizeOrLineLength : IRealElement
2016-02-04 00:55:39 +00:00
{
DECL_YAML
const char* ClassID() const {return "PSLL";}
};
2016-03-02 22:37:10 +00:00
struct REParticleRotationOrLineWidth : IRealElement
2016-02-04 00:55:39 +00:00
{
DECL_YAML
const char* ClassID() const {return "PRLW";}
};
struct RESubtract : IRealElement
{
DECL_YAML
RealElementFactory a;
RealElementFactory b;
const char* ClassID() const {return "SUB_";}
};
struct REVectorMagnitude : IRealElement
{
DECL_YAML
2016-03-02 22:37:10 +00:00
VectorElementFactory vec;
2016-02-04 00:55:39 +00:00
const char* ClassID() const {return "VMAG";}
};
struct REVectorXToReal : IRealElement
{
DECL_YAML
2016-03-02 22:37:10 +00:00
VectorElementFactory vec;
2016-02-04 00:55:39 +00:00
const char* ClassID() const {return "VXTR";}
};
struct REVectorYToReal : IRealElement
{
DECL_YAML
2016-03-02 22:37:10 +00:00
VectorElementFactory vec;
2016-02-04 00:55:39 +00:00
const char* ClassID() const {return "VYTR";}
};
struct REVectorZToReal : IRealElement
{
DECL_YAML
2016-03-02 22:37:10 +00:00
VectorElementFactory vec;
2016-02-04 00:55:39 +00:00
const char* ClassID() const {return "VZTR";}
};
struct RECEXT : IRealElement
{
DECL_YAML
2016-03-02 22:37:10 +00:00
IntElementFactory index;
2016-02-04 00:55:39 +00:00
const char* ClassID() const {return "CEXT";}
};
2016-02-07 00:19:59 +00:00
struct REIntTimesReal : IRealElement
2016-02-04 00:55:39 +00:00
{
DECL_YAML
IntElementFactory a;
RealElementFactory b;
const char* ClassID() const {return "ITRL";}
};
2016-02-02 04:29:58 +00:00
struct IEKeyframeEmitter : IIntElement
{
DECL_YAML
2016-03-02 22:37:10 +00:00
Value<atUint32> percentageTween;
Value<atUint32> unk1;
Value<bool> loop;
Value<atUint8> unk2;
Value<atUint32> loopEnd;
Value<atUint32> loopStart;
2016-02-02 04:29:58 +00:00
Value<atUint32> count;
Vector<atUint32, DNA_COUNT(count)> keys;
2016-03-02 22:37:10 +00:00
const char* ClassID() const {return percentageTween ? "KEYP" : "KEYE";}
2016-02-02 04:29:58 +00:00
};
struct IEDeath : IIntElement
{
DECL_YAML
2016-03-02 22:37:10 +00:00
IntElementFactory passthrough;
IntElementFactory thresholdFrame;
2016-02-02 23:41:55 +00:00
const char* ClassID() const {return "DETH";}
2016-02-02 04:29:58 +00:00
};
struct IEClamp : IIntElement
{
DECL_YAML
2016-03-02 22:37:10 +00:00
IntElementFactory min;
IntElementFactory max;
IntElementFactory val;
2016-02-02 23:41:55 +00:00
const char* ClassID() const {return "CLMP";}
2016-02-02 04:29:58 +00:00
};
struct IETimeChain : IIntElement
{
DECL_YAML
IntElementFactory a;
IntElementFactory b;
2016-03-02 22:37:10 +00:00
IntElementFactory thresholdFrame;
2016-02-02 23:41:55 +00:00
const char* ClassID() const {return "CHAN";}
2016-02-02 04:29:58 +00:00
};
struct IEAdd : IIntElement
{
DECL_YAML
IntElementFactory a;
IntElementFactory b;
2016-02-02 23:41:55 +00:00
const char* ClassID() const {return "ADD_";}
2016-02-02 04:29:58 +00:00
};
struct IEConstant : IIntElement
{
2016-02-04 00:55:39 +00:00
Delete _d;
2016-02-02 04:29:58 +00:00
Value<atUint32> val;
2016-02-04 00:55:39 +00:00
2016-03-04 23:04:53 +00:00
void read(athena::io::YAMLDocReader& r)
2016-02-04 00:55:39 +00:00
{
val = r.readUint32(nullptr);
}
2016-03-04 23:04:53 +00:00
void write(athena::io::YAMLDocWriter& w) const
2016-02-04 00:55:39 +00:00
{
w.writeUint32(nullptr, val);
}
size_t binarySize(size_t __isz) const
{
return __isz + 4;
}
2016-03-04 23:04:53 +00:00
void read(athena::io::IStreamReader& r)
2016-02-04 00:55:39 +00:00
{
val = r.readUint32Big();
}
2016-03-04 23:04:53 +00:00
void write(athena::io::IStreamWriter& w) const
2016-02-04 00:55:39 +00:00
{
w.writeUint32Big(val);
}
2016-02-02 23:41:55 +00:00
const char* ClassID() const {return "CNST";}
2016-02-02 04:29:58 +00:00
};
struct IEImpulse : IIntElement
{
DECL_YAML
2016-03-02 22:37:10 +00:00
IntElementFactory val;
2016-02-02 23:41:55 +00:00
const char* ClassID() const {return "IMPL";}
2016-02-02 04:29:58 +00:00
};
struct IELifetimePercent : IIntElement
{
DECL_YAML
2016-03-02 22:37:10 +00:00
IntElementFactory percent;
2016-02-02 23:41:55 +00:00
const char* ClassID() const {return "ILPT";}
2016-02-02 04:29:58 +00:00
};
struct IEInitialRandom : IIntElement
{
DECL_YAML
IntElementFactory a;
IntElementFactory b;
2016-02-02 23:41:55 +00:00
const char* ClassID() const {return "IRND";}
2016-02-02 04:29:58 +00:00
};
struct IEPulse : IIntElement
{
DECL_YAML
2016-03-02 22:37:10 +00:00
IntElementFactory aDuration;
IntElementFactory bDuration;
2016-02-02 04:29:58 +00:00
IntElementFactory a;
IntElementFactory b;
2016-02-02 23:41:55 +00:00
const char* ClassID() const {return "PULS";}
2016-02-02 04:29:58 +00:00
};
struct IEMultiply : IIntElement
{
DECL_YAML
IntElementFactory a;
IntElementFactory b;
2016-02-02 23:41:55 +00:00
const char* ClassID() const {return "MULT";}
2016-02-02 04:29:58 +00:00
};
struct IESampleAndHold : IIntElement
{
DECL_YAML
2016-03-02 22:37:10 +00:00
IntElementFactory val;
IntElementFactory waitMin;
IntElementFactory waitMax;
2016-02-02 23:41:55 +00:00
const char* ClassID() const {return "SPAH";}
2016-02-02 04:29:58 +00:00
};
struct IERandom : IIntElement
{
DECL_YAML
IntElementFactory a;
IntElementFactory b;
2016-02-02 23:41:55 +00:00
const char* ClassID() const {return "RAND";}
2016-02-02 04:29:58 +00:00
};
struct IETimeScale : IIntElement
{
DECL_YAML
2016-03-02 22:37:10 +00:00
RealElementFactory dv;
2016-02-02 23:41:55 +00:00
const char* ClassID() const {return "TSCL";}
2016-02-02 04:29:58 +00:00
};
2016-02-04 00:55:39 +00:00
struct IEGTCP : IIntElement
{
DECL_YAML
const char* ClassID() const {return "GTCP";}
};
struct IEModulo : IIntElement
{
DECL_YAML
IntElementFactory a;
IntElementFactory b;
const char* ClassID() const {return "MODU";}
};
struct IESubtract : IIntElement
{
DECL_YAML
2016-03-02 22:37:10 +00:00
IntElementFactory direction;
IntElementFactory baseRadius;
2016-02-04 00:55:39 +00:00
const char* ClassID() const {return "SUB_";}
};
2016-02-02 08:22:01 +00:00
struct VECone : IVectorElement
{
DECL_YAML
VectorElementFactory a;
RealElementFactory b;
2016-02-02 23:41:55 +00:00
const char* ClassID() const {return "CONE";}
2016-02-02 08:22:01 +00:00
};
struct VETimeChain : IVectorElement
{
DECL_YAML
VectorElementFactory a;
VectorElementFactory b;
2016-03-02 22:37:10 +00:00
IntElementFactory thresholdFrame;
2016-02-02 23:41:55 +00:00
const char* ClassID() const {return "CHAN";}
2016-02-02 08:22:01 +00:00
};
struct VEAngleCone : IVectorElement
{
DECL_YAML
2016-03-02 22:37:10 +00:00
RealElementFactory angleXBias;
RealElementFactory angleYBias;
RealElementFactory angleXRange;
RealElementFactory angleYRange;
RealElementFactory magnitude;
2016-02-02 23:41:55 +00:00
const char* ClassID() const {return "ANGC";}
2016-02-02 08:22:01 +00:00
};
struct VEAdd : IVectorElement
{
DECL_YAML
VectorElementFactory a;
VectorElementFactory b;
2016-02-02 23:41:55 +00:00
const char* ClassID() const {return "ADD_";}
2016-02-02 08:22:01 +00:00
};
struct VECircleCluster : IVectorElement
{
DECL_YAML
2016-03-02 22:37:10 +00:00
VectorElementFactory circleOffset;
VectorElementFactory circleNormal;
IntElementFactory cycleFrames;
RealElementFactory randomFactor;
2016-02-02 23:41:55 +00:00
const char* ClassID() const {return "CCLU";}
2016-02-02 08:22:01 +00:00
};
struct VEConstant : IVectorElement
{
2016-02-04 00:55:39 +00:00
Delete _d;
RealElementFactory comps[3];
2016-03-04 23:04:53 +00:00
void read(athena::io::YAMLDocReader& r)
2016-02-04 00:55:39 +00:00
{
2016-03-28 21:38:48 +00:00
size_t elemCount;
r.enterSubVector(nullptr, elemCount);
for (int i=0 ; i<3 && i<elemCount ; ++i)
2016-02-04 00:55:39 +00:00
{
r.enterSubRecord(nullptr);
comps[i].read(r);
r.leaveSubRecord();
}
2016-03-28 21:38:48 +00:00
r.leaveSubVector();
2016-02-04 00:55:39 +00:00
}
2016-03-04 23:04:53 +00:00
void write(athena::io::YAMLDocWriter& w) const
2016-02-04 00:55:39 +00:00
{
w.enterSubVector(nullptr);
for (int i=0 ; i<3 ; ++i)
{
w.enterSubRecord(nullptr);
comps[i].write(w);
w.leaveSubRecord();
}
w.leaveSubVector();
}
size_t binarySize(size_t __isz) const
{
__isz = comps[0].binarySize(__isz);
__isz = comps[1].binarySize(__isz);
return comps[2].binarySize(__isz);
}
2016-03-04 23:04:53 +00:00
void read(athena::io::IStreamReader& r)
2016-02-04 00:55:39 +00:00
{
comps[0].read(r);
comps[1].read(r);
comps[2].read(r);
}
2016-03-04 23:04:53 +00:00
void write(athena::io::IStreamWriter& w) const
2016-02-04 00:55:39 +00:00
{
comps[0].write(w);
comps[1].write(w);
comps[2].write(w);
}
2016-02-02 23:41:55 +00:00
const char* ClassID() const {return "CNST";}
2016-02-02 08:22:01 +00:00
};
struct VECircle : IVectorElement
{
DECL_YAML
2016-03-02 22:37:10 +00:00
VectorElementFactory circleOffset;
VectorElementFactory circleNormal;
RealElementFactory angleConstant;
RealElementFactory angleLinear;
RealElementFactory circleRadius;
2016-02-02 23:41:55 +00:00
const char* ClassID() const {return "CIRC";}
2016-02-02 08:22:01 +00:00
};
struct VEKeyframeEmitter : IVectorElement
{
DECL_YAML
2016-03-02 22:37:10 +00:00
Value<atUint32> percentageTween;
Value<atUint32> unk1;
Value<bool> loop;
Value<atUint8> unk2;
Value<atUint32> loopEnd;
Value<atUint32> loopStart;
2016-02-02 08:22:01 +00:00
Value<atUint32> count;
Vector<atVec3f, DNA_COUNT(count)> keys;
2016-03-02 22:37:10 +00:00
const char* ClassID() const {return percentageTween ? "KEYP" : "KEYE";}
2016-02-02 08:22:01 +00:00
};
struct VEMultiply : IVectorElement
{
DECL_YAML
VectorElementFactory a;
VectorElementFactory b;
2016-02-02 23:41:55 +00:00
const char* ClassID() const {return "MULT";}
2016-02-02 08:22:01 +00:00
};
struct VERealToVector : IVectorElement
{
DECL_YAML
RealElementFactory a;
2016-02-02 23:41:55 +00:00
const char* ClassID() const {return "RTOV";}
2016-02-02 08:22:01 +00:00
};
struct VEPulse : IVectorElement
{
DECL_YAML
2016-03-02 22:37:10 +00:00
IntElementFactory aDuration;
IntElementFactory bDuration;
VectorElementFactory a;
VectorElementFactory b;
2016-02-02 23:41:55 +00:00
const char* ClassID() const {return "PULS";}
2016-02-02 08:22:01 +00:00
};
2016-02-04 00:55:39 +00:00
struct VEParticleVelocity : IVectorElement
{
DECL_YAML
const char* ClassID() const {return "PVEL";}
};
struct VESPOS : IVectorElement
{
DECL_YAML
VectorElementFactory a;
const char* ClassID() const {return "SPOS";}
};
struct VEPLCO : IVectorElement
{
DECL_YAML
const char* ClassID() const {return "PLCO";}
};
struct VEPLOC : IVectorElement
{
DECL_YAML
const char* ClassID() const {return "PLOC";}
};
struct VEPSOR : IVectorElement
{
DECL_YAML
const char* ClassID() const {return "PSOR";}
};
struct VEPSOF : IVectorElement
{
DECL_YAML
const char* ClassID() const {return "PSOF";}
};
2016-02-02 08:22:01 +00:00
struct CEKeyframeEmitter : IColorElement
{
DECL_YAML
2016-03-02 22:37:10 +00:00
Value<atUint32> percentageTween;
Value<atUint32> unk1;
Value<bool> loop;
Value<atUint8> unk2;
Value<atUint32> loopEnd;
Value<atUint32> loopStart;
2016-02-02 08:22:01 +00:00
Value<atUint32> count;
Vector<atVec4f, DNA_COUNT(count)> keys;
2016-03-02 22:37:10 +00:00
const char* ClassID() const {return percentageTween ? "KEYP" : "KEYE";}
2016-02-02 08:22:01 +00:00
};
struct CEConstant : IColorElement
{
2016-02-04 00:55:39 +00:00
Delete _d;
RealElementFactory comps[4];
2016-03-04 23:04:53 +00:00
void read(athena::io::YAMLDocReader& r)
2016-02-04 00:55:39 +00:00
{
for (int i=0 ; i<4 ; ++i)
{
r.enterSubRecord(nullptr);
comps[i].read(r);
r.leaveSubRecord();
}
}
2016-03-04 23:04:53 +00:00
void write(athena::io::YAMLDocWriter& w) const
2016-02-04 00:55:39 +00:00
{
w.enterSubVector(nullptr);
for (int i=0 ; i<4 ; ++i)
{
w.enterSubRecord(nullptr);
comps[i].write(w);
w.leaveSubRecord();
}
w.leaveSubVector();
}
size_t binarySize(size_t __isz) const
{
__isz = comps[0].binarySize(__isz);
__isz = comps[1].binarySize(__isz);
__isz = comps[2].binarySize(__isz);
return comps[3].binarySize(__isz);
}
2016-03-04 23:04:53 +00:00
void read(athena::io::IStreamReader& r)
2016-02-04 00:55:39 +00:00
{
comps[0].read(r);
comps[1].read(r);
comps[2].read(r);
comps[3].read(r);
}
2016-03-04 23:04:53 +00:00
void write(athena::io::IStreamWriter& w) const
2016-02-04 00:55:39 +00:00
{
comps[0].write(w);
comps[1].write(w);
comps[2].write(w);
comps[3].write(w);
}
2016-02-02 23:41:55 +00:00
const char* ClassID() const {return "CNST";}
2016-02-02 08:22:01 +00:00
};
struct CETimeChain : IColorElement
{
DECL_YAML
ColorElementFactory a;
ColorElementFactory b;
2016-03-02 22:37:10 +00:00
IntElementFactory thresholdFrame;
2016-02-02 23:41:55 +00:00
const char* ClassID() const {return "CHAN";}
2016-02-02 08:22:01 +00:00
};
struct CEFadeEnd : IColorElement
{
DECL_YAML
ColorElementFactory a;
ColorElementFactory b;
2016-03-02 22:37:10 +00:00
RealElementFactory startFrame;
RealElementFactory endFrame;
2016-02-02 23:41:55 +00:00
const char* ClassID() const {return "CFDE";}
2016-02-02 08:22:01 +00:00
};
struct CEFade : IColorElement
{
DECL_YAML
ColorElementFactory a;
ColorElementFactory b;
2016-03-02 22:37:10 +00:00
RealElementFactory endFrame;
2016-02-02 23:41:55 +00:00
const char* ClassID() const {return "FADE";}
2016-02-02 08:22:01 +00:00
};
struct CEPulse : IColorElement
{
DECL_YAML
2016-03-02 22:37:10 +00:00
IntElementFactory aDuration;
IntElementFactory bDuration;
ColorElementFactory a;
ColorElementFactory b;
2016-02-02 23:41:55 +00:00
const char* ClassID() const {return "PULS";}
2016-02-02 08:22:01 +00:00
};
struct MVEImplosion : IModVectorElement
{
DECL_YAML
2016-03-02 22:37:10 +00:00
VectorElementFactory implodePoint;
RealElementFactory velocityScale;
RealElementFactory maxRadius;
RealElementFactory minRadius;
BoolHelper enableMinRadius;
2016-02-02 23:41:55 +00:00
const char* ClassID() const {return "IMPL";}
2016-02-02 08:22:01 +00:00
};
struct MVEExponentialImplosion : IModVectorElement
{
DECL_YAML
2016-03-02 22:37:10 +00:00
VectorElementFactory implodePoint;
RealElementFactory velocityScale;
RealElementFactory maxRadius;
RealElementFactory minRadius;
BoolHelper enableMinRadius;
2016-02-02 23:41:55 +00:00
const char* ClassID() const {return "EMPL";}
2016-02-02 08:22:01 +00:00
};
struct MVETimeChain : IModVectorElement
{
DECL_YAML
ModVectorElementFactory a;
ModVectorElementFactory b;
2016-03-02 22:37:10 +00:00
IntElementFactory thresholdFrame;
2016-02-02 23:41:55 +00:00
const char* ClassID() const {return "CHAN";}
2016-02-02 08:22:01 +00:00
};
struct MVEBounce : IModVectorElement
{
DECL_YAML
2016-03-02 22:37:10 +00:00
VectorElementFactory planePoint;
VectorElementFactory planeNormal;
RealElementFactory friction;
RealElementFactory restitution;
BoolHelper dieOnPenetrate;
2016-02-02 23:41:55 +00:00
const char* ClassID() const {return "BNCE";}
2016-02-02 08:22:01 +00:00
};
struct MVEConstant : IModVectorElement
{
2016-02-04 00:55:39 +00:00
Delete _d;
RealElementFactory comps[3];
2016-03-04 23:04:53 +00:00
void read(athena::io::YAMLDocReader& r)
2016-02-04 00:55:39 +00:00
{
for (int i=0 ; i<3 ; ++i)
{
r.enterSubRecord(nullptr);
comps[i].read(r);
r.leaveSubRecord();
}
}
2016-03-04 23:04:53 +00:00
void write(athena::io::YAMLDocWriter& w) const
2016-02-04 00:55:39 +00:00
{
w.enterSubVector(nullptr);
for (int i=0 ; i<3 ; ++i)
{
w.enterSubRecord(nullptr);
comps[i].write(w);
w.leaveSubRecord();
}
w.leaveSubVector();
}
size_t binarySize(size_t __isz) const
{
__isz = comps[0].binarySize(__isz);
__isz = comps[1].binarySize(__isz);
return comps[2].binarySize(__isz);
}
2016-03-04 23:04:53 +00:00
void read(athena::io::IStreamReader& r)
2016-02-04 00:55:39 +00:00
{
comps[0].read(r);
comps[1].read(r);
comps[2].read(r);
}
2016-03-04 23:04:53 +00:00
void write(athena::io::IStreamWriter& w) const
2016-02-04 00:55:39 +00:00
{
comps[0].write(w);
comps[1].write(w);
comps[2].write(w);
}
2016-02-02 23:41:55 +00:00
const char* ClassID() const {return "CNST";}
2016-02-02 08:22:01 +00:00
};
struct MVEGravity : IModVectorElement
{
DECL_YAML
2016-03-02 22:37:10 +00:00
VectorElementFactory acceleration;
2016-02-02 23:41:55 +00:00
const char* ClassID() const {return "GRAV";}
2016-02-02 08:22:01 +00:00
};
struct MVEExplode : IModVectorElement
{
DECL_YAML
2016-03-02 22:37:10 +00:00
RealElementFactory impulseMagnitude;
RealElementFactory falloffFactor;
2016-02-02 23:41:55 +00:00
const char* ClassID() const {return "EXPL";}
2016-02-02 08:22:01 +00:00
};
struct MVESetPosition : IModVectorElement
{
DECL_YAML
2016-03-02 22:37:10 +00:00
VectorElementFactory position;
2016-02-02 23:41:55 +00:00
const char* ClassID() const {return "SPOS";}
2016-02-02 08:22:01 +00:00
};
struct MVELinearImplosion : IModVectorElement
{
DECL_YAML
2016-03-02 22:37:10 +00:00
VectorElementFactory implodePoint;
RealElementFactory velocityScale;
RealElementFactory maxRadius;
RealElementFactory minRadius;
BoolHelper enableMinRadius;
2016-02-02 23:41:55 +00:00
const char* ClassID() const {return "LMPL";}
2016-02-02 08:22:01 +00:00
};
struct MVEPulse : IModVectorElement
{
DECL_YAML
2016-03-02 22:37:10 +00:00
IntElementFactory aDuration;
IntElementFactory bDuration;
ModVectorElementFactory a;
ModVectorElementFactory b;
2016-02-02 23:41:55 +00:00
const char* ClassID() const {return "PULS";}
2016-02-02 08:22:01 +00:00
};
struct MVEWind : IModVectorElement
{
DECL_YAML
2016-03-02 22:37:10 +00:00
VectorElementFactory windVelocity;
RealElementFactory factor;
2016-02-02 23:41:55 +00:00
const char* ClassID() const {return "WIND";}
2016-02-02 08:22:01 +00:00
};
struct MVESwirl : IModVectorElement
{
DECL_YAML
2016-03-02 22:37:10 +00:00
VectorElementFactory helixPoint;
VectorElementFactory curveBinormal;
RealElementFactory targetRadius;
RealElementFactory tangentialVelocity;
2016-02-02 23:41:55 +00:00
const char* ClassID() const {return "SWRL";}
2016-02-02 08:22:01 +00:00
};
struct EESimpleEmitter : IEmitterElement
{
DECL_YAML
2016-03-02 22:37:10 +00:00
VectorElementFactory position;
VectorElementFactory velocity;
const char* ClassID() const {return "SEMR";}
};
struct VESphere : IEmitterElement
{
DECL_YAML
2016-03-02 22:37:10 +00:00
VectorElementFactory sphereOrigin;
RealElementFactory sphereRadius;
RealElementFactory magnitude;
const char* ClassID() const {return "SPHE";}
};
struct VEAngleSphere : IEmitterElement
2016-02-04 00:55:39 +00:00
{
DECL_YAML
2016-03-02 22:37:10 +00:00
VectorElementFactory sphereOrigin;
RealElementFactory sphereRadius;
RealElementFactory magnitude;
RealElementFactory angleXBias;
RealElementFactory angleYBias;
RealElementFactory angleXRange;
RealElementFactory angleYRange;
2016-02-04 00:55:39 +00:00
const char* ClassID() const {return "ASPH";}
};
struct EESimpleEmitterTR : EESimpleEmitter
{
Delete _d;
2016-03-04 23:04:53 +00:00
void read(athena::io::YAMLDocReader& r)
{
2016-03-02 22:37:10 +00:00
position.m_elem.reset();
velocity.m_elem.reset();
if (r.enterSubRecord("ILOC"))
{
2016-03-02 22:37:10 +00:00
position.read(r);
r.leaveSubRecord();
}
if (r.enterSubRecord("IVEC"))
{
2016-03-02 22:37:10 +00:00
velocity.read(r);
r.leaveSubRecord();
}
}
2016-03-04 23:04:53 +00:00
void write(athena::io::YAMLDocWriter& w) const
{
w.enterSubRecord("ILOC");
2016-03-02 22:37:10 +00:00
position.write(w);
w.leaveSubRecord();
w.enterSubRecord("IVEC");
2016-03-02 22:37:10 +00:00
velocity.write(w);
w.leaveSubRecord();
}
size_t binarySize(size_t __isz) const
{
__isz += 8;
2016-03-02 22:37:10 +00:00
__isz = position.binarySize(__isz);
__isz = velocity.binarySize(__isz);
return __isz;
}
2016-03-04 23:04:53 +00:00
void read(athena::io::IStreamReader& r)
{
2016-03-02 22:37:10 +00:00
position.m_elem.reset();
velocity.m_elem.reset();
uint32_t clsId;
r.readBytesToBuf(&clsId, 4);
if (clsId == SBIG('ILOC'))
{
2016-03-02 22:37:10 +00:00
position.read(r);
r.readBytesToBuf(&clsId, 4);
if (clsId == SBIG('IVEC'))
2016-03-02 22:37:10 +00:00
velocity.read(r);
}
}
2016-03-04 23:04:53 +00:00
void write(athena::io::IStreamWriter& w) const
{
w.writeBytes((atInt8*)"ILOC", 4);
2016-03-02 22:37:10 +00:00
position.write(w);
w.writeBytes((atInt8*)"IVEC", 4);
2016-03-02 22:37:10 +00:00
velocity.write(w);
}
const char* ClassID() const {return "SETR";}
};
2016-02-02 08:22:01 +00:00
template <class IDType>
struct UVEConstant : IUVElement
{
Delete _d;
IDType tex;
2016-03-04 23:04:53 +00:00
void read(athena::io::YAMLDocReader& r)
2016-02-02 08:22:01 +00:00
{
tex.clear();
if (r.enterSubRecord("tex"))
{
2016-03-02 22:37:10 +00:00
tex.read(r);
2016-02-02 08:22:01 +00:00
r.leaveSubRecord();
}
}
2016-03-04 23:04:53 +00:00
void write(athena::io::YAMLDocWriter& w) const
2016-02-02 08:22:01 +00:00
{
2016-03-02 22:37:10 +00:00
w.enterSubRecord("tex");
tex.write(w);
w.leaveSubRecord();
2016-02-02 08:22:01 +00:00
}
size_t binarySize(size_t __isz) const
{
2016-03-02 22:37:10 +00:00
return tex.binarySize(__isz + 4);
2016-02-02 08:22:01 +00:00
}
2016-03-04 23:04:53 +00:00
void read(athena::io::IStreamReader& r)
2016-02-02 08:22:01 +00:00
{
tex.clear();
uint32_t clsId;
r.readBytesToBuf(&clsId, 4);
if (clsId == SBIG('CNST'))
tex.read(r);
}
2016-03-04 23:04:53 +00:00
void write(athena::io::IStreamWriter& w) const
2016-02-02 08:22:01 +00:00
{
2016-03-02 22:37:10 +00:00
w.writeBytes((atInt8*)"CNST", 4);
tex.write(w);
2016-02-02 08:22:01 +00:00
}
const char* ClassID() const {return "CNST";}
2016-10-02 22:41:36 +00:00
void gatherDependencies(std::vector<hecl::ProjectPath>& pathsOut) const
{
g_curSpec->flattenDependencies(tex, pathsOut);
}
2016-02-02 08:22:01 +00:00
};
template <class IDType>
struct UVEAnimTexture : IUVElement
{
Delete _d;
IDType tex;
2016-03-02 22:37:10 +00:00
IntElementFactory tileW;
IntElementFactory tileH;
IntElementFactory strideW;
IntElementFactory strideH;
IntElementFactory cycleFrames;
Value<bool> loop = false;
2016-03-04 23:04:53 +00:00
void read(athena::io::YAMLDocReader& r)
2016-02-02 08:22:01 +00:00
{
tex.clear();
if (r.enterSubRecord("tex"))
{
2016-03-02 22:37:10 +00:00
tex.read(r);
2016-02-02 08:22:01 +00:00
r.leaveSubRecord();
}
2016-03-02 22:37:10 +00:00
if (r.enterSubRecord("tileW"))
2016-02-02 08:22:01 +00:00
{
2016-03-02 22:37:10 +00:00
tileW.read(r);
2016-02-02 08:22:01 +00:00
r.leaveSubRecord();
}
2016-03-02 22:37:10 +00:00
if (r.enterSubRecord("tileH"))
2016-02-02 08:22:01 +00:00
{
2016-03-02 22:37:10 +00:00
tileH.read(r);
2016-02-02 08:22:01 +00:00
r.leaveSubRecord();
}
2016-03-02 22:37:10 +00:00
if (r.enterSubRecord("strideW"))
2016-02-02 08:22:01 +00:00
{
2016-03-02 22:37:10 +00:00
strideW.read(r);
2016-02-02 08:22:01 +00:00
r.leaveSubRecord();
}
2016-03-02 22:37:10 +00:00
if (r.enterSubRecord("strideH"))
2016-02-02 08:22:01 +00:00
{
2016-03-02 22:37:10 +00:00
strideH.read(r);
2016-02-02 08:22:01 +00:00
r.leaveSubRecord();
}
2016-03-02 22:37:10 +00:00
if (r.enterSubRecord("cycleFrames"))
2016-02-02 08:22:01 +00:00
{
2016-03-02 22:37:10 +00:00
cycleFrames.read(r);
2016-02-02 08:22:01 +00:00
r.leaveSubRecord();
}
2016-03-02 22:37:10 +00:00
if (r.enterSubRecord("loop"))
2016-02-02 08:22:01 +00:00
{
2016-03-02 22:37:10 +00:00
loop = r.readBool(nullptr);
2016-02-02 08:22:01 +00:00
r.leaveSubRecord();
}
}
2016-03-04 23:04:53 +00:00
void write(athena::io::YAMLDocWriter& w) const
2016-02-02 08:22:01 +00:00
{
2016-03-02 22:37:10 +00:00
w.enterSubRecord("tex");
tex.write(w);
w.leaveSubRecord();
w.enterSubRecord("tileW");
tileW.write(w);
w.leaveSubRecord();
w.enterSubRecord("tileH");
tileH.write(w);
w.leaveSubRecord();
w.enterSubRecord("strideW");
strideW.write(w);
w.leaveSubRecord();
w.enterSubRecord("strideH");
strideH.write(w);
2016-02-02 08:22:01 +00:00
w.leaveSubRecord();
2016-03-02 22:37:10 +00:00
w.enterSubRecord("cycleFrames");
cycleFrames.write(w);
w.leaveSubRecord();
w.writeBool("loop", loop);
2016-02-02 08:22:01 +00:00
}
size_t binarySize(size_t __isz) const
{
2016-03-02 22:37:10 +00:00
__isz += 9;
__isz = tex.binarySize(__isz);
__isz = tileW.binarySize(__isz);
__isz = tileH.binarySize(__isz);
__isz = strideW.binarySize(__isz);
__isz = strideH.binarySize(__isz);
__isz = cycleFrames.binarySize(__isz);
2016-02-02 08:22:01 +00:00
return __isz;
}
2016-03-04 23:04:53 +00:00
void read(athena::io::IStreamReader& r)
2016-02-02 08:22:01 +00:00
{
tex.clear();
uint32_t clsId;
r.readBytesToBuf(&clsId, 4);
if (clsId == SBIG('CNST'))
tex.read(r);
2016-03-02 22:37:10 +00:00
tileW.read(r);
tileH.read(r);
strideW.read(r);
strideH.read(r);
cycleFrames.read(r);
2016-02-02 08:22:01 +00:00
r.readBytesToBuf(&clsId, 4);
if (clsId == SBIG('CNST'))
2016-03-02 22:37:10 +00:00
loop = r.readBool();
2016-02-02 08:22:01 +00:00
}
2016-03-04 23:04:53 +00:00
void write(athena::io::IStreamWriter& w) const
2016-02-02 08:22:01 +00:00
{
2016-03-02 22:37:10 +00:00
w.writeBytes((atInt8*)"CNST", 4);
tex.write(w);
tileW.write(w);
tileH.write(w);
strideW.write(w);
strideH.write(w);
cycleFrames.write(w);
w.writeBytes((atInt8*)"CNST", 4);
w.writeBool(loop);
2016-02-02 08:22:01 +00:00
}
const char* ClassID() const {return "ATEX";}
2016-10-02 22:41:36 +00:00
void gatherDependencies(std::vector<hecl::ProjectPath>& pathsOut) const
{
g_curSpec->flattenDependencies(tex, pathsOut);
}
2016-02-02 08:22:01 +00:00
};
template <class IDType>
struct UVElementFactory : BigYAML
{
Delete _d;
std::unique_ptr<IUVElement> m_elem;
2016-02-04 00:55:39 +00:00
operator bool() const {return m_elem.operator bool();}
2016-02-02 08:22:01 +00:00
2016-03-04 23:04:53 +00:00
void read(athena::io::YAMLDocReader& r)
2016-02-02 08:22:01 +00:00
{
if (r.enterSubRecord("CNST"))
{
m_elem.reset(new struct UVEConstant<IDType>);
m_elem->read(r);
r.leaveSubRecord();
}
else if (r.enterSubRecord("ATEX"))
{
m_elem.reset(new struct UVEAnimTexture<IDType>);
m_elem->read(r);
r.leaveSubRecord();
}
else
m_elem.reset();
}
2016-03-04 23:04:53 +00:00
void write(athena::io::YAMLDocWriter& w) const
2016-02-02 08:22:01 +00:00
{
if (m_elem)
{
2016-02-02 23:41:55 +00:00
w.enterSubRecord(m_elem->ClassID());
2016-02-02 08:22:01 +00:00
m_elem->write(w);
w.leaveSubRecord();
}
}
size_t binarySize(size_t __isz) const
{
if (m_elem)
return m_elem->binarySize(__isz + 4);
else
return __isz + 4;
}
2016-03-04 23:04:53 +00:00
void read(athena::io::IStreamReader& r)
2016-02-02 08:22:01 +00:00
{
uint32_t clsId;
r.readBytesToBuf(&clsId, 4);
switch (clsId)
{
case SBIG('CNST'):
m_elem.reset(new struct UVEConstant<IDType>);
break;
case SBIG('ATEX'):
m_elem.reset(new struct UVEAnimTexture<IDType>);
break;
default:
m_elem.reset();
return;
}
m_elem->read(r);
}
2016-03-04 23:04:53 +00:00
void write(athena::io::IStreamWriter& w) const
2016-02-02 08:22:01 +00:00
{
if (m_elem)
{
2016-02-02 23:41:55 +00:00
w.writeBytes((atInt8*)m_elem->ClassID(), 4);
2016-02-02 08:22:01 +00:00
m_elem->write(w);
}
else
w.writeBytes((atInt8*)"NONE", 4);
}
};
2016-02-02 04:29:58 +00:00
template <class IDType>
struct SpawnSystemKeyframeData : BigYAML
{
Delete _d;
Value<atUint32> a;
Value<atUint32> b;
2016-03-02 22:37:10 +00:00
Value<atUint32> endFrame;
Value<atUint32> d;
struct SpawnSystemKeyframeInfo : BigYAML
{
Delete _d;
IDType id;
Value<atUint32> a;
Value<atUint32> b;
Value<atUint32> c;
2016-03-04 23:04:53 +00:00
void read(athena::io::YAMLDocReader& r)
{
if (r.enterSubRecord("id"))
{
id.read(r);
r.leaveSubRecord();
}
if (r.enterSubRecord("a"))
{
a = r.readUint32(nullptr);
r.leaveSubRecord();
}
if (r.enterSubRecord("b"))
{
b = r.readUint32(nullptr);
r.leaveSubRecord();
}
if (r.enterSubRecord("c"))
{
c = r.readUint32(nullptr);
r.leaveSubRecord();
}
}
2016-03-04 23:04:53 +00:00
void write(athena::io::YAMLDocWriter& w) const
{
w.enterSubRecord("id");
id.write(w);
w.leaveSubRecord();
w.writeUint32("a", a);
w.writeUint32("b", b);
w.writeUint32("c", c);
}
size_t binarySize(size_t __isz) const
{
return id.binarySize(__isz + 12);
}
2016-03-04 23:04:53 +00:00
void read(athena::io::IStreamReader& r)
{
id.read(r);
a = r.readUint32Big();
b = r.readUint32Big();
c = r.readUint32Big();
}
2016-03-04 23:04:53 +00:00
void write(athena::io::IStreamWriter& w) const
{
id.write(w);
w.writeUint32Big(a);
w.writeUint32Big(b);
w.writeUint32Big(c);
}
};
std::vector<std::pair<atUint32, std::vector<SpawnSystemKeyframeInfo>>> spawns;
2016-03-04 23:04:53 +00:00
void read(athena::io::YAMLDocReader& r)
{
if (r.enterSubRecord("a"))
{
a = r.readUint32(nullptr);
r.leaveSubRecord();
}
if (r.enterSubRecord("b"))
{
b = r.readUint32(nullptr);
r.leaveSubRecord();
}
2016-03-02 22:37:10 +00:00
if (r.enterSubRecord("endFrame"))
{
2016-03-02 22:37:10 +00:00
endFrame = r.readUint32(nullptr);
r.leaveSubRecord();
}
if (r.enterSubRecord("d"))
{
d = r.readUint32(nullptr);
r.leaveSubRecord();
}
spawns.clear();
2016-03-04 23:04:53 +00:00
size_t spawnCount;
if (r.enterSubVector("spawns", spawnCount))
{
2016-03-04 23:04:53 +00:00
spawns.reserve(spawnCount);
for (const auto& child : r.getCurNode()->m_seqChildren)
{
if (r.enterSubRecord(nullptr))
{
spawns.emplace_back();
2016-03-02 22:37:10 +00:00
spawns.back().first = r.readUint32("startFrame");
2016-03-04 23:04:53 +00:00
size_t systemCount;
if (r.enterSubVector("systems", systemCount))
{
2016-03-04 23:04:53 +00:00
spawns.back().second.reserve(systemCount);
for (const auto& in : r.getCurNode()->m_seqChildren)
{
spawns.back().second.emplace_back();
SpawnSystemKeyframeInfo& info = spawns.back().second.back();
r.enterSubRecord(nullptr);
info.read(r);
r.leaveSubRecord();
}
r.leaveSubVector();
}
r.leaveSubRecord();
}
}
r.leaveSubVector();
}
}
2016-03-04 23:04:53 +00:00
void write(athena::io::YAMLDocWriter& w) const
{
2016-02-04 00:55:39 +00:00
if (spawns.empty())
return;
w.writeUint32("a", a);
w.writeUint32("b", b);
2016-03-02 22:37:10 +00:00
w.writeUint32("endFrame", endFrame);
w.writeUint32("d", d);
w.enterSubVector("spawns");
for (const auto& spawn : spawns)
{
2016-02-04 00:55:39 +00:00
w.enterSubRecord(nullptr);
2016-03-02 22:37:10 +00:00
w.writeUint32("startFrame", spawn.first);
w.enterSubVector("systems");
for (const auto& info : spawn.second)
{
w.enterSubRecord(nullptr);
info.write(w);
w.leaveSubRecord();
}
w.leaveSubVector();
2016-02-04 00:55:39 +00:00
w.leaveSubRecord();
}
w.leaveSubVector();
}
size_t binarySize(size_t __isz) const
{
__isz += 20;
for (const auto& spawn : spawns)
{
__isz += 8;
for (const auto& info : spawn.second)
__isz = info.binarySize(__isz);
}
return __isz;
}
2016-03-04 23:04:53 +00:00
void read(athena::io::IStreamReader& r)
{
2016-02-04 00:55:39 +00:00
uint32_t clsId;
r.readBytesToBuf(&clsId, 4);
if (clsId != SBIG('CNST'))
return;
a = r.readUint32Big();
b = r.readUint32Big();
2016-03-02 22:37:10 +00:00
endFrame = r.readUint32Big();
d = r.readUint32Big();
uint32_t count = r.readUint32Big();
spawns.clear();
spawns.reserve(count);
for (size_t i=0 ; i<count ; ++i)
{
spawns.emplace_back();
spawns.back().first = r.readUint32Big();
uint32_t infoCount = r.readUint32Big();
spawns.back().second.reserve(infoCount);
for (size_t j=0 ; j<infoCount ; ++j)
{
spawns.back().second.emplace_back();
spawns.back().second.back().read(r);
}
}
}
2016-03-04 23:04:53 +00:00
void write(athena::io::IStreamWriter& w) const
{
2016-02-04 00:55:39 +00:00
if (spawns.empty())
{
w.writeBytes((atInt8*)"NONE", 4);
return;
}
w.writeBytes((atInt8*)"CNST", 4);
w.writeUint32Big(a);
w.writeUint32Big(b);
2016-03-02 22:37:10 +00:00
w.writeUint32Big(endFrame);
w.writeUint32Big(d);
w.writeUint32Big(spawns.size());
for (const auto& spawn : spawns)
{
w.writeUint32Big(spawn.first);
w.writeUint32Big(spawn.second.size());
for (const auto& info : spawn.second)
info.write(w);
}
}
2016-02-04 00:55:39 +00:00
operator bool() const {return spawns.size() != 0;}
2016-10-02 22:41:36 +00:00
void gatherDependencies(std::vector<hecl::ProjectPath>& pathsOut) const
{
for (const auto& p : spawns)
for (const SpawnSystemKeyframeInfo& info : p.second)
g_curSpec->flattenDependencies(info.id, pathsOut);
}
};
template <class IDType>
struct ChildResourceFactory : BigYAML
2016-02-02 04:29:58 +00:00
{
Delete _d;
IDType id;
2016-03-04 23:04:53 +00:00
void read(athena::io::YAMLDocReader& r)
2016-02-02 04:29:58 +00:00
{
id.clear();
if (r.enterSubRecord("CNST"))
{
id.read(r);
r.leaveSubRecord();
}
}
2016-03-04 23:04:53 +00:00
void write(athena::io::YAMLDocWriter& w) const
2016-02-02 04:29:58 +00:00
{
if (id)
{
w.enterSubRecord("CNST");
id.write(w);
w.leaveSubRecord();
}
}
size_t binarySize(size_t __isz) const
{
if (id)
return id.binarySize(__isz + 4);
2016-02-02 04:29:58 +00:00
else
return __isz + 4;
}
2016-03-04 23:04:53 +00:00
void read(athena::io::IStreamReader& r)
2016-02-02 04:29:58 +00:00
{
id.clear();
2016-02-02 08:22:01 +00:00
uint32_t clsId;
r.readBytesToBuf(&clsId, 4);
if (clsId == SBIG('CNST'))
2016-02-02 04:29:58 +00:00
id.read(r);
}
2016-03-04 23:04:53 +00:00
void write(athena::io::IStreamWriter& w) const
2016-02-02 04:29:58 +00:00
{
if (id)
{
2016-02-02 08:22:01 +00:00
w.writeBytes((atInt8*)"CNST", 4);
2016-02-02 04:29:58 +00:00
id.write(w);
}
else
2016-02-02 08:22:01 +00:00
w.writeBytes((atInt8*)"NONE", 4);
2016-02-02 04:29:58 +00:00
}
2016-02-04 00:55:39 +00:00
operator bool() const {return id.operator bool();}
2016-02-02 04:29:58 +00:00
};
}
}
#endif // __COMMON_PARTICLECOMMON_HPP__