metaforce/DataSpec/DNAMP3/CHAR.cpp

158 lines
4.6 KiB
C++
Raw Normal View History

2015-09-26 03:12:08 +00:00
#include "CHAR.hpp"
2018-12-08 05:30:43 +00:00
namespace DataSpec::DNAMP3 {
2015-09-26 03:12:08 +00:00
2018-02-22 07:24:51 +00:00
template <>
2018-12-08 05:30:43 +00:00
void CHAR::AnimationInfo::EVNT::SFXEvent::Enumerate<BigDNA::Read>(athena::io::IStreamReader& reader) {
EventBase::read(reader);
caudId.read(reader);
unk1 = reader.readUint32Big();
unk2 = reader.readUint32Big();
unk3 = reader.readUint32Big();
reader.enumerateBig(unk3Vals, unk3);
extraType = reader.readUint32Big();
if (extraType == 1)
extraFloat = reader.readFloatBig();
else if (extraType == 2)
reader.seek(35, athena::SeekOrigin::Current);
2015-09-26 03:12:08 +00:00
}
2018-02-22 07:24:51 +00:00
template <>
2018-12-08 05:30:43 +00:00
void CHAR::AnimationInfo::EVNT::SFXEvent::Enumerate<BigDNA::Write>(athena::io::IStreamWriter& writer) {
EventBase::write(writer);
caudId.write(writer);
writer.writeUint32Big(unk1);
writer.writeUint32Big(unk2);
writer.writeUint32Big(unk3);
writer.enumerateBig(unk3Vals);
writer.writeUint32Big(extraType);
if (extraType == 1)
writer.writeFloatBig(extraFloat);
else if (extraType == 2)
writer.seek(35, athena::SeekOrigin::Current);
2015-09-26 03:12:08 +00:00
}
2018-02-22 07:24:51 +00:00
template <>
2018-12-08 05:30:43 +00:00
void CHAR::AnimationInfo::EVNT::SFXEvent::Enumerate<BigDNA::BinarySize>(size_t& __isz) {
EventBase::binarySize(__isz);
caudId.binarySize(__isz);
__isz += 16;
__isz += unk3Vals.size() * 4;
if (extraType == 1)
__isz += 4;
else if (extraType == 2)
__isz += 35;
}
2018-02-22 07:24:51 +00:00
template <>
2018-12-08 05:30:43 +00:00
void CHAR::AnimationInfo::EVNT::SFXEvent::Enumerate<BigDNA::ReadYaml>(athena::io::YAMLDocReader& reader) {
EventBase::read(reader);
reader.enumerate("caudId", caudId);
unk1 = reader.readUint32("unk1");
unk2 = reader.readUint32("unk2");
unk3 = reader.enumerate("unk3Vals", unk3Vals);
extraType = reader.readUint32("extraType");
if (extraType == 1)
extraFloat = reader.readFloat("extraFloat");
2015-09-26 03:12:08 +00:00
}
2018-02-22 07:24:51 +00:00
template <>
2018-12-08 05:30:43 +00:00
void CHAR::AnimationInfo::EVNT::SFXEvent::Enumerate<BigDNA::WriteYaml>(athena::io::YAMLDocWriter& writer) {
EventBase::write(writer);
writer.enumerate("caudId", caudId);
writer.writeUint32("unk1", unk1);
writer.writeUint32("unk2", unk2);
writer.enumerate("unk3Vals", unk3Vals);
writer.writeUint32("extraType", extraType);
if (extraType == 1)
writer.writeFloat("extraFloat", extraFloat);
2015-09-26 03:12:08 +00:00
}
2019-10-01 07:38:03 +00:00
std::string_view CHAR::AnimationInfo::EVNT::SFXEvent::DNAType() {
2021-04-10 08:42:06 +00:00
return "DNAMP3::CHAR::AnimationInfo::EVNT::SFXEvent"sv;
2015-10-01 00:40:21 +00:00
}
2018-02-22 07:24:51 +00:00
template <>
2018-12-08 05:30:43 +00:00
void CHAR::AnimationInfo::MetaAnimFactory::Enumerate<BigDNA::Read>(athena::io::IStreamReader& reader) {
const auto type = IMetaAnim::Type(reader.readUint32Big());
2018-12-08 05:30:43 +00:00
switch (type) {
case IMetaAnim::Type::Primitive:
m_anim = std::make_unique<MetaAnimPrimitive>();
2018-12-08 05:30:43 +00:00
m_anim->read(reader);
break;
case IMetaAnim::Type::Blend:
m_anim = std::make_unique<MetaAnimBlend>();
2018-12-08 05:30:43 +00:00
m_anim->read(reader);
break;
case IMetaAnim::Type::PhaseBlend:
m_anim = std::make_unique<MetaAnimPhaseBlend>();
2018-12-08 05:30:43 +00:00
m_anim->read(reader);
break;
case IMetaAnim::Type::Random:
m_anim = std::make_unique<MetaAnimRandom>();
2018-12-08 05:30:43 +00:00
m_anim->read(reader);
break;
case IMetaAnim::Type::Sequence:
m_anim = std::make_unique<MetaAnimSequence>();
2018-12-08 05:30:43 +00:00
m_anim->read(reader);
break;
default:
m_anim.reset();
2018-12-08 05:30:43 +00:00
break;
}
2015-09-26 03:12:08 +00:00
}
2018-02-22 07:24:51 +00:00
template <>
2018-12-08 05:30:43 +00:00
void CHAR::AnimationInfo::MetaAnimFactory::Enumerate<BigDNA::Write>(athena::io::IStreamWriter& writer) {
if (!m_anim)
return;
writer.writeInt32Big(atInt32(m_anim->m_type));
m_anim->write(writer);
2015-09-26 03:12:08 +00:00
}
2018-02-22 07:24:51 +00:00
template <>
2018-12-08 05:30:43 +00:00
void CHAR::AnimationInfo::MetaAnimFactory::Enumerate<BigDNA::BinarySize>(size_t& __isz) {
if (!m_anim)
return;
__isz += 4;
m_anim->binarySize(__isz);
}
2018-02-22 07:24:51 +00:00
template <>
2018-12-08 05:30:43 +00:00
void CHAR::AnimationInfo::MetaAnimFactory::Enumerate<BigDNA::ReadYaml>(athena::io::YAMLDocReader& reader) {
std::string type = reader.readString("type");
std::transform(type.begin(), type.end(), type.begin(), tolower);
2019-10-01 07:38:03 +00:00
if (type == "primitive") {
m_anim = std::make_unique<MetaAnimPrimitive>();
2018-12-08 05:30:43 +00:00
m_anim->read(reader);
2019-10-01 07:38:03 +00:00
} else if (type == "blend") {
m_anim = std::make_unique<MetaAnimBlend>();
2018-12-08 05:30:43 +00:00
m_anim->read(reader);
2019-10-01 07:38:03 +00:00
} else if (type == "phaseblend") {
m_anim = std::make_unique<MetaAnimPhaseBlend>();
2018-12-08 05:30:43 +00:00
m_anim->read(reader);
2019-10-01 07:38:03 +00:00
} else if (type == "random") {
m_anim = std::make_unique<MetaAnimRandom>();
2018-12-08 05:30:43 +00:00
m_anim->read(reader);
2019-10-01 07:38:03 +00:00
} else if (type == "sequence") {
m_anim = std::make_unique<MetaAnimSequence>();
2018-12-08 05:30:43 +00:00
m_anim->read(reader);
} else {
m_anim.reset();
2018-12-08 05:30:43 +00:00
}
2015-09-26 03:12:08 +00:00
}
2018-02-22 07:24:51 +00:00
template <>
2018-12-08 05:30:43 +00:00
void CHAR::AnimationInfo::MetaAnimFactory::Enumerate<BigDNA::WriteYaml>(athena::io::YAMLDocWriter& writer) {
if (!m_anim)
return;
writer.writeString("type", m_anim->m_typeStr);
m_anim->write(writer);
2015-09-26 03:12:08 +00:00
}
2019-10-01 07:38:03 +00:00
std::string_view CHAR::AnimationInfo::MetaAnimFactory::DNAType() {
2021-04-10 08:42:06 +00:00
return "DNAMP3::CHAR::AnimationInfo::MetaAnimFactory"sv;
2015-10-01 00:40:21 +00:00
}
2018-12-08 05:30:43 +00:00
} // namespace DataSpec::DNAMP3