2019-12-22 20:04:07 +00:00
|
|
|
#include "Runtime/CScannableObjectInfo.hpp"
|
|
|
|
|
|
|
|
#include "Runtime/GameGlobalObjects.hpp"
|
2016-08-03 23:20:31 +00:00
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
namespace metaforce {
|
2018-12-08 05:30:43 +00:00
|
|
|
CScannableObjectInfo::CScannableObjectInfo(CInputStream& in, CAssetId resId) : x0_scannableObjectId(resId) {
|
2022-02-18 07:37:54 +00:00
|
|
|
const u32 version = in.ReadLong();
|
2018-12-08 05:30:43 +00:00
|
|
|
Load(in, version);
|
2017-02-10 05:43:07 +00:00
|
|
|
|
2020-04-13 01:42:52 +00:00
|
|
|
for (auto& bucket : x14_buckets) {
|
|
|
|
bucket.x4_appearanceRange *= x8_totalDownloadTime;
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
2018-11-24 08:09:35 +00:00
|
|
|
|
2020-04-13 01:42:52 +00:00
|
|
|
const float appearanceOffset = g_tweakGui->GetScanAppearanceDuration();
|
|
|
|
for (size_t i = 0; i < x14_buckets.size(); ++i) {
|
|
|
|
if (x14_buckets[i].x8_imagePos == UINT32_MAX) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
x8_totalDownloadTime += appearanceOffset;
|
|
|
|
for (size_t j = i; j < x14_buckets.size(); j++) {
|
|
|
|
x14_buckets[j].x4_appearanceRange += appearanceOffset;
|
2017-02-10 05:43:07 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
2017-02-10 05:43:07 +00:00
|
|
|
|
2020-04-13 01:42:52 +00:00
|
|
|
for (size_t i = 0; i < x14_buckets.size() - 1; ++i) {
|
|
|
|
for (size_t j = i + 1; j < x14_buckets.size(); ++j) {
|
|
|
|
if (x14_buckets[i].x8_imagePos == x14_buckets[j].x8_imagePos && x14_buckets[i].x8_imagePos != UINT32_MAX) {
|
|
|
|
x14_buckets[j].x8_imagePos = UINT32_MAX;
|
|
|
|
}
|
2017-02-10 05:43:07 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
2016-08-03 23:20:31 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CScannableObjectInfo::Load(CInputStream& in, u32 version) {
|
2022-02-18 07:37:54 +00:00
|
|
|
in.ReadLong();
|
|
|
|
in.ReadLong();
|
2022-02-19 13:04:45 +00:00
|
|
|
x4_stringId = in.Get<CAssetId>();
|
2020-04-13 01:45:08 +00:00
|
|
|
if (version < 4) {
|
2022-02-18 07:37:54 +00:00
|
|
|
x8_totalDownloadTime = in.ReadFloat();
|
2020-04-13 01:45:08 +00:00
|
|
|
} else {
|
2022-02-18 07:37:54 +00:00
|
|
|
const u32 scanSpeed = in.ReadLong();
|
2018-12-08 05:30:43 +00:00
|
|
|
x8_totalDownloadTime = g_tweakGui->GetScanSpeed(scanSpeed);
|
|
|
|
}
|
2022-02-18 07:37:54 +00:00
|
|
|
xc_category = in.ReadLong();
|
2020-04-13 01:45:08 +00:00
|
|
|
if (version > 4) {
|
2022-02-18 07:37:54 +00:00
|
|
|
x10_important = in.ReadBool();
|
2020-04-13 01:45:08 +00:00
|
|
|
}
|
2016-08-03 23:20:31 +00:00
|
|
|
|
2020-04-13 01:45:08 +00:00
|
|
|
for (size_t i = 0; i < x14_buckets.capacity(); i++) {
|
2018-12-08 05:30:43 +00:00
|
|
|
x14_buckets.emplace_back(in, version);
|
2020-04-13 01:45:08 +00:00
|
|
|
}
|
2016-08-03 23:20:31 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
CScannableObjectInfo::SBucket::SBucket(CInputStream& in, u32 version) {
|
2022-02-19 13:04:45 +00:00
|
|
|
x0_texture = in.Get<CAssetId>();
|
2022-02-18 07:37:54 +00:00
|
|
|
x4_appearanceRange = in.ReadFloat();
|
|
|
|
x8_imagePos = in.ReadLong();
|
2018-12-08 05:30:43 +00:00
|
|
|
if (version > 1) {
|
2022-02-18 07:37:54 +00:00
|
|
|
xc_size.x = in.ReadLong();
|
|
|
|
xc_size.y = in.ReadLong();
|
|
|
|
x14_interval = in.ReadFloat();
|
2018-12-08 05:30:43 +00:00
|
|
|
if (version >= 3)
|
2022-02-18 07:37:54 +00:00
|
|
|
x18_fadeDuration = in.ReadFloat();
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
2016-08-03 23:20:31 +00:00
|
|
|
}
|
|
|
|
|
2017-01-31 11:21:45 +00:00
|
|
|
CFactoryFnReturn FScannableObjectInfoFactory(const SObjectTag& tag, CInputStream& in, const CVParamTransfer&,
|
2020-05-20 18:02:50 +00:00
|
|
|
CObjectReference*) {
|
2018-12-08 05:30:43 +00:00
|
|
|
return TToken<CScannableObjectInfo>::GetIObjObjectFor(std::make_unique<CScannableObjectInfo>(in, tag.id));
|
2016-08-03 23:20:31 +00:00
|
|
|
}
|
2021-04-10 08:42:06 +00:00
|
|
|
} // namespace metaforce
|