summaryrefslogtreecommitdiff
path: root/src/KingSystem/Resource/Actor/resResourceASResource.h
blob: 4b07bde66f2a8bfa048568f2f25833c9933c9312 (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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
#pragma once

#include <container/seadBuffer.h>
#include <prim/seadRuntimeTypeInfo.h>
#include <utility/aglParameterList.h>
#include <utility/aglResParameter.h>
#include "KingSystem/Resource/Actor/resResourceASResourceExtension.h"

namespace ksys::res {

class AS;

class ASResource {
    SEAD_RTTI_BASE(ASResource)
public:
    struct ParseArgs {
        agl::utl::ResParameterList list;
        sead::Heap* heap;
        AS* as;
        int index;
    };

    ASResource(int type_index, int index) : mTypeIndex(type_index), mIndex(index) {}
    virtual ~ASResource() = default;

    bool parse(const ParseArgs& args);

    virtual int m4() { return 0; }
    virtual int m5() { return 0; }
    virtual int m6() { return 1; }
    virtual int m7() { return 0; }

    static const sead::SafeString& getDefaultStr();
    static ASResource* make(const ParseArgs& args);

    u16 getTypeIndex() const { return mTypeIndex; }
    u16 getIndex() const { return mIndex; }
    int findStringIndex(const sead::SafeString& value) const;
    int findIntIndex(int value) const;

    agl::utl::ParameterList& getList() { return mList; }

protected:
    virtual bool doParse(const ParseArgs& args) { return true; }

    u16 mTypeIndex{};
    u16 mIndex{};
    agl::utl::ParameterList mList;
    ASExtensions mExtensions;
};

class ASResourceWithChildren : public ASResource {
    SEAD_RTTI_OVERRIDE(ASResourceWithChildren, ASResource)
public:
    using ASResource::ASResource;
    ~ASResourceWithChildren() override;
    ASResourceWithChildren(const ASResourceWithChildren&) = delete;
    auto operator=(const ASResourceWithChildren&) = delete;

    int m4() override { return callOnChildren_(&ASResource::m4); }
    int m5() override { return callOnChildren_(&ASResource::m5); }
    int m6() override { return callOnChildren_(&ASResource::m6) + 1; }

protected:
    using MemberFunction = int (ASResource::*)();

    bool doParse(const ParseArgs& args) override;
    virtual int callOnChildren_(MemberFunction fn);

    sead::Buffer<ASResource*> mChildren;
};

class ASSequencePlayContainerResource : public ASResourceWithChildren {
    SEAD_RTTI_OVERRIDE(ASSequencePlayContainerResource, ASResourceWithChildren)
public:
    using ASResourceWithChildren::ASResourceWithChildren;

    const auto& getSequenceLoop() const { return *mSequenceLoop; }
    float getValue(int index) const;

protected:
    bool doParse(const ParseArgs& args) override;
    int callOnChildren_(MemberFunction fn) override;
    int m7() override;

    agl::utl::ParameterObj mObj;
    agl::utl::Parameter<bool> mSequenceLoop;
};

class ASSelectorResource : public ASResourceWithChildren {
    SEAD_RTTI_OVERRIDE(ASSelectorResource, ASResourceWithChildren)
public:
    using ASResourceWithChildren::ASResourceWithChildren;

    const auto& getNoSync() const { return *mNoSync; }
    const auto& getJudgeOnce() const { return *mJudgeOnce; }

protected:
    bool doParse(const ParseArgs& args) override;
    int callOnChildren_(MemberFunction fn) override;

    agl::utl::ParameterObj mObj;
    agl::utl::Parameter<bool> mNoSync;
    agl::utl::Parameter<bool> mJudgeOnce;
};

class ASBlenderResource : public ASResourceWithChildren {
    SEAD_RTTI_OVERRIDE(ASBlenderResource, ASResourceWithChildren)
public:
    using ASResourceWithChildren::ASResourceWithChildren;

    const auto& getNoSync() const { return *mNoSync; }
    const auto& getJudgeOnce() const { return *mJudgeOnce; }
    const auto& getInputLimit() const { return *mInputLimit; }

protected:
    bool doParse(const ParseArgs& args) override;
    int callOnChildren_(MemberFunction fn) override;

    agl::utl::ParameterObj mObj;
    agl::utl::Parameter<bool> mNoSync;
    agl::utl::Parameter<bool> mJudgeOnce;
    agl::utl::Parameter<float> mInputLimit;
};

class ASAssetResource : public ASResource {
    SEAD_RTTI_OVERRIDE(ASAssetResource, ASResource)
public:
    using ASResource::ASResource;

    const sead::SafeString& getFileName() const { return *mFileName; }

protected:
    bool doParse(const ParseArgs& args) override;

    agl::utl::ParameterObj mObj;
    agl::utl::Parameter<sead::SafeString> mFileName;
};

class ASAssetExResource : public ASAssetResource {
    SEAD_RTTI_OVERRIDE(ASAssetExResource, ASAssetResource)
public:
    using ASAssetResource::ASAssetResource;

protected:
    int m5() override { return 1; }
};

class ASSkeltalAssetResource : public ASAssetResource {
    SEAD_RTTI_OVERRIDE(ASSkeltalAssetResource, ASAssetResource)
public:
    using ASAssetResource::ASAssetResource;

    const auto& getInitAnmDriven() const { return *mInitAnmDriven; }
    const auto& getMorph() const { return *mMorph; }
    const auto& getResetMorph() const { return *mResetMorph; }

protected:
    bool doParse(const ParseArgs& args) override;

    agl::utl::Parameter<int> mInitAnmDriven;
    agl::utl::Parameter<float> mMorph;
    agl::utl::Parameter<float> mResetMorph;
};

}  // namespace ksys::res