summaryrefslogtreecommitdiff
path: root/src/KingSystem/ActorSystem/actAiInlineParam.h
blob: 06b38ba8ae3ebc75f26fb33d9a0c0d556ba7cb05 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
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