summaryrefslogtreecommitdiff
path: root/src/KingSystem/System/NXArgs.h
blob: 6ba6696e3188aaea7df51246063b413622fa2da9 (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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#pragma once

#include <basis/seadNew.h>
#include <container/seadBuffer.h>
#include <heap/seadDisposer.h>
#include <heap/seadExpHeap.h>
#include <math/seadVector.h>
#include <nn/oe.h>
#include <prim/seadSafeString.h>
#include "KingSystem/Utils/Types.h"

namespace ksys {

class nxargs {
    SEAD_SINGLETON_DISPOSER(nxargs)
    nxargs() : mResField4{0}, mResField6{0}, mType{ArgsType::None}, mNumEntries{0} {}
    virtual ~nxargs();

public:
    enum class LaunchParamFlag : u8 {
        None = 0,
        HasDropActor = 1,
        _2 = 2,
    };

    struct LaunchParamEntrySpawnCondition {
        u32 resfield0;
        u32 resfield8;
        u8 resfield4;
        u8 resfield5;
    };

    enum class LaunchParamEntryConditionDataType : u8 {
        None = 0,
        Bool = 1,
        S32 = 2,
        F32 = 3,
    };

    enum class ActorEntryConditionOperation : u8 {
        None = 0,
        Eq = 1,
        NotEq = 2,
        Gt = 3,
        Gte = 4,
        Lt = 5,
        Lte = 6,
    };

    struct LaunchParamEntryCondition {
        s32 flagNameHash;
        f32 rhsValue;
        LaunchParamEntryConditionDataType flagDataType;
        ActorEntryConditionOperation operation;
    };

    struct LaunchParamEntry {
        u32 actorNameHash;
        u32 dropActorNameHash;
        sead::Vector3f positionOffset;
        sead::Vector3f rotation;
        sead::Vector3f velocity;
        LaunchParamFlag flags{};
        u8 numConditions;
        sead::Buffer<LaunchParamEntryCondition> conditions;
    };

    KSYS_CHECK_SIZE_NX150(LaunchParamEntry, 0x40);

    enum class ArgsType : u8 {
        None = 0,
        CreateActors = 1,
    };

    struct ResLaunchParamDataHeader {
        char magic[4];
        u16 _4;
        u8 _6;
        ArgsType type;
        u32 padding;
        u8 numEntries;
        u8 padding2[3];
    };

    void init(sead::Heap* heap);
    void allocEntries(sead::Heap* heap, const u8* data);
    void handleArgs();

private:
    u16 mResField4;
    u8 mResField6;
    ArgsType mType;
    u8 mNumEntries;
    sead::Buffer<LaunchParamEntry> mEntries;
    bool mHasHandledArgs = false;
};
KSYS_CHECK_SIZE_NX150(nxargs, 0x48);

}  // namespace ksys