mirror of
https://github.com/zeldaret/botw
synced 2026-08-01 08:07:52 -04:00
ksys/res: Implement RagdollConfigList
This commit is contained in:
@@ -4,7 +4,11 @@ namespace ksys::res {
|
||||
|
||||
const int RagdollConfig::cNumReceiveObjs = 3;
|
||||
const int RagdollConfig::cNumImpulseObjs = 5;
|
||||
const int RagdollConfig::cNumXXX = 10;
|
||||
const int RagdollConfig::cNumImpulseParams = 10;
|
||||
const std::array<char, 64> RagdollConfig::cImpulseParamNames[10] = {
|
||||
{"Default"}, {"Sword"}, {"LargeSword"}, {"Spear"}, {"Arrow"},
|
||||
{"Bomb"}, {"HeadShot"}, {"ShockWave"}, {"SilentKill"}, {"Gust"},
|
||||
};
|
||||
|
||||
RagdollConfig::RagdollConfig() : ParamIO("rgconfig", 0) {}
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
|
||||
#include "KingSystem/Physics/Ragdoll/physRagdollConfig.h"
|
||||
#include "KingSystem/Resource/resResource.h"
|
||||
#include "KingSystem/Utils/ParamIO.h"
|
||||
@@ -20,7 +22,8 @@ public:
|
||||
|
||||
static const int cNumReceiveObjs;
|
||||
static const int cNumImpulseObjs;
|
||||
static const int cNumXXX; // FIXME: rename
|
||||
static const int cNumImpulseParams;
|
||||
static const std::array<char, 64> cImpulseParamNames[10];
|
||||
|
||||
private:
|
||||
phys::RagdollConfig mConfig;
|
||||
|
||||
@@ -1 +1,80 @@
|
||||
#include "KingSystem/Resource/resResourceRagdollConfigList.h"
|
||||
#include "KingSystem/Resource/resResourceRagdollConfig.h"
|
||||
|
||||
namespace ksys::res {
|
||||
|
||||
RagdollConfigList::RagdollConfigList()
|
||||
: ParamIO("rgconfiglist", 0),
|
||||
mUpperLimitHeight(0.0, "UpperLimitHight" /*sic*/, "ヒット位置判定の境界(上)", &mCommonData),
|
||||
mLowerLimitHeight(0.0, "LowerLimitHight" /*sic*/, "ヒット位置判定の境界(下)",
|
||||
&mCommonData) {}
|
||||
|
||||
RagdollConfigList::~RagdollConfigList() {
|
||||
mImpulseParams.freeBuffer();
|
||||
mBodyParams.freeBuffer();
|
||||
}
|
||||
|
||||
void RagdollConfigList::doCreate_(u8*, u32, sead::Heap*) {}
|
||||
|
||||
bool RagdollConfigList::parse_(u8* data, size_t size, sead::Heap* heap) {
|
||||
if (!data)
|
||||
return false;
|
||||
|
||||
if (RagdollConfig::cNumImpulseParams > 0) {
|
||||
mImpulseParams.allocBufferAssert(RagdollConfig::cNumImpulseParams, heap);
|
||||
if (!mImpulseParams.isBufferReady())
|
||||
return false;
|
||||
|
||||
#ifdef MATCHING_HACK_NX_CLANG
|
||||
__builtin_assume(RagdollConfig::cNumImpulseParams != 0);
|
||||
#endif
|
||||
|
||||
for (int i = 0; i != RagdollConfig::cNumImpulseParams; ++i) {
|
||||
mImpulseParams[i].config = nullptr;
|
||||
mImpulseParams[i].file_name.init("", "FileName", "データファイル名", "",
|
||||
&mImpulseParams[i].obj);
|
||||
mImpulseParamList.addObj(
|
||||
&mImpulseParams[i].obj,
|
||||
sead::FormatFixedSafeString<32>("%s%s", "ImpulseParam_",
|
||||
RagdollConfig::cImpulseParamNames[i].data()));
|
||||
}
|
||||
}
|
||||
addList(&mImpulseParamList, "ImpulseParamList");
|
||||
|
||||
addObj(&mCommonData, "CommonData");
|
||||
|
||||
agl::utl::ResParameterArchive archive{data};
|
||||
const auto root = archive.getRootList();
|
||||
const auto BodyParamList = agl::utl::getResParameterList(root, "BodyParamList");
|
||||
if (int num_params;
|
||||
BodyParamList && (num_params = BodyParamList.getResParameterObjNum()) != 0) {
|
||||
mBodyParams.allocBufferAssert(num_params, heap);
|
||||
for (int i = 0; i < num_params; ++i) {
|
||||
mBodyParams[i].rigid_name.init(sead::SafeString::cEmptyString, "RigidName", "RigidName",
|
||||
"RigidName", &mBodyParams[i]);
|
||||
mBodyParams[i].friction_scale.init(1.0, "FrictionScale", "FrictionScale",
|
||||
"FrictionScale", &mBodyParams[i]);
|
||||
mBodyParams[i].buoyancy_scale.init(1.0, "BuoyancyScale", "BuoyancyScale",
|
||||
"BuoyancyScale", &mBodyParams[i]);
|
||||
mBodyParamList.addObj(&mBodyParams[i],
|
||||
sead::FormatFixedSafeString<32>("BodyParam_%d", i));
|
||||
}
|
||||
}
|
||||
addList(&mBodyParamList, "BodyParamList");
|
||||
|
||||
applyResParameterArchive(archive);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RagdollConfigList::finishParsing_() {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RagdollConfigList::m7_() {
|
||||
for (auto& param : mImpulseParams)
|
||||
param.config = nullptr;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace ksys::res
|
||||
|
||||
@@ -33,8 +33,10 @@ public:
|
||||
|
||||
RagdollConfigList();
|
||||
~RagdollConfigList() override;
|
||||
RagdollConfigList(const RagdollConfigList&) = delete;
|
||||
auto operator=(const RagdollConfigList&) = delete;
|
||||
|
||||
void doCreate_(u8*, u32, sead::Heap*) override {}
|
||||
void doCreate_(u8*, u32, sead::Heap*) override;
|
||||
bool needsParse() const override { return true; }
|
||||
bool parse_(u8* data, size_t size, sead::Heap* heap) override;
|
||||
bool finishParsing_() override;
|
||||
|
||||
Reference in New Issue
Block a user