diff options
Diffstat (limited to 'src/KingSystem/ActorSystem/actAiClassDef.h')
| -rw-r--r-- | src/KingSystem/ActorSystem/actAiClassDef.h | 49 |
1 files changed, 44 insertions, 5 deletions
diff --git a/src/KingSystem/ActorSystem/actAiClassDef.h b/src/KingSystem/ActorSystem/actAiClassDef.h index d3f3adad..9208ab7c 100644 --- a/src/KingSystem/ActorSystem/actAiClassDef.h +++ b/src/KingSystem/ActorSystem/actAiClassDef.h @@ -1,8 +1,13 @@ #pragma once +#include <container/seadBuffer.h> +#include <container/seadSafeArray.h> #include <heap/seadDisposer.h> #include <prim/seadSafeString.h> #include <prim/seadSizedEnum.h> +#include "KingSystem/Resource/resHandle.h" +#include "KingSystem/Utils/Byaml/Byaml.h" +#include "KingSystem/Utils/SafeDelete.h" #include "KingSystem/Utils/Types.h" namespace ksys { @@ -14,6 +19,8 @@ enum class AIDefType { Query = 3, }; +static constexpr s32 NumAIDefTypes = 4; + enum class AIDefInstParamKind { Static = 0, Dynamic = 1, @@ -56,21 +63,53 @@ struct AIDef { }; KSYS_CHECK_SIZE_NX150(AIDef, 0x650); -// FIXME class AIClassDef { SEAD_SINGLETON_DISPOSER(AIClassDef) + AIClassDef() = default; + ~AIClassDef(); + public: void init(const sead::SafeString& aidef_file_name, sead::Heap* heap); void getDef(AIDef* def, const sead::SafeString& class_name, AIDefInstParamKind param_kind, AIDefType class_type); + bool isSystemQuery(const sead::SafeString& query) const; + private: - class Data; + struct Data { + struct Def { + u32 name_hash; + al::ByamlIter iter; + }; + + explicit Data(const u8* root) : root_iter(root) {} + bool load(sead::Heap* heap); + + sead::SafeArray<al::ByamlIter, NumAIDefTypes> iters; + sead::SafeArray<sead::Buffer<Def>, NumAIDefTypes> defs; + s32 idx_StaticInstParams; + s32 idx_DynamicInstParams; + s32 idx_MapUnitInstParams; + s32 idx_AITreeVariables; + s32 idx_Childs = -1; + al::ByamlIter root_iter; + }; + KSYS_CHECK_SIZE_NX150(Data, 0xa8); + + inline void freeData() { + if (!mData) + return; + + for (auto& defs : mData->defs) + defs.freeBuffer(); + + util::safeDelete(mData); + } - Data* mData; - // res::Handle mResHandle; + Data* mData = nullptr; + res::Handle mResHandle; }; -// KSYS_CHECK_SIZE_NX150(AIClassDef, 0x78); +KSYS_CHECK_SIZE_NX150(AIClassDef, 0x78); } // namespace ksys |
