diff options
| author | Léo Lam <leo@leolam.fr> | 2020-12-09 17:17:25 +0100 |
|---|---|---|
| committer | Léo Lam <leo@leolam.fr> | 2020-12-09 18:11:24 +0100 |
| commit | fcbe17a3f0db98bdafdfd917210b03019de2d31f (patch) | |
| tree | 90c949cab5c91d11a5d62b600b4cd7f33e7d7a61 /src/KingSystem/ActorSystem | |
| parent | cd10f3774bd1e08dd7126958303730407158dd79 (diff) | |
ksys/act: Start adding RootAi
Diffstat (limited to 'src/KingSystem/ActorSystem')
| -rw-r--r-- | src/KingSystem/ActorSystem/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | src/KingSystem/ActorSystem/actActor.h | 9 | ||||
| -rw-r--r-- | src/KingSystem/ActorSystem/actAiAction.cpp | 3 | ||||
| -rw-r--r-- | src/KingSystem/ActorSystem/actAiAi.cpp | 3 | ||||
| -rw-r--r-- | src/KingSystem/ActorSystem/actAiBehavior.cpp | 3 | ||||
| -rw-r--r-- | src/KingSystem/ActorSystem/actAiQuery.cpp | 3 | ||||
| -rw-r--r-- | src/KingSystem/ActorSystem/actAiRoot.cpp | 19 | ||||
| -rw-r--r-- | src/KingSystem/ActorSystem/actAiRoot.h | 87 |
8 files changed, 128 insertions, 1 deletions
diff --git a/src/KingSystem/ActorSystem/CMakeLists.txt b/src/KingSystem/ActorSystem/CMakeLists.txt index 2d47558e..97df84d5 100644 --- a/src/KingSystem/ActorSystem/CMakeLists.txt +++ b/src/KingSystem/ActorSystem/CMakeLists.txt @@ -35,6 +35,8 @@ target_sources(uking PRIVATE actAiParam.h actAiQuery.cpp actAiQuery.h + actAiRoot.cpp + actAiRoot.h actAttention.cpp actAttention.h actBaseProc.cpp diff --git a/src/KingSystem/ActorSystem/actActor.h b/src/KingSystem/ActorSystem/actActor.h index 2fa71ca5..b910671a 100644 --- a/src/KingSystem/ActorSystem/actActor.h +++ b/src/KingSystem/ActorSystem/actActor.h @@ -8,6 +8,10 @@ namespace ksys { namespace act { +namespace ai { +class RootAi; +} + class LifeRecoverInfo; class ActorParam; @@ -39,7 +43,10 @@ public: const sead::TypedBitFlag<StasisFlag>& getStasisFlags() const { return mStasisFlags; } protected: - /* 0x008 */ u8 TEMP_0x008[0x3F4]; // FIXME + /* 0x180 */ u8 TEMP_0x180[0x3D8]; // FIXME + /* 0x558 */ ai::RootAi* mRootAi; + /* 0x560 */ void* mASList; // FIXME + /* 0x568 */ void* mEffects; // FIXME /* 0x570 */ ActorParam* mActorParam; /* 0x578 */ u8 TEMP_0x578[0x648 - 0x578]; /* 0x648 */ map::MubinIter mMapObjIter; diff --git a/src/KingSystem/ActorSystem/actAiAction.cpp b/src/KingSystem/ActorSystem/actAiAction.cpp index 674a2e39..742605ad 100644 --- a/src/KingSystem/ActorSystem/actAiAction.cpp +++ b/src/KingSystem/ActorSystem/actAiAction.cpp @@ -1,4 +1,5 @@ #include "KingSystem/ActorSystem/actAiAction.h" +#include "KingSystem/ActorSystem/actAiRoot.h" namespace ksys::act::ai { @@ -8,4 +9,6 @@ void Action::calc() { calc_(); } +template class ClassContainer<Action>; + } // namespace ksys::act::ai diff --git a/src/KingSystem/ActorSystem/actAiAi.cpp b/src/KingSystem/ActorSystem/actAiAi.cpp index d22e5c82..5dee7b68 100644 --- a/src/KingSystem/ActorSystem/actAiAi.cpp +++ b/src/KingSystem/ActorSystem/actAiAi.cpp @@ -1,4 +1,5 @@ #include "KingSystem/ActorSystem/actAiAi.h" +#include "KingSystem/ActorSystem/actAiRoot.h" namespace ksys::act::ai { @@ -44,4 +45,6 @@ void Ai::updateChildIdx(u16 new_idx) { mPendingChildIdx = InvalidIdx; } +template class ClassContainer<Ai>; + } // namespace ksys::act::ai diff --git a/src/KingSystem/ActorSystem/actAiBehavior.cpp b/src/KingSystem/ActorSystem/actAiBehavior.cpp index ea86c732..c6e5b327 100644 --- a/src/KingSystem/ActorSystem/actAiBehavior.cpp +++ b/src/KingSystem/ActorSystem/actAiBehavior.cpp @@ -1,8 +1,11 @@ #include "KingSystem/ActorSystem/actAiBehavior.h" +#include "KingSystem/ActorSystem/actAiRoot.h" namespace ksys::act::ai { Behavior::Behavior(const InitArg& arg) : mActor(arg.actor), mDefIdx(static_cast<u16>(arg.def_idx)) {} +template class ClassContainer<Behavior>; + } // namespace ksys::act::ai diff --git a/src/KingSystem/ActorSystem/actAiQuery.cpp b/src/KingSystem/ActorSystem/actAiQuery.cpp index f38ab676..ca97fc67 100644 --- a/src/KingSystem/ActorSystem/actAiQuery.cpp +++ b/src/KingSystem/ActorSystem/actAiQuery.cpp @@ -1,7 +1,10 @@ #include "KingSystem/ActorSystem/actAiQuery.h" +#include "KingSystem/ActorSystem/actAiRoot.h" namespace ksys::act::ai { Query::Query(const InitArg& arg) : mActor(arg.actor), mDefIdx(arg.def_idx) {} +template class ClassContainer<Query>; + } // namespace ksys::act::ai diff --git a/src/KingSystem/ActorSystem/actAiRoot.cpp b/src/KingSystem/ActorSystem/actAiRoot.cpp new file mode 100644 index 00000000..041ab86c --- /dev/null +++ b/src/KingSystem/ActorSystem/actAiRoot.cpp @@ -0,0 +1,19 @@ +#include "KingSystem/ActorSystem/actAiRoot.h" + +namespace ksys::act::ai { + +RootAi::RootAi(const InitArg& arg) : Ai(arg) { + mBehaviorsByStopAndCalcTiming[0].fill({}); + mBehaviorsByStopAndCalcTiming[1].fill({}); +} + +RootAi::~RootAi() { + mQueries.finalize(); + mBehaviors.finalize(); + mAis.finalize(); + mActions.finalize(); + if (_140) + delete _140; +} + +} // namespace ksys::act::ai diff --git a/src/KingSystem/ActorSystem/actAiRoot.h b/src/KingSystem/ActorSystem/actAiRoot.h new file mode 100644 index 00000000..e80ec01b --- /dev/null +++ b/src/KingSystem/ActorSystem/actAiRoot.h @@ -0,0 +1,87 @@ +#pragma once + +#include "KingSystem/ActorSystem/actAiAi.h" +#include "KingSystem/ActorSystem/actAiParam.h" +#include "KingSystem/Utils/Types.h" + +namespace ksys::act::ai { + +class Action; +class Ai; +class Behavior; +class Query; + +class IRootAi { +public: + virtual ~IRootAi() = default; +}; + +template <typename Class> +class ClassContainer { +public: + ClassContainer(); + ~ClassContainer(); + + void finalize(); + +private: + sead::Buffer<Class> classes; + // TODO: rename + sead::Buffer<Class> x; + // TODO: rename + sead::Buffer<Class> y; +}; + +class RootAi : public Ai, public IRootAi { + SEAD_RTTI_OVERRIDE(RootAi, Ai) +public: + explicit RootAi(const InitArg& arg); + ~RootAi() override; + + bool isFlag4Set() const override { return true; } + bool init_(sead::Heap* heap) override; + void enter_(InlineParamPack* params) override; + void leave_() override; + bool m16() override; + void calc() override; + + const ParamPack& getMapUnitParams() const { return mMapUnitParams; } + const ParamPack& getAiTreeParams() const { return mAiTreeParams; } + +private: + // TODO: rename and put this in a different translation unit + struct SomeStruct { + SomeStruct(); + virtual ~SomeStruct(); + + void* _8{}; + }; + KSYS_CHECK_SIZE_NX150(SomeStruct, 0x10); + + void calc_() override; + + f32 _40 = 1.0; + u32 _44{}; + ClassContainer<Action> mActions; + ClassContainer<Ai> mAis; + ClassContainer<Behavior> mBehaviors; + ClassContainer<Query> mQueries; + sead::SafeArray<Behavior*, 3> mBehaviorsByStopAndCalcTiming[2]{}; + void* _138{}; + SomeStruct* _140{}; + u32 mMA_I{}; + u16 mAt{}; + u8 _14e{}; + void* _150{}; + void* _158{}; + void* _160{}; + // TODO: is this really an atomic? + sead::Atomic<f32> _168 = 1.0; + u16 _16c{}; + u16 _16e{}; + ParamPack mMapUnitParams; + ParamPack mAiTreeParams; +}; +KSYS_CHECK_SIZE_NX150(RootAi, 0x180); + +} // namespace ksys::act::ai |
