2020-01-15 12:07:48 +00:00
|
|
|
#include "Runtime/Character/CCharacterInfo.hpp"
|
2022-02-18 07:37:54 +00:00
|
|
|
#include "Runtime/IOStreams.hpp"
|
2016-04-10 04:49:02 +00:00
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
namespace metaforce {
|
2016-04-10 04:49:02 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
CCharacterInfo::CParticleResData::CParticleResData(CInputStream& in, u16 tableCount) {
|
2022-02-18 07:37:54 +00:00
|
|
|
const u32 partCount = in.ReadLong();
|
2018-12-08 05:30:43 +00:00
|
|
|
x0_part.reserve(partCount);
|
2020-02-28 09:51:16 +00:00
|
|
|
for (u32 i = 0; i < partCount; ++i) {
|
2022-02-18 07:37:54 +00:00
|
|
|
x0_part.emplace_back(in.Get<CAssetId>());
|
2020-02-28 09:51:16 +00:00
|
|
|
}
|
2016-04-10 21:22:59 +00:00
|
|
|
|
2022-02-18 07:37:54 +00:00
|
|
|
const u32 swhcCount = in.ReadLong();
|
2018-12-08 05:30:43 +00:00
|
|
|
x10_swhc.reserve(swhcCount);
|
2020-02-28 09:51:16 +00:00
|
|
|
for (u32 i = 0; i < swhcCount; ++i) {
|
2022-02-18 07:37:54 +00:00
|
|
|
x10_swhc.emplace_back(in.Get<CAssetId>());
|
2020-02-28 09:51:16 +00:00
|
|
|
}
|
2016-04-10 21:22:59 +00:00
|
|
|
|
2022-02-18 07:37:54 +00:00
|
|
|
const u32 unkCount = in.ReadLong();
|
2018-12-08 05:30:43 +00:00
|
|
|
x20_elsc.reserve(unkCount);
|
2020-02-28 09:51:16 +00:00
|
|
|
for (u32 i = 0; i < unkCount; ++i) {
|
2022-02-18 07:37:54 +00:00
|
|
|
x20_elsc.emplace_back(in.Get<CAssetId>());
|
2020-02-28 09:51:16 +00:00
|
|
|
}
|
2016-04-10 21:22:59 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
if (tableCount > 5) {
|
2022-02-18 07:37:54 +00:00
|
|
|
const u32 elscCount = in.ReadLong();
|
2018-12-08 05:30:43 +00:00
|
|
|
x30_elsc.reserve(elscCount);
|
2020-02-28 09:51:16 +00:00
|
|
|
for (u32 i = 0; i < elscCount; ++i) {
|
2022-02-18 07:37:54 +00:00
|
|
|
x30_elsc.emplace_back(in.Get<CAssetId>());
|
2020-02-28 09:51:16 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
2016-04-10 21:22:59 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
static std::vector<std::pair<s32, std::pair<std::string, std::string>>> MakeAnimInfoVector(CInputStream& in) {
|
|
|
|
std::vector<std::pair<s32, std::pair<std::string, std::string>>> ret;
|
2022-02-18 07:37:54 +00:00
|
|
|
const u32 animInfoCount = in.ReadLong();
|
2018-12-08 05:30:43 +00:00
|
|
|
ret.reserve(animInfoCount);
|
|
|
|
for (u32 i = 0; i < animInfoCount; ++i) {
|
2022-02-18 07:37:54 +00:00
|
|
|
const s32 idx = in.ReadLong();
|
|
|
|
std::string a = in.Get<std::string>();
|
|
|
|
std::string b = in.Get<std::string>();
|
2020-02-28 09:55:05 +00:00
|
|
|
ret.emplace_back(idx, std::make_pair(std::move(a), std::move(b)));
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
|
|
|
return ret;
|
2016-04-10 04:49:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CCharacterInfo::CCharacterInfo(CInputStream& in)
|
2022-02-18 07:37:54 +00:00
|
|
|
: x0_tableCount(in.ReadShort())
|
|
|
|
, x4_name(in.Get<std::string>())
|
|
|
|
, x14_cmdl(in.ReadLong())
|
|
|
|
, x18_cskr(in.ReadLong())
|
|
|
|
, x1c_cinf(in.ReadLong())
|
2018-12-08 05:30:43 +00:00
|
|
|
, x20_animInfo(MakeAnimInfoVector(in))
|
|
|
|
, x30_pasDatabase(in)
|
|
|
|
, x44_partRes(in, x0_tableCount)
|
2022-02-18 07:37:54 +00:00
|
|
|
, x84_unk(in.ReadLong()) {
|
2018-12-08 05:30:43 +00:00
|
|
|
if (x0_tableCount > 1) {
|
2022-02-18 07:37:54 +00:00
|
|
|
const u32 aabbCount = in.ReadLong();
|
2018-12-08 05:30:43 +00:00
|
|
|
x88_aabbs.reserve(aabbCount);
|
|
|
|
for (u32 i = 0; i < aabbCount; ++i) {
|
2022-02-18 07:37:54 +00:00
|
|
|
std::string name = in.Get<std::string>();
|
2020-02-28 09:55:05 +00:00
|
|
|
x88_aabbs.emplace_back(std::move(name), zeus::CAABox());
|
2022-02-18 07:37:54 +00:00
|
|
|
x88_aabbs.back().second = in.Get<zeus::CAABox>();
|
2016-04-10 21:22:59 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
2016-04-10 21:22:59 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
if (x0_tableCount > 2) {
|
2022-02-18 07:37:54 +00:00
|
|
|
const u32 effectCount = in.ReadLong();
|
2018-12-08 05:30:43 +00:00
|
|
|
x98_effects.reserve(effectCount);
|
|
|
|
for (u32 i = 0; i < effectCount; ++i) {
|
2022-02-18 07:37:54 +00:00
|
|
|
std::string name = in.Get<std::string>();
|
2020-02-28 09:55:05 +00:00
|
|
|
x98_effects.emplace_back(std::move(name), std::vector<CEffectComponent>());
|
2018-12-08 05:30:43 +00:00
|
|
|
std::vector<CEffectComponent>& comps = x98_effects.back().second;
|
2022-02-18 07:37:54 +00:00
|
|
|
const u32 compCount = in.ReadLong();
|
2018-12-08 05:30:43 +00:00
|
|
|
comps.reserve(compCount);
|
2020-02-28 09:55:05 +00:00
|
|
|
for (u32 j = 0; j < compCount; ++j) {
|
2018-12-08 05:30:43 +00:00
|
|
|
comps.emplace_back(in);
|
2020-02-28 09:55:05 +00:00
|
|
|
}
|
2016-04-10 21:22:59 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
2016-04-10 21:22:59 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
if (x0_tableCount > 3) {
|
2022-02-18 07:37:54 +00:00
|
|
|
xa8_cmdlOverlay = in.ReadLong();
|
|
|
|
xac_cskrOverlay = in.ReadLong();
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
2016-04-10 21:22:59 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
if (x0_tableCount > 4) {
|
2022-02-18 07:37:54 +00:00
|
|
|
const u32 aidxCount = in.ReadLong();
|
2018-12-08 05:30:43 +00:00
|
|
|
xb0_animIdxs.reserve(aidxCount);
|
2020-02-28 09:55:05 +00:00
|
|
|
for (u32 i = 0; i < aidxCount; ++i) {
|
2022-02-18 07:37:54 +00:00
|
|
|
xb0_animIdxs.push_back(in.ReadLong());
|
2020-02-28 09:55:05 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
2016-04-10 21:22:59 +00:00
|
|
|
}
|
2016-04-10 04:49:02 +00:00
|
|
|
|
2020-02-28 09:56:41 +00:00
|
|
|
s32 CCharacterInfo::GetAnimationIndex(std::string_view name) const {
|
2018-12-08 05:30:43 +00:00
|
|
|
for (const auto& pair : x20_animInfo) {
|
2019-10-01 07:38:03 +00:00
|
|
|
if (pair.second.second == name)
|
2018-12-08 05:30:43 +00:00
|
|
|
return pair.first;
|
|
|
|
}
|
2018-09-16 23:22:35 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
return -1;
|
2018-09-16 23:22:35 +00:00
|
|
|
}
|
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
} // namespace metaforce
|