metaforce/DataSpec/DNAMP3/CHAR.cpp

179 lines
4.7 KiB
C++
Raw Normal View History

2015-09-26 03:12:08 +00:00
#include "CHAR.hpp"
namespace Retro
{
namespace DNAMP3
{
void CHAR::AnimationInfo::EVNT::SFXEvent::read(Athena::io::IStreamReader& reader)
{
EventBase::read(reader);
caudId.read(reader);
unk1 = reader.readUint32Big();
unk2 = reader.readUint32Big();
unk3 = reader.readUint32Big();
2015-09-27 03:48:53 +00:00
reader.enumerateBig(unk3Vals, unk3);
2015-09-26 03:12:08 +00:00
extraType = reader.readUint32Big();
if (extraType == 1)
extraFloat = reader.readFloatBig();
else if (extraType == 2)
reader.seek(35, Athena::Current);
}
void CHAR::AnimationInfo::EVNT::SFXEvent::write(Athena::io::IStreamWriter& writer) const
{
EventBase::write(writer);
caudId.write(writer);
writer.writeUint32Big(unk1);
writer.writeUint32Big(unk2);
writer.writeUint32Big(unk3);
2015-09-27 03:48:53 +00:00
writer.enumerateBig(unk3Vals);
2015-09-26 03:12:08 +00:00
writer.writeUint32Big(extraType);
if (extraType == 1)
writer.writeFloatBig(extraFloat);
else if (extraType == 2)
writer.seek(35, Athena::Current);
}
size_t CHAR::AnimationInfo::EVNT::SFXEvent::binarySize(size_t __isz) const
{
__isz = EventBase::binarySize(__isz);
__isz = caudId.binarySize(__isz);
__isz += 16;
__isz += unk3Vals.size() * 4;
if (extraType == 1)
__isz += 4;
else if (extraType == 2)
__isz += 35;
return __isz;
}
2016-01-04 05:31:02 +00:00
void CHAR::AnimationInfo::EVNT::SFXEvent::read(Athena::io::YAMLDocReader& reader)
2015-09-26 03:12:08 +00:00
{
2016-01-04 05:31:02 +00:00
EventBase::read(reader);
2015-09-26 03:12:08 +00:00
reader.enumerate("caudId", caudId);
unk1 = reader.readUint32("unk1");
unk2 = reader.readUint32("unk2");
unk3 = reader.readUint32("unk3");
2015-09-27 03:48:53 +00:00
reader.enumerate("unk3Vals", unk3Vals, unk3);
2015-09-26 03:12:08 +00:00
extraType = reader.readUint32("extraType");
if (extraType == 1)
extraFloat = reader.readFloat("extraFloat");
}
2016-01-04 05:31:02 +00:00
void CHAR::AnimationInfo::EVNT::SFXEvent::write(Athena::io::YAMLDocWriter& writer) const
2015-09-26 03:12:08 +00:00
{
2016-01-04 05:31:02 +00:00
EventBase::write(writer);
2015-09-26 03:12:08 +00:00
writer.enumerate("caudId", caudId);
writer.writeUint32("unk1", unk1);
writer.writeUint32("unk2", unk2);
writer.writeUint32("unk3", unk3);
2015-09-27 03:48:53 +00:00
writer.enumerate("unk3Vals", unk3Vals);
2015-09-26 03:12:08 +00:00
writer.writeUint32("extraType", extraType);
if (extraType == 1)
writer.writeFloat("extraFloat", extraFloat);
}
2015-10-01 00:40:21 +00:00
const char* CHAR::AnimationInfo::EVNT::SFXEvent::DNAType()
{
return "Retro::DNAMP3::CHAR::AnimationInfo::EVNT::SFXEvent";
}
2015-09-26 03:12:08 +00:00
void CHAR::AnimationInfo::MetaAnimFactory::read(Athena::io::IStreamReader& reader)
{
IMetaAnim::Type type(IMetaAnim::Type(reader.readUint32Big()));
switch (type)
{
2015-11-21 01:16:07 +00:00
case IMetaAnim::Type::Primitive:
2015-09-26 03:12:08 +00:00
m_anim.reset(new struct MetaAnimPrimitive);
m_anim->read(reader);
break;
2015-11-21 01:16:07 +00:00
case IMetaAnim::Type::Blend:
2015-09-26 03:12:08 +00:00
m_anim.reset(new struct MetaAnimBlend);
m_anim->read(reader);
break;
2015-11-21 01:16:07 +00:00
case IMetaAnim::Type::PhaseBlend:
2015-09-26 03:12:08 +00:00
m_anim.reset(new struct MetaAnimPhaseBlend);
m_anim->read(reader);
break;
2015-11-21 01:16:07 +00:00
case IMetaAnim::Type::Random:
2015-09-26 03:12:08 +00:00
m_anim.reset(new struct MetaAnimRandom);
m_anim->read(reader);
break;
2015-11-21 01:16:07 +00:00
case IMetaAnim::Type::Sequence:
2015-09-26 03:12:08 +00:00
m_anim.reset(new struct MetaAnimSequence);
m_anim->read(reader);
break;
default:
m_anim.reset(nullptr);
break;
}
}
void CHAR::AnimationInfo::MetaAnimFactory::write(Athena::io::IStreamWriter& writer) const
{
if (!m_anim)
return;
2015-11-21 01:16:07 +00:00
writer.writeInt32Big(atInt32(m_anim->m_type));
2015-09-26 03:12:08 +00:00
m_anim->write(writer);
}
size_t CHAR::AnimationInfo::MetaAnimFactory::binarySize(size_t __isz) const
{
if (!m_anim)
return __isz;
return m_anim->binarySize(__isz + 4);
}
2016-01-04 05:31:02 +00:00
void CHAR::AnimationInfo::MetaAnimFactory::read(Athena::io::YAMLDocReader& reader)
2015-09-26 03:12:08 +00:00
{
std::string type = reader.readString("type");
std::transform(type.begin(), type.end(), type.begin(), tolower);
if (!type.compare("primitive"))
{
m_anim.reset(new struct MetaAnimPrimitive);
2016-01-04 05:31:02 +00:00
m_anim->read(reader);
2015-09-26 03:12:08 +00:00
}
else if (!type.compare("blend"))
{
m_anim.reset(new struct MetaAnimBlend);
2016-01-04 05:31:02 +00:00
m_anim->read(reader);
2015-09-26 03:12:08 +00:00
}
else if (!type.compare("phaseblend"))
{
m_anim.reset(new struct MetaAnimPhaseBlend);
2016-01-04 05:31:02 +00:00
m_anim->read(reader);
2015-09-26 03:12:08 +00:00
}
else if (!type.compare("random"))
{
m_anim.reset(new struct MetaAnimRandom);
2016-01-04 05:31:02 +00:00
m_anim->read(reader);
2015-09-26 03:12:08 +00:00
}
else if (!type.compare("sequence"))
{
m_anim.reset(new struct MetaAnimSequence);
2016-01-04 05:31:02 +00:00
m_anim->read(reader);
2015-09-26 03:12:08 +00:00
}
else
{
m_anim.reset(nullptr);
}
}
2016-01-04 05:31:02 +00:00
void CHAR::AnimationInfo::MetaAnimFactory::write(Athena::io::YAMLDocWriter& writer) const
2015-09-26 03:12:08 +00:00
{
if (!m_anim)
return;
writer.writeString("type", m_anim->m_typeStr);
2016-01-04 05:31:02 +00:00
m_anim->write(writer);
2015-09-26 03:12:08 +00:00
}
2015-10-01 00:40:21 +00:00
const char* CHAR::AnimationInfo::MetaAnimFactory::DNAType()
{
return "Retro::DNAMP3::CHAR::AnimationInfo::MetaAnimFactory";
}
2015-09-26 03:12:08 +00:00
}
}