mirror of
https://github.com/zeldaret/botw
synced 2026-06-02 01:59:59 -04:00
ksys/act: Start implementing AIClassDef
This commit is contained in:
@@ -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);
|
||||
|
||||
private:
|
||||
class Data;
|
||||
bool isSystemQuery(const sead::SafeString& query) const;
|
||||
|
||||
Data* mData;
|
||||
// res::Handle mResHandle;
|
||||
private:
|
||||
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 = nullptr;
|
||||
res::Handle mResHandle;
|
||||
};
|
||||
// KSYS_CHECK_SIZE_NX150(AIClassDef, 0x78);
|
||||
KSYS_CHECK_SIZE_NX150(AIClassDef, 0x78);
|
||||
|
||||
} // namespace ksys
|
||||
|
||||
Reference in New Issue
Block a user