mirror of https://github.com/zeldaret/botw.git
ksys: Split actAiParam.h to reduce compile times
This commit is contained in:
parent
814baf809e
commit
3a9fd0f9b9
|
@ -42,6 +42,7 @@ target_sources(uking PRIVATE
|
|||
actAiBehavior.h
|
||||
actAiClassDef.cpp
|
||||
actAiClassDef.h
|
||||
actAiInlineParam.h
|
||||
actAiParam.cpp
|
||||
actAiParam.h
|
||||
actAiQuery.cpp
|
||||
|
|
|
@ -2,9 +2,11 @@
|
|||
#include "KingSystem/ActorSystem/actActor.h"
|
||||
#include "KingSystem/ActorSystem/actActorParam.h"
|
||||
#include "KingSystem/ActorSystem/actAiAction.h"
|
||||
#include "KingSystem/ActorSystem/actAiInlineParam.h"
|
||||
#include "KingSystem/ActorSystem/actAiRoot.h"
|
||||
#include "KingSystem/Resource/resResourceAIProgram.h"
|
||||
#include "KingSystem/Utils/InitTimeInfo.h"
|
||||
#include "KingSystem/Utils/Thread/MessageTransceiverId.h"
|
||||
|
||||
namespace ksys::act::ai {
|
||||
|
||||
|
|
|
@ -2,14 +2,17 @@
|
|||
|
||||
#include <basis/seadTypes.h>
|
||||
#include <math/seadMathCalcCommon.h>
|
||||
#include <math/seadVector.h>
|
||||
#include <prim/seadRuntimeTypeInfo.h>
|
||||
#include <prim/seadTypedBitFlag.h>
|
||||
#include "KingSystem/ActorSystem/actAiParam.h"
|
||||
#include "KingSystem/Utils/Types.h"
|
||||
|
||||
namespace ksys {
|
||||
struct AIDefSet;
|
||||
class Message;
|
||||
}
|
||||
struct MesTransceiverId;
|
||||
} // namespace ksys
|
||||
|
||||
namespace ksys::res {
|
||||
class AIProgram;
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
#include "KingSystem/ActorSystem/actActorParam.h"
|
||||
#include "KingSystem/ActorSystem/actActorUtil.h"
|
||||
#include "KingSystem/ActorSystem/actAiAction.h"
|
||||
#include "KingSystem/ActorSystem/actAiClassDef.h"
|
||||
#include "KingSystem/ActorSystem/actAiInlineParam.h"
|
||||
#include "KingSystem/ActorSystem/actAiRoot.h"
|
||||
#include "KingSystem/ActorSystem/aiDummyAi.h"
|
||||
#include "KingSystem/Resource/resResourceAIProgram.h"
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include <codec/seadHashCRC32.h>
|
||||
#include <prim/seadContainerIterator.h>
|
||||
#include <resource/seadResource.h>
|
||||
#include "KingSystem/ActorSystem/actAiParam.h"
|
||||
#include "KingSystem/Resource/resLoadRequest.h"
|
||||
#include "KingSystem/Utils/Byaml/ByamlData.h"
|
||||
#include "KingSystem/Utils/Byaml/ByamlHashIter.h"
|
||||
|
|
|
@ -40,21 +40,7 @@ constexpr bool paramKindHasValue(AIDefInstParamKind kind) {
|
|||
|
||||
constexpr s32 NumAIDefInstParamKinds = 4;
|
||||
|
||||
enum class AIDefParamType {
|
||||
String = 0,
|
||||
Int = 1,
|
||||
Float = 2,
|
||||
Vec3 = 3,
|
||||
Bool = 4,
|
||||
Tree = 5,
|
||||
AITreeVariablePointer = 6,
|
||||
UInt = 7,
|
||||
BaseProcLink = 8,
|
||||
MesTransceiverId = 9,
|
||||
BaseProcHandle = 10,
|
||||
Rail = 11,
|
||||
Other = 12,
|
||||
};
|
||||
enum class AIDefParamType;
|
||||
|
||||
enum class CalcTiming {
|
||||
AIAfter = 0,
|
||||
|
|
|
@ -0,0 +1,85 @@
|
|||
#pragma once
|
||||
|
||||
#include <basis/seadTypes.h>
|
||||
#include <math/seadVector.h>
|
||||
#include <prim/seadSafeString.h>
|
||||
|
||||
#include "KingSystem/ActorSystem/actAiClassDef.h"
|
||||
#include "KingSystem/ActorSystem/actBaseProcLink.h"
|
||||
#include "KingSystem/Utils/Thread/MessageTransceiverId.h"
|
||||
#include "KingSystem/Utils/Types.h"
|
||||
|
||||
namespace ksys {
|
||||
|
||||
class Rail;
|
||||
|
||||
namespace act {
|
||||
class Actor;
|
||||
class BaseProc;
|
||||
} // namespace act
|
||||
|
||||
namespace act::ai {
|
||||
|
||||
struct InlineParam {
|
||||
union {
|
||||
bool b;
|
||||
int i;
|
||||
u32 u;
|
||||
float f;
|
||||
const char* cstr;
|
||||
void* ptr;
|
||||
};
|
||||
BaseProcLink baseProcLink;
|
||||
sead::Vector3f vec3;
|
||||
MesTransceiverId mesTransceiverId;
|
||||
AIDefParamType type;
|
||||
const char* key;
|
||||
};
|
||||
KSYS_CHECK_SIZE_NX150(InlineParam, 0x50);
|
||||
|
||||
struct InlineParamPack {
|
||||
InlineParamPack() = default;
|
||||
|
||||
InlineParam& getParam(s32 idx) {
|
||||
if (idx < 0) {
|
||||
idx = count;
|
||||
if (count > NumParamsMax - 1)
|
||||
idx = 0;
|
||||
else
|
||||
count = idx + 1;
|
||||
}
|
||||
return params[idx];
|
||||
}
|
||||
|
||||
s32 findIndex(const sead::SafeString& name, AIDefParamType type) const {
|
||||
for (s32 i = 0; i < count; ++i) {
|
||||
if (params[i].type == type && name == params[i].key)
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
void addString(const char* value, const sead::SafeString& key, s32 idx);
|
||||
void addString(const sead::SafeString& value, const sead::SafeString& key, s32 idx) {
|
||||
addString(value.cstr(), key, idx);
|
||||
}
|
||||
void addInt(s32 value, const sead::SafeString& key, s32 idx);
|
||||
void addFloat(f32 value, const sead::SafeString& key, s32 idx);
|
||||
void addVec3(const sead::Vector3f& value, const sead::SafeString& key, s32 idx);
|
||||
void addBool(bool value, const sead::SafeString& key, s32 idx);
|
||||
void addUInt(u32 value, const sead::SafeString& key, s32 idx);
|
||||
void addActor(const BaseProcLink& value, const sead::SafeString& key, s32 idx);
|
||||
void addMesTransceiverId(const MesTransceiverId& value, const sead::SafeString& key, s32 idx);
|
||||
void addPointer(void* value, const sead::SafeString& key, AIDefParamType type, s32 idx);
|
||||
void acquireActor(BaseProc* proc, const sead::SafeString& key, s32 idx);
|
||||
void copyToParamPack(ParamPack& pack) const;
|
||||
|
||||
static constexpr s32 NumParamsMax = 32;
|
||||
InlineParam params[NumParamsMax];
|
||||
int count = 0;
|
||||
};
|
||||
KSYS_CHECK_SIZE_NX150(InlineParamPack, 0xA08);
|
||||
|
||||
} // namespace act::ai
|
||||
|
||||
} // namespace ksys
|
|
@ -1,5 +1,8 @@
|
|||
#include "KingSystem/ActorSystem/actAiParam.h"
|
||||
#include <agl/Utils/aglParameter.h>
|
||||
#include "KingSystem/ActorSystem/actActor.h"
|
||||
#include "KingSystem/ActorSystem/actAiClassDef.h"
|
||||
#include "KingSystem/ActorSystem/actAiInlineParam.h"
|
||||
|
||||
namespace ksys::act {
|
||||
class BaseProcHandle;
|
||||
|
@ -58,6 +61,22 @@ ParamPack::~ParamPack() {
|
|||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T* ParamPack::getVariable(const sead::SafeString& key, AIDefParamType type, bool a4) const {
|
||||
const u32 hash = agl::utl::ParameterBase::calcHash(key);
|
||||
auto* param = mParams;
|
||||
if (!param)
|
||||
return nullptr;
|
||||
while (param->hash != hash || param->type != type) {
|
||||
param = param->next;
|
||||
if (!param)
|
||||
return nullptr;
|
||||
}
|
||||
if (a4)
|
||||
param->used = true;
|
||||
return static_cast<T*>(param->data);
|
||||
}
|
||||
|
||||
bool ParamPack::load(const Actor& actor, const ParamNameTypePairs& pairs, s32 count,
|
||||
sead::Heap* heap) {
|
||||
AIDef def;
|
||||
|
|
|
@ -1,26 +1,40 @@
|
|||
#pragma once
|
||||
|
||||
#include <agl/Utils/aglParameter.h>
|
||||
#include <basis/seadTypes.h>
|
||||
#include <container/seadSafeArray.h>
|
||||
#include <math/seadVector.h>
|
||||
#include <prim/seadSafeString.h>
|
||||
#include <prim/seadSizedEnum.h>
|
||||
|
||||
#include "KingSystem/ActorSystem/actAiClassDef.h"
|
||||
#include "KingSystem/ActorSystem/actBaseProcLink.h"
|
||||
#include "KingSystem/Utils/Thread/MessageTransceiverId.h"
|
||||
#include "KingSystem/Utils/Types.h"
|
||||
|
||||
namespace ksys {
|
||||
|
||||
class Rail;
|
||||
|
||||
namespace act {
|
||||
class Actor;
|
||||
class BaseProc;
|
||||
class BaseProcLink;
|
||||
} // namespace act
|
||||
|
||||
struct AIDef;
|
||||
class Rail;
|
||||
enum class AIDefInstParamKind;
|
||||
|
||||
enum class AIDefParamType {
|
||||
String = 0,
|
||||
Int = 1,
|
||||
Float = 2,
|
||||
Vec3 = 3,
|
||||
Bool = 4,
|
||||
Tree = 5,
|
||||
AITreeVariablePointer = 6,
|
||||
UInt = 7,
|
||||
BaseProcLink = 8,
|
||||
MesTransceiverId = 9,
|
||||
BaseProcHandle = 10,
|
||||
Rail = 11,
|
||||
Other = 12,
|
||||
};
|
||||
|
||||
namespace act::ai {
|
||||
|
||||
struct InlineParamPack;
|
||||
|
@ -57,20 +71,7 @@ public:
|
|||
~ParamPack();
|
||||
|
||||
template <typename T>
|
||||
T* getVariable(const sead::SafeString& key, AIDefParamType type, bool a4 = true) const {
|
||||
const u32 hash = agl::utl::ParameterBase::calcHash(key);
|
||||
auto* param = mParams;
|
||||
if (!param)
|
||||
return nullptr;
|
||||
while (param->hash != hash || param->type != type) {
|
||||
param = param->next;
|
||||
if (!param)
|
||||
return nullptr;
|
||||
}
|
||||
if (a4)
|
||||
param->used = true;
|
||||
return static_cast<T*>(param->data);
|
||||
}
|
||||
T* getVariable(const sead::SafeString& key, AIDefParamType type, bool a4 = true) const;
|
||||
|
||||
template <typename T>
|
||||
void setVariable(const sead::SafeString& key, AIDefParamType type, const T& val) const {
|
||||
|
@ -112,66 +113,6 @@ private:
|
|||
Param* mParams = nullptr;
|
||||
};
|
||||
|
||||
struct InlineParam {
|
||||
union {
|
||||
bool b;
|
||||
int i;
|
||||
u32 u;
|
||||
float f;
|
||||
const char* cstr;
|
||||
void* ptr;
|
||||
};
|
||||
BaseProcLink baseProcLink;
|
||||
sead::Vector3f vec3;
|
||||
MesTransceiverId mesTransceiverId;
|
||||
AIDefParamType type;
|
||||
const char* key;
|
||||
};
|
||||
KSYS_CHECK_SIZE_NX150(InlineParam, 0x50);
|
||||
|
||||
struct InlineParamPack {
|
||||
InlineParamPack() = default;
|
||||
|
||||
InlineParam& getParam(s32 idx) {
|
||||
if (idx < 0) {
|
||||
idx = count;
|
||||
if (count > NumParamsMax - 1)
|
||||
idx = 0;
|
||||
else
|
||||
count = idx + 1;
|
||||
}
|
||||
return params[idx];
|
||||
}
|
||||
|
||||
s32 findIndex(const sead::SafeString& name, AIDefParamType type) const {
|
||||
for (s32 i = 0; i < count; ++i) {
|
||||
if (params[i].type == type && name == params[i].key)
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
void addString(const char* value, const sead::SafeString& key, s32 idx);
|
||||
void addString(const sead::SafeString& value, const sead::SafeString& key, s32 idx) {
|
||||
addString(value.cstr(), key, idx);
|
||||
}
|
||||
void addInt(s32 value, const sead::SafeString& key, s32 idx);
|
||||
void addFloat(f32 value, const sead::SafeString& key, s32 idx);
|
||||
void addVec3(const sead::Vector3f& value, const sead::SafeString& key, s32 idx);
|
||||
void addBool(bool value, const sead::SafeString& key, s32 idx);
|
||||
void addUInt(u32 value, const sead::SafeString& key, s32 idx);
|
||||
void addActor(const BaseProcLink& value, const sead::SafeString& key, s32 idx);
|
||||
void addMesTransceiverId(const MesTransceiverId& value, const sead::SafeString& key, s32 idx);
|
||||
void addPointer(void* value, const sead::SafeString& key, AIDefParamType type, s32 idx);
|
||||
void acquireActor(BaseProc* proc, const sead::SafeString& key, s32 idx);
|
||||
void copyToParamPack(ParamPack& pack) const;
|
||||
|
||||
static constexpr s32 NumParamsMax = 32;
|
||||
InlineParam params[NumParamsMax];
|
||||
int count = 0;
|
||||
};
|
||||
KSYS_CHECK_SIZE_NX150(InlineParamPack, 0xA08);
|
||||
|
||||
} // namespace act::ai
|
||||
|
||||
} // namespace ksys
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "KingSystem/ActorSystem/actAiQuery.h"
|
||||
#include "KingSystem/ActorSystem/actActor.h"
|
||||
#include "KingSystem/ActorSystem/actActorParam.h"
|
||||
#include "KingSystem/ActorSystem/actAiClassDef.h"
|
||||
#include "KingSystem/ActorSystem/actAiRoot.h"
|
||||
#include "KingSystem/Resource/resResourceAIProgram.h"
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "KingSystem/ActorSystem/actAiRoot.h"
|
||||
#include "KingSystem/ActorSystem/actActor.h"
|
||||
#include "KingSystem/ActorSystem/actAiClassDef.h"
|
||||
#include "KingSystem/Utils/InitTimeInfo.h"
|
||||
|
||||
namespace ksys::act::ai {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <prim/seadTypedBitFlag.h>
|
||||
#include <thread/seadAtomic.h>
|
||||
#include "KingSystem/ActorSystem/actAiAction.h"
|
||||
#include "KingSystem/ActorSystem/actAiAi.h"
|
||||
#include "KingSystem/ActorSystem/actAiBehavior.h"
|
||||
|
|
Loading…
Reference in New Issue