diff options
| author | Léo Lam <leo@leolam.fr> | 2021-04-26 14:45:37 +0200 |
|---|---|---|
| committer | Léo Lam <leo@leolam.fr> | 2021-04-26 14:47:12 +0200 |
| commit | caa3dcf5489f54c1aeb0bc1981f8de6441ddb0cc (patch) | |
| tree | 839e5cab2b021f695bae8ad524e6899395fe162c /src | |
| parent | f365c0b591749009b809e21e9cfa01d4643131fe (diff) | |
ksys/xlink: Add InfoData
Diffstat (limited to 'src')
| -rw-r--r-- | src/KingSystem/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | src/KingSystem/XLink/CMakeLists.txt | 4 | ||||
| -rw-r--r-- | src/KingSystem/XLink/xlinkInfoData.cpp | 84 | ||||
| -rw-r--r-- | src/KingSystem/XLink/xlinkInfoData.h | 36 |
4 files changed, 125 insertions, 0 deletions
diff --git a/src/KingSystem/CMakeLists.txt b/src/KingSystem/CMakeLists.txt index 0e19ed21..c387306f 100644 --- a/src/KingSystem/CMakeLists.txt +++ b/src/KingSystem/CMakeLists.txt @@ -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 diff --git a/src/KingSystem/XLink/CMakeLists.txt b/src/KingSystem/XLink/CMakeLists.txt new file mode 100644 index 00000000..f1ab0c91 --- /dev/null +++ b/src/KingSystem/XLink/CMakeLists.txt @@ -0,0 +1,4 @@ +target_sources(uking PRIVATE + xlinkInfoData.cpp + xlinkInfoData.h +) diff --git a/src/KingSystem/XLink/xlinkInfoData.cpp b/src/KingSystem/XLink/xlinkInfoData.cpp new file mode 100644 index 00000000..2bacc5ea --- /dev/null +++ b/src/KingSystem/XLink/xlinkInfoData.cpp @@ -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 diff --git a/src/KingSystem/XLink/xlinkInfoData.h b/src/KingSystem/XLink/xlinkInfoData.h new file mode 100644 index 00000000..9b429d20 --- /dev/null +++ b/src/KingSystem/XLink/xlinkInfoData.h @@ -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 |
