metaforce/DataSpec/DNAMP1/EVNT.cpp

100 lines
2.1 KiB
C++
Raw Normal View History

2015-08-15 04:12:15 +00:00
#include "EVNT.hpp"
2016-02-13 09:02:47 +00:00
namespace DataSpec
2015-08-15 04:12:15 +00:00
{
namespace DNAMP1
{
2016-03-04 23:04:53 +00:00
void EVNT::read(athena::io::IStreamReader& reader)
2015-08-15 04:12:15 +00:00
{
version = reader.readUint32Big();
atUint32 loopCount = reader.readUint32Big();
reader.enumerate(loopEvents, loopCount);
uevtEvents.clear();
2016-01-19 05:32:34 +00:00
atUint32 uevtCount = reader.readUint32Big();
reader.enumerate(uevtEvents, uevtCount);
2015-08-15 04:12:15 +00:00
atUint32 effectCount = reader.readUint32Big();
reader.enumerate(effectEvents, effectCount);
2016-01-19 05:32:34 +00:00
if (version == 2)
{
atUint32 sfxCount = reader.readUint32Big();
reader.enumerate(sfxEvents, sfxCount);
}
2015-08-15 04:12:15 +00:00
}
2016-03-04 23:04:53 +00:00
void EVNT::write(athena::io::IStreamWriter& writer) const
2015-08-15 04:12:15 +00:00
{
writer.writeUint32Big(version);
writer.writeUint32Big(loopEvents.size());
writer.enumerate(loopEvents);
2016-01-19 05:32:34 +00:00
writer.writeUint32Big(uevtEvents.size());
writer.enumerate(uevtEvents);
2015-08-15 04:12:15 +00:00
writer.writeUint32Big(effectEvents.size());
writer.enumerate(effectEvents);
2016-01-19 05:32:34 +00:00
if (version == 2)
{
writer.writeUint32Big(sfxEvents.size());
writer.enumerate(sfxEvents);
}
2015-08-15 04:12:15 +00:00
}
2016-03-04 23:04:53 +00:00
void EVNT::read(athena::io::YAMLDocReader& reader)
2015-08-15 04:12:15 +00:00
{
version = reader.readUint32("version");
2016-03-04 23:04:53 +00:00
reader.enumerate("loopEvents", loopEvents);
2015-08-15 04:12:15 +00:00
uevtEvents.clear();
2016-03-04 23:04:53 +00:00
reader.enumerate("uevtEvents", uevtEvents);
2015-08-15 04:12:15 +00:00
2016-03-04 23:04:53 +00:00
reader.enumerate("effectEvents", effectEvents);
2015-08-15 04:12:15 +00:00
2016-01-19 05:32:34 +00:00
if (version == 2)
{
2016-03-04 23:04:53 +00:00
reader.enumerate("sfxEvents", sfxEvents);
2016-01-19 05:32:34 +00:00
}
2015-08-15 04:12:15 +00:00
}
2016-03-04 23:04:53 +00:00
void EVNT::write(athena::io::YAMLDocWriter& writer) const
2015-08-15 04:12:15 +00:00
{
writer.writeUint32("version", version);
writer.enumerate("loopEvents", loopEvents);
2016-01-19 05:32:34 +00:00
writer.enumerate("uevtEvents", uevtEvents);
writer.enumerate("effectEvents", effectEvents);
2015-08-15 04:12:15 +00:00
if (version == 2)
{
2016-01-19 05:32:34 +00:00
writer.enumerate("sfxEvents", sfxEvents);
2015-08-15 04:12:15 +00:00
}
2016-01-19 05:32:34 +00:00
}
2015-08-15 04:12:15 +00:00
2016-01-19 05:32:34 +00:00
const char* EVNT::DNAType()
{
2016-03-04 23:04:53 +00:00
return "urde::DNAMP1::EVNT";
2016-01-19 05:32:34 +00:00
}
size_t EVNT::binarySize(size_t __isz) const
{
__isz = __EnumerateSize(__isz, loopEvents);
__isz = __EnumerateSize(__isz, uevtEvents);
__isz = __EnumerateSize(__isz, effectEvents);
if (version == 2)
__isz = __EnumerateSize(__isz, sfxEvents);
2015-08-15 04:12:15 +00:00
2016-01-19 05:32:34 +00:00
return __isz + (version == 2 ? 20 : 16);
2015-08-15 04:12:15 +00:00
}
}
}