2021-06-05 05:27:52 +00:00
|
|
|
#include "Runtime/CWorldSaveGameInfo.hpp"
|
2019-12-22 20:04:07 +00:00
|
|
|
|
|
|
|
#include "Runtime/CToken.hpp"
|
2016-07-24 01:51:15 +00:00
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
namespace metaforce {
|
2021-06-05 05:27:52 +00:00
|
|
|
CWorldSaveGameInfo::CWorldSaveGameInfo(CInputStream& in) {
|
2022-02-18 07:37:54 +00:00
|
|
|
in.ReadLong();
|
|
|
|
const u32 version = in.ReadLong();
|
2020-03-13 20:32:24 +00:00
|
|
|
if (version > 1) {
|
2022-02-18 07:37:54 +00:00
|
|
|
x0_areaCount = in.ReadLong();
|
2020-03-13 20:32:24 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
if (version > 2) {
|
2022-02-18 07:37:54 +00:00
|
|
|
const u32 cinematicCount = in.ReadLong();
|
2018-12-08 05:30:43 +00:00
|
|
|
x4_cinematics.reserve(cinematicCount);
|
2020-03-13 20:32:24 +00:00
|
|
|
for (u32 i = 0; i < cinematicCount; ++i) {
|
2022-02-18 07:37:54 +00:00
|
|
|
x4_cinematics.emplace_back(in.ReadLong());
|
2020-03-13 20:32:24 +00:00
|
|
|
}
|
2016-07-24 07:39:58 +00:00
|
|
|
|
2022-02-18 07:37:54 +00:00
|
|
|
const u32 relayCount = in.ReadLong();
|
2018-12-08 05:30:43 +00:00
|
|
|
x14_relays.reserve(relayCount);
|
2020-03-13 20:32:24 +00:00
|
|
|
for (u32 i = 0; i < relayCount; ++i) {
|
2022-02-18 07:37:54 +00:00
|
|
|
x14_relays.emplace_back(in.ReadLong());
|
2020-03-13 20:32:24 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
2016-07-24 07:39:58 +00:00
|
|
|
|
2022-02-18 07:37:54 +00:00
|
|
|
const u32 layerCount = in.ReadLong();
|
2018-12-08 05:30:43 +00:00
|
|
|
x24_layers.reserve(layerCount);
|
|
|
|
for (u32 i = 0; i < layerCount; ++i) {
|
2020-03-13 20:32:24 +00:00
|
|
|
SLayerState& st = x24_layers.emplace_back();
|
2022-02-18 07:37:54 +00:00
|
|
|
st.x0_area = in.ReadLong();
|
|
|
|
st.x4_layer = in.ReadLong();
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
2016-07-24 07:39:58 +00:00
|
|
|
|
2022-02-18 07:37:54 +00:00
|
|
|
const u32 doorCount = in.ReadLong();
|
2018-12-08 05:30:43 +00:00
|
|
|
x34_doors.reserve(doorCount);
|
2020-03-13 20:32:24 +00:00
|
|
|
for (u32 i = 0; i < doorCount; ++i) {
|
2022-02-18 07:37:54 +00:00
|
|
|
x34_doors.emplace_back(in.ReadLong());
|
2020-03-13 20:32:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (version <= 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-02-18 07:37:54 +00:00
|
|
|
const u32 scanCount = in.ReadLong();
|
2020-03-13 20:32:24 +00:00
|
|
|
x44_scans.reserve(scanCount);
|
|
|
|
for (u32 i = 0; i < scanCount; ++i) {
|
|
|
|
SScanState& st = x44_scans.emplace_back();
|
2022-02-19 13:04:45 +00:00
|
|
|
st.x0_id = in.Get<CAssetId>();
|
2022-02-18 07:37:54 +00:00
|
|
|
st.x4_category = EScanCategory(in.ReadLong());
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
2016-07-24 07:39:58 +00:00
|
|
|
}
|
|
|
|
|
2021-06-05 05:27:52 +00:00
|
|
|
u32 CWorldSaveGameInfo::GetAreaCount() const { return x0_areaCount; }
|
2016-07-24 07:39:58 +00:00
|
|
|
|
2021-06-05 05:27:52 +00:00
|
|
|
u32 CWorldSaveGameInfo::GetCinematicCount() const { return x4_cinematics.size(); }
|
2016-07-24 07:39:58 +00:00
|
|
|
|
2021-06-05 05:27:52 +00:00
|
|
|
s32 CWorldSaveGameInfo::GetCinematicIndex(const TEditorId& id) const {
|
2018-12-08 05:30:43 +00:00
|
|
|
auto it = std::find(x4_cinematics.begin(), x4_cinematics.end(), id);
|
|
|
|
if (it == x4_cinematics.end())
|
|
|
|
return -1;
|
|
|
|
return it - x4_cinematics.begin();
|
2016-07-24 07:39:58 +00:00
|
|
|
}
|
|
|
|
|
2021-06-05 05:27:52 +00:00
|
|
|
u32 CWorldSaveGameInfo::GetRelayCount() const { return x14_relays.size(); }
|
2016-07-24 07:39:58 +00:00
|
|
|
|
2021-06-05 05:27:52 +00:00
|
|
|
s32 CWorldSaveGameInfo::GetRelayIndex(const TEditorId& id) const {
|
2018-12-08 05:30:43 +00:00
|
|
|
auto it = std::find(x14_relays.begin(), x14_relays.end(), id);
|
|
|
|
if (it == x14_relays.end())
|
|
|
|
return -1;
|
|
|
|
return it - x14_relays.begin();
|
2016-07-24 23:14:58 +00:00
|
|
|
}
|
2016-07-24 07:39:58 +00:00
|
|
|
|
2021-06-05 05:27:52 +00:00
|
|
|
TEditorId CWorldSaveGameInfo::GetRelayEditorId(u32 idx) const { return x14_relays[idx]; }
|
2016-07-24 07:39:58 +00:00
|
|
|
|
2021-06-05 05:27:52 +00:00
|
|
|
u32 CWorldSaveGameInfo::GetDoorCount() const { return x34_doors.size(); }
|
2016-07-24 07:39:58 +00:00
|
|
|
|
2021-06-05 05:27:52 +00:00
|
|
|
s32 CWorldSaveGameInfo::GetDoorIndex(const TEditorId& id) const {
|
2018-12-08 05:30:43 +00:00
|
|
|
auto it = std::find(x34_doors.begin(), x34_doors.end(), id);
|
|
|
|
if (it == x34_doors.end())
|
|
|
|
return -1;
|
|
|
|
return it - x34_doors.begin();
|
2016-07-24 01:51:15 +00:00
|
|
|
}
|
|
|
|
|
2021-06-05 05:27:52 +00:00
|
|
|
CFactoryFnReturn FWorldSaveGameInfoFactory([[maybe_unused]] const SObjectTag& tag, CInputStream& in,
|
2021-06-07 19:29:18 +00:00
|
|
|
[[maybe_unused]] const CVParamTransfer& param,
|
|
|
|
[[maybe_unused]] CObjectReference* selfRef) {
|
2021-06-05 05:27:52 +00:00
|
|
|
return TToken<CWorldSaveGameInfo>::GetIObjObjectFor(std::make_unique<CWorldSaveGameInfo>(in));
|
2016-10-08 20:32:36 +00:00
|
|
|
}
|
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
} // namespace metaforce
|