diff options
| author | Léo Lam <leo@leolam.fr> | 2026-09-14 00:02:22 +0200 |
|---|---|---|
| committer | Léo Lam <leo@leolam.fr> | 2026-09-14 00:02:22 +0200 |
| commit | f4cd38c43b436fe91def1a1b0b3dfe0134369870 (patch) | |
| tree | 1ab07eab2ea43c0719d6b1309743715bd80cd408 /src/Game/Actor/AI/aiActorWaterDepthSelect.cpp | |
| parent | 5b26254bfe69560b0993a50d8ba8f418ae749380 (diff) | |
Actor: move all AI code under Game/Actor
Link order shows one sorted actor tree, not a separate AI project: the
Action/AI/Query folders and per-feature folders (Camera, Player, Horse,
...) come out of the same archive rounds as the actor classes.
(AI assisted using Claude Fable 5.1 and Claude Opus 5.5)
Diffstat (limited to 'src/Game/Actor/AI/aiActorWaterDepthSelect.cpp')
| -rw-r--r-- | src/Game/Actor/AI/aiActorWaterDepthSelect.cpp | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/src/Game/Actor/AI/aiActorWaterDepthSelect.cpp b/src/Game/Actor/AI/aiActorWaterDepthSelect.cpp new file mode 100644 index 00000000..50d437ca --- /dev/null +++ b/src/Game/Actor/AI/aiActorWaterDepthSelect.cpp @@ -0,0 +1,73 @@ +#include "Game/Actor/AI/aiActorWaterDepthSelect.h" +#include "KingSystem/ActorSystem/actActor.h" + +namespace uking::ai { + +ActorWaterDepthSelect::ActorWaterDepthSelect(const InitArg& arg) : ksys::act::ai::Ai(arg) {} + +ActorWaterDepthSelect::~ActorWaterDepthSelect() = default; + +bool ActorWaterDepthSelect::isChangeable() const { + return getCurrentChild()->isChangeable(); +} + +bool ActorWaterDepthSelect::isFailed() const { + return getCurrentChild()->isFailed(); +} + +bool ActorWaterDepthSelect::isFinished() const { + return getCurrentChild()->isFinished(); +} + +bool ActorWaterDepthSelect::init_(sead::Heap* heap) { + return true; +} + +void ActorWaterDepthSelect::enter_(ksys::act::ai::InlineParamPack* params) { + if (isDeep() && isUnderwater()) { + changeChild("深瀬", params); + } else { + changeChild("浅瀬", params); + } +} + +void ActorWaterDepthSelect::calc_() { + if (*mOnEnterOnly_s) + return; + + auto is_deep = isDeep() && isUnderwater(); + if (*mForceDeepChange_s && is_deep) { + if (!isCurrentChild("深瀬")) { + changeChild("深瀬"); + return; + } + } + + if (getCurrentChild()->isChangeable()) { + if (is_deep && !isCurrentChild("深瀬")) + changeChild("深瀬"); + else if (!is_deep && !isCurrentChild("浅瀬")) + changeChild("浅瀬"); + } +} + +void ActorWaterDepthSelect::leave_() { + ksys::act::ai::Ai::leave_(); +} + +void ActorWaterDepthSelect::loadParams_() { + getStaticParam(&mDeepDepth_s, "DeepDepth"); + getStaticParam(&mOnEnterOnly_s, "OnEnterOnly"); + getStaticParam(&mForceDeepChange_s, "ForceDeepChange"); +} + +bool ActorWaterDepthSelect::isDeep() const { + return 0.0 < *mDeepDepth_s && mActor->get68f().load(); +} + +bool ActorWaterDepthSelect::isUnderwater() const { + float y_w = mActor->getMtx().m[1][3]; + return mActor->get6f0() - y_w > *mDeepDepth_s; +} + +} // namespace uking::ai |
