mirror of
https://github.com/zeldaret/botw
synced 2026-08-11 03:25:57 -04:00
ksys/act: Start adding ai::ActionBase
This commit is contained in:
@@ -7,11 +7,14 @@
|
||||
namespace uking::action {
|
||||
|
||||
class SetInstEventFlagAction : public ksys::act::ai::Action {
|
||||
SEAD_RTTI_OVERRIDE(SetInstEventFlagAction, ksys::act::ai::Action)
|
||||
public:
|
||||
explicit SetInstEventFlagAction(const InitArg& arg);
|
||||
~SetInstEventFlagAction() override;
|
||||
|
||||
void oneShot() override;
|
||||
bool oneShot() override;
|
||||
bool init_(sead::Heap* heap) override;
|
||||
void loadParams_() override;
|
||||
};
|
||||
KSYS_CHECK_SIZE_NX150(SetInstEventFlagAction, 0x20);
|
||||
|
||||
|
||||
@@ -3,12 +3,11 @@
|
||||
|
||||
namespace uking::action {
|
||||
|
||||
SetLinkTagBasicAction::SetLinkTagBasicAction(const InitArg& arg)
|
||||
: ksys::act::ai::Action(arg) {}
|
||||
SetLinkTagBasicAction::SetLinkTagBasicAction(const InitArg& arg) : ksys::act::ai::Action(arg) {}
|
||||
|
||||
SetLinkTagBasicAction::~SetLinkTagBasicAction() = default;
|
||||
|
||||
void SetLinkTagBasicAction::enter() {
|
||||
void SetLinkTagBasicAction::enter_(ksys::act::ai::InlineParamPack* params) {
|
||||
if (IsOn.value())
|
||||
mActor->emitBasicSigOn();
|
||||
else
|
||||
@@ -17,7 +16,7 @@ void SetLinkTagBasicAction::enter() {
|
||||
setFinished();
|
||||
}
|
||||
|
||||
void SetLinkTagBasicAction::loadParams() {
|
||||
void SetLinkTagBasicAction::loadParams_() {
|
||||
getParamStatic(&IsOn, "IsOn");
|
||||
}
|
||||
|
||||
|
||||
@@ -7,12 +7,13 @@
|
||||
namespace uking::action {
|
||||
|
||||
class SetLinkTagBasicAction : public ksys::act::ai::Action {
|
||||
SEAD_RTTI_OVERRIDE(SetLinkTagBasicAction, ksys::act::ai::Action)
|
||||
public:
|
||||
explicit SetLinkTagBasicAction(const InitArg& arg);
|
||||
~SetLinkTagBasicAction() override;
|
||||
|
||||
void enter() override;
|
||||
void loadParams() override;
|
||||
void enter_(ksys::act::ai::InlineParamPack* params) override;
|
||||
void loadParams_() override;
|
||||
|
||||
private:
|
||||
ksys::act::ai::ParamRef<bool> IsOn;
|
||||
|
||||
@@ -4,8 +4,4 @@ namespace ksys::act::ai {
|
||||
|
||||
Action::Action(const InitArg& arg) : ActionBase(arg) {}
|
||||
|
||||
bool Action::isAction() {
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace ksys::act::ai
|
||||
|
||||
@@ -6,14 +6,15 @@
|
||||
namespace ksys::act::ai {
|
||||
|
||||
class Action : public ActionBase {
|
||||
SEAD_RTTI_OVERRIDE(Action, ActionBase)
|
||||
public:
|
||||
explicit Action(const InitArg& arg);
|
||||
|
||||
virtual void enter() {}
|
||||
virtual void loadParams() {}
|
||||
virtual void oneShot() {}
|
||||
void calc() override;
|
||||
bool isAction() const override { return true; }
|
||||
|
||||
bool isAction() override;
|
||||
protected:
|
||||
virtual void calc_() {}
|
||||
};
|
||||
KSYS_CHECK_SIZE_NX150(Action, 0x20);
|
||||
|
||||
|
||||
@@ -5,22 +5,26 @@ namespace ksys::act::ai {
|
||||
ActionBase::ActionBase(const InitArg& arg)
|
||||
: mActor{arg.actor}, mDefinitionIdx{u16(arg.def_idx)}, mRootIdx{u8(arg.root_idx)} {}
|
||||
|
||||
bool ActionBase::isFinished() {
|
||||
return mStatus.isOn(Status::Finished);
|
||||
bool ActionBase::isFinished() const {
|
||||
return mFlags.isOn(Flag::Finished);
|
||||
}
|
||||
|
||||
bool ActionBase::isFailed() {
|
||||
return mStatus.isOn(Status::Failed);
|
||||
bool ActionBase::isFailed() const {
|
||||
return mFlags.isOn(Flag::Failed);
|
||||
}
|
||||
|
||||
bool ActionBase::isFlag4Set() const {
|
||||
return mFlags.isOn(Flag::_4);
|
||||
}
|
||||
|
||||
void ActionBase::setFinished() {
|
||||
mStatus.set(Status::Finished);
|
||||
mStatus.reset(Status::Failed);
|
||||
mFlags.set(Flag::Finished);
|
||||
mFlags.reset(Flag::Failed);
|
||||
}
|
||||
|
||||
void ActionBase::setFailed() {
|
||||
mStatus.set(Status::Failed);
|
||||
mStatus.reset(Status::Finished);
|
||||
mFlags.set(Flag::Failed);
|
||||
mFlags.reset(Flag::Finished);
|
||||
}
|
||||
|
||||
} // namespace ksys::act::ai
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <basis/seadTypes.h>
|
||||
#include <prim/seadRuntimeTypeInfo.h>
|
||||
#include <prim/seadTypedBitFlag.h>
|
||||
#include "KingSystem/ActorSystem/actActor.h"
|
||||
#include "KingSystem/ActorSystem/actAiParam.h"
|
||||
@@ -12,7 +13,9 @@ class Actor;
|
||||
|
||||
namespace ai {
|
||||
|
||||
/// Base class for actions and AIs, which can be seen as looping actions.
|
||||
class ActionBase {
|
||||
SEAD_RTTI_BASE(ActionBase)
|
||||
public:
|
||||
struct InitArg {
|
||||
Actor* actor;
|
||||
@@ -25,9 +28,40 @@ public:
|
||||
explicit ActionBase(const InitArg& arg);
|
||||
virtual ~ActionBase() = default;
|
||||
|
||||
virtual bool isAction();
|
||||
const char* getName() const;
|
||||
bool init(sead::Heap* heap, bool load_map_or_tree_params);
|
||||
|
||||
enum class Status : u8 {
|
||||
virtual bool isFinished() const;
|
||||
virtual bool isFailed() const;
|
||||
virtual bool isFlag4Set() const;
|
||||
|
||||
virtual bool m7() { return false; }
|
||||
virtual bool m8() { return false; }
|
||||
virtual void m9() {}
|
||||
virtual bool oneShot() { return true; }
|
||||
virtual bool init_(sead::Heap* heap) { return true; }
|
||||
virtual void enter_(InlineParamPack* params) {}
|
||||
virtual bool reenter_(ActionBase* other, bool x);
|
||||
virtual void leave_() {}
|
||||
virtual void loadParams_() {}
|
||||
virtual bool m16() { return false; }
|
||||
virtual bool m17() { return false; }
|
||||
virtual bool m18() { return true; }
|
||||
virtual void m19() {}
|
||||
virtual void calc() {}
|
||||
virtual void getCurrentName(sead::BufferedSafeString* name, ActionBase* parent) const;
|
||||
virtual void* m22() { return nullptr; }
|
||||
virtual void getParams(ParamNameTypePairs* pairs, bool update_use_count) const;
|
||||
virtual s32 m24() { return 0; }
|
||||
virtual bool m25() { return true; }
|
||||
virtual ActionBase* getCurrentChild() const { return nullptr; }
|
||||
virtual bool isAction() const = 0;
|
||||
virtual bool reenter(ActionBase* other) { return reenter_(other, false); }
|
||||
virtual void postLeave() {}
|
||||
virtual ActionBase* getAction(s32 idx) const { return nullptr; }
|
||||
|
||||
protected:
|
||||
enum class Flag : u8 {
|
||||
Finished = 1,
|
||||
Failed = 2,
|
||||
_4 = 4,
|
||||
@@ -38,9 +72,6 @@ public:
|
||||
_80 = 0x80,
|
||||
};
|
||||
|
||||
protected:
|
||||
bool isFinished();
|
||||
bool isFailed();
|
||||
void setFinished();
|
||||
void setFailed();
|
||||
|
||||
@@ -51,7 +82,7 @@ protected:
|
||||
ParamPack mParams;
|
||||
u16 mDefinitionIdx;
|
||||
u8 mRootIdx;
|
||||
sead::TypedBitFlag<Status, u8> mStatus;
|
||||
sead::TypedBitFlag<Flag> mFlags;
|
||||
u16 mClassIdx;
|
||||
u16 mPrevClassIdx;
|
||||
};
|
||||
|
||||
@@ -196,7 +196,7 @@ void InlineParamPack::addMesTransceiverId(const mes::TransceiverId& value,
|
||||
param.type = AIDefParamType::MesTransceiverId;
|
||||
}
|
||||
|
||||
void ParamPack::getPairs(ParamNameTypePairs* pairs, bool update_use_count) {
|
||||
void ParamPack::getPairs(ParamNameTypePairs* pairs, bool update_use_count) const {
|
||||
for (auto* param = mParams; param; param = param->next) {
|
||||
if (param->data)
|
||||
pairs->addPair(param->type, param->name, update_use_count);
|
||||
|
||||
@@ -82,7 +82,7 @@ public:
|
||||
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);
|
||||
void getPairs(ParamNameTypePairs* pairs, bool update_use_count) const;
|
||||
|
||||
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