ksys/xlink: Add InfoData

This commit is contained in:
Léo Lam
2021-04-26 14:45:37 +02:00
parent f365c0b591
commit caa3dcf548
5 changed files with 141 additions and 16 deletions
+1
View File
@@ -17,6 +17,7 @@ add_subdirectory(System)
add_subdirectory(Terrain)
add_subdirectory(Utils)
add_subdirectory(World)
add_subdirectory(XLink)
target_sources(uking PRIVATE
ksys.cpp
+4
View File
@@ -0,0 +1,4 @@
target_sources(uking PRIVATE
xlinkInfoData.cpp
xlinkInfoData.h
)
+84
View File
@@ -0,0 +1,84 @@
#include "KingSystem/XLink/xlinkInfoData.h"
#include "KingSystem/Resource/resLoadRequest.h"
namespace ksys::xlink {
SEAD_SINGLETON_DISPOSER_IMPL(InfoData)
InfoData::~InfoData() {
if (mRootIter)
delete mRootIter;
}
void InfoData::loadInfo(sead::Heap* heap) {
res::LoadRequest req;
req.mRequester = "xlink::InfoData";
req._22 = true;
mResHandle.load("Actor/XLink/XLinkInfo.byml", &req);
auto* resource = sead::DynamicCast<sead::DirectResource>(mResHandle.getResource());
if (mRootIter)
delete mRootIter;
mRootIter = new (heap) al::ByamlIter(resource->getRawData());
}
void InfoData::init(sead::Heap* heap) {
loadInfo(heap);
}
al::ByamlIter InfoData::getIter(const sead::SafeString& key) const {
const auto iter = mRootIter->getIterByKey(key.cstr());
return al::ByamlIter(iter);
}
sead::SafeString InfoData::getXLinkSettingPropertyTableName(const al::ByamlIter& iter) const {
const char* value = "ActorBasic";
iter.tryGetStringByKey(&value, "XLinkSettingPropertyTableName");
return value;
}
sead::SafeString InfoData::getXLinkSettingFootStepProcTypeName(const al::ByamlIter& iter) const {
const char* value = "None";
iter.tryGetStringByKey(&value, "XLinkSettingFootStepProcTypeName");
return value;
}
float InfoData::getXLinkSettingVeloClampThreshold(const al::ByamlIter& iter) const {
float value = 0.0;
iter.tryGetFloatByKey(&value, "XLinkSettingVeloClampThreshold");
return value;
}
float InfoData::getXLinkSettingVeloRollClampThreshold(const al::ByamlIter& iter) const {
float value = 0.0;
iter.tryGetFloatByKey(&value, "XLinkSettingVeloRollClampThreshold");
return value;
}
bool InfoData::getXLinkSettingIsReactionTargetEnemy(const al::ByamlIter& iter) const {
bool value = false;
iter.tryGetBoolByKey(&value, "XLinkSettingIsReactionTargetEnemy");
return value;
}
bool InfoData::getXLinkSettingIsReactionTargetTinyEnemy(const al::ByamlIter& iter) const {
bool value = false;
iter.tryGetBoolByKey(&value, "XLinkSettingIsReactionTargetTinyEnemy");
return value;
}
bool InfoData::getXLinkSettingIsReactionTargetObject(const al::ByamlIter& iter) const {
bool value = false;
iter.tryGetBoolByKey(&value, "XLinkSettingIsReactionTargetObject");
return value;
}
bool InfoData::getXLinkSettingIsIgnoreDamageToObject(const sead::SafeString& key) const {
const auto iter = getIter(key);
bool value = false;
iter.tryGetBoolByKey(&value, "XLinkSettingIsIgnoreDamageToObject");
return value;
}
} // namespace ksys::xlink
+36
View File
@@ -0,0 +1,36 @@
#pragma once
#include <heap/seadDisposer.h>
#include "KingSystem/Resource/resHandle.h"
#include "KingSystem/Utils/Byaml/Byaml.h"
namespace ksys::xlink {
class InfoData {
SEAD_SINGLETON_DISPOSER(InfoData)
InfoData() = default;
virtual ~InfoData();
public:
void init(sead::Heap* heap);
al::ByamlIter getIter(const sead::SafeString& key) const;
sead::SafeString getXLinkSettingPropertyTableName(const al::ByamlIter& iter) const;
sead::SafeString getXLinkSettingFootStepProcTypeName(const al::ByamlIter& iter) const;
float getXLinkSettingVeloClampThreshold(const al::ByamlIter& iter) const;
float getXLinkSettingVeloRollClampThreshold(const al::ByamlIter& iter) const;
bool getXLinkSettingIsReactionTargetEnemy(const al::ByamlIter& iter) const;
bool getXLinkSettingIsReactionTargetTinyEnemy(const al::ByamlIter& iter) const;
bool getXLinkSettingIsReactionTargetObject(const al::ByamlIter& iter) const;
bool getXLinkSettingIsIgnoreDamageToObject(const sead::SafeString& key) const;
private:
void loadInfo(sead::Heap* heap);
al::ByamlIter* mRootIter{};
res::Handle mResHandle{};
};
} // namespace ksys::xlink