mirror of
https://github.com/zeldaret/botw
synced 2026-09-01 09:23:13 -04:00
ksys/act: Finish ParamPack
This commit is contained in:
@@ -65,7 +65,7 @@ enum class CalcTiming {
|
||||
struct AIDef {
|
||||
union Value {
|
||||
Value() {}
|
||||
u8 raw[16];
|
||||
std::array<u8, 16> raw;
|
||||
const char* str;
|
||||
s32 i;
|
||||
f32 f;
|
||||
|
||||
@@ -54,6 +54,30 @@ ParamPack::~ParamPack() {
|
||||
}
|
||||
}
|
||||
|
||||
bool ParamPack::load(const Actor& actor, const ParamNameTypePairs& pairs, s32 count,
|
||||
sead::Heap* heap) {
|
||||
AIDef def;
|
||||
def.no_stop = false;
|
||||
def.trigger_action = false;
|
||||
def.dynamic_param_child = false;
|
||||
def._24b = false;
|
||||
def.num_params = 0;
|
||||
def.calc_timing = CalcTiming::AIAfter;
|
||||
|
||||
for (s32 i = 0; i < pairs.count; ++i) {
|
||||
const auto& pair = pairs.pairs[i];
|
||||
if (pair.use_count < count) {
|
||||
def.param_names[def.num_params] = pair.name;
|
||||
def.param_types[def.num_params] = pair.type;
|
||||
def.param_values[def.num_params].vec3 = {0, 0, 0};
|
||||
def.param_values[def.num_params].variable_ptr = nullptr;
|
||||
++def.num_params;
|
||||
}
|
||||
}
|
||||
|
||||
return load(actor, def, heap, AIDefInstParamKind::Dynamic);
|
||||
}
|
||||
|
||||
void* ParamPack::getAITreeVariablePointer(const sead::SafeString& key, AIDefParamType type,
|
||||
bool x) const {
|
||||
return getVariable<void>(key, type, x);
|
||||
@@ -172,6 +196,34 @@ void InlineParamPack::addMesTransceiverId(const mes::TransceiverId& value,
|
||||
param.type = AIDefParamType::MesTransceiverId;
|
||||
}
|
||||
|
||||
void ParamPack::getPairs(ParamNameTypePairs* pairs, bool update_use_count) {
|
||||
for (auto* param = mParams; param; param = param->next) {
|
||||
if (param->data)
|
||||
pairs->addPair(param->type, param->name, update_use_count);
|
||||
}
|
||||
}
|
||||
|
||||
void ParamNameTypePairs::addPair(AIDefParamType type, const sead::SafeString& name,
|
||||
bool update_use_count) {
|
||||
for (s32 i = 0; i < count; ++i) {
|
||||
auto& pair = pairs[i];
|
||||
if (pair.type == type && name == pair.name) {
|
||||
if (update_use_count)
|
||||
++pair.use_count;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (count >= pairs.size())
|
||||
return;
|
||||
|
||||
auto& pair = pairs[count];
|
||||
pair.type = type;
|
||||
pair.name = name.cstr();
|
||||
pair.use_count = 1;
|
||||
++count;
|
||||
}
|
||||
|
||||
bool ParamPack::getString(sead::SafeString* value, const sead::SafeString& key) const {
|
||||
auto* str = getVariable<sead::SafeString>(key, AIDefParamType::String, false);
|
||||
if (!str)
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#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>
|
||||
@@ -24,6 +25,21 @@ namespace act::ai {
|
||||
|
||||
struct InlineParamPack;
|
||||
|
||||
struct ParamNameType {
|
||||
const char* name;
|
||||
AIDefParamType type;
|
||||
s32 use_count;
|
||||
};
|
||||
KSYS_CHECK_SIZE_NX150(ParamNameType, 0x10);
|
||||
|
||||
struct ParamNameTypePairs {
|
||||
void addPair(AIDefParamType type, const sead::SafeString& name, bool update_use_count);
|
||||
|
||||
sead::SafeArray<ParamNameType, 32> pairs;
|
||||
s32 count;
|
||||
};
|
||||
KSYS_CHECK_SIZE_NX150(ParamNameTypePairs, 0x208);
|
||||
|
||||
struct Param {
|
||||
Param* next;
|
||||
u32 hash;
|
||||
@@ -63,8 +79,10 @@ public:
|
||||
*variable = val;
|
||||
}
|
||||
|
||||
bool load(const Actor& actor, const ParamNameTypePairs& pairs, s32 count, sead::Heap* heap);
|
||||
void* getAITreeVariablePointer(const sead::SafeString& key, AIDefParamType type, bool x) const;
|
||||
void copy(InlineParamPack* dest, bool x);
|
||||
void getPairs(ParamNameTypePairs* pairs, bool update_use_count);
|
||||
|
||||
bool getString(sead::SafeString* value, const sead::SafeString& key) const;
|
||||
bool setString(const sead::SafeString& value, const sead::SafeString& key) const;
|
||||
|
||||
Reference in New Issue
Block a user