Enemy: Implement FlyerStateWander (#229)

This commit is contained in:
Fuzzy2319 2025-01-13 12:21:25 +01:00 committed by GitHub
parent fd52e56e84
commit 218aa8d613
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 133 additions and 9 deletions

View file

@ -6622,14 +6622,14 @@ Address,Quality,Size,Name
0x0000007100101338,U,000072,_ZNK12_GLOBAL__N_125FireBrosFireBallNrvAttach7executeEPN2al11NerveKeeperE
0x0000007100101380,U,000020,_ZN15FlyerStateParamC2Ev
0x0000007100101394,U,000012,_ZN15FlyerStateParamC2Eff
0x00000071001013a0,U,000288,_ZN21FlyerStateWanderParamC2EiiiPKcPKN2al14ActorParamMoveE
0x00000071001014c0,U,000092,_ZN16FlyerStateWanderC1EPN2al9LiveActorEPK21FlyerStateWanderParam
0x000000710010151c,U,000016,_ZN16FlyerStateWander6appearEv
0x000000710010152c,U,000204,_ZN16FlyerStateWander9exeWanderEv
0x00000071001015f8,U,000124,_ZN16FlyerStateWander7exeWaitEv
0x0000007100101674,U,000036,_ZN16FlyerStateWanderD0Ev
0x0000007100101698,U,000008,_ZNK12_GLOBAL__N_125FlyerStateWanderNrvWander7executeEPN2al11NerveKeeperE
0x00000071001016a0,U,000128,_ZNK12_GLOBAL__N_123FlyerStateWanderNrvWait7executeEPN2al11NerveKeeperE
0x00000071001013a0,O,000288,_ZN21FlyerStateWanderParamC2EiiiPKcPKN2al14ActorParamMoveE
0x00000071001014c0,O,000092,_ZN16FlyerStateWanderC1EPN2al9LiveActorEPK21FlyerStateWanderParam
0x000000710010151c,O,000016,_ZN16FlyerStateWander6appearEv
0x000000710010152c,O,000204,_ZN16FlyerStateWander9exeWanderEv
0x00000071001015f8,O,000124,_ZN16FlyerStateWander7exeWaitEv
0x0000007100101674,O,000036,_ZN16FlyerStateWanderD0Ev
0x0000007100101698,O,000008,_ZNK12_GLOBAL__N_125FlyerStateWanderNrvWander7executeEPN2al11NerveKeeperE
0x00000071001016a0,O,000128,_ZNK12_GLOBAL__N_123FlyerStateWanderNrvWait7executeEPN2al11NerveKeeperE
0x0000007100101720,U,000316,_ZN7GabuZouC2EPKc
0x000000710010185c,U,000328,_ZN7GabuZouC1EPKc
0x00000071001019a4,U,000808,_ZN7GabuZou4initERKN2al13ActorInitInfoE

Can't render this file because it is too large.

View file

@ -8,7 +8,7 @@
namespace al {
class LiveActor;
class HitSensor;
class ActorParamMove;
struct ActorParamMove;
void resetPosition(LiveActor* actor);
void resetPosition(LiveActor* actor, const sead::Vector3f& trans);

View file

@ -0,0 +1,13 @@
#pragma once
#include <basis/seadTypes.h>
namespace al {
struct ActorParamMove {
public:
f32 _0;
f32 _4;
f32 _8;
f32 _c;
};
} // namespace al

View file

@ -0,0 +1,59 @@
#include "Enemy/FlyerStateWander.h"
#include "Library/LiveActor/ActorActionFunction.h"
#include "Library/LiveActor/ActorMovementFunction.h"
#include "Library/LiveActor/ActorParamMove.h"
#include "Library/LiveActor/ActorPoseKeeper.h"
#include "Library/Math/MathRandomUtil.h"
#include "Library/Nerve/NerveSetupUtil.h"
namespace {
NERVE_IMPL(FlyerStateWander, Wander)
NERVE_IMPL(FlyerStateWander, Wait)
NERVES_MAKE_NOSTRUCT(FlyerStateWander, Wander, Wait)
} // namespace
FlyerStateWanderParam::FlyerStateWanderParam(s32 ukn, s32 wanderTime, s32 waitTime,
const char* actionName,
const al::ActorParamMove* actorParamMove)
: _0(ukn), mWanderTime(wanderTime), mWaitTime(waitTime), mActionName(actionName),
mActorParamMove(actorParamMove) {}
FlyerStateWander::FlyerStateWander(al::LiveActor* actor, const FlyerStateWanderParam* param)
: al::ActorStateBase("飛行型うろつき状態", actor), mFlyerStateWanderParam(param) {
initNerve(&Wander, 0);
}
void FlyerStateWander::appear() {
setDead(false);
al::setNerve(this, &Wander);
}
void FlyerStateWander::exeWander() {
if (al::isFirstStep(this)) {
mStartTrans.set(al::getTrans(mActor));
al::startAction(mActor, mFlyerStateWanderParam->getActionName());
mNerveTime = mFlyerStateWanderParam->getWanderTime() +
mFlyerStateWanderParam->get_0() * al::getRandom(3);
}
const al::ActorParamMove* actorParamMove = mFlyerStateWanderParam->getActorParamMove();
al::flyAndTurnToTarget(mActor, mStartTrans, actorParamMove->_0, actorParamMove->_4,
actorParamMove->_8, actorParamMove->_c);
if (al::isGreaterEqualStep(this, mNerveTime))
al::setNerve(this, &Wait);
}
void FlyerStateWander::exeWait() {
if (al::isFirstStep(this)) {
mNerveTime = mFlyerStateWanderParam->getWaitTime() +
mFlyerStateWanderParam->get_0() * al::getRandom(3);
}
al::setVelocityZero(mActor);
if (al::isGreaterEqualStep(this, mNerveTime))
al::setNerve(this, &Wander);
}

View file

@ -0,0 +1,52 @@
#pragma once
#include <math/seadVector.h>
#include <prim/seadSafeString.h>
#include "Library/Nerve/NerveStateBase.h"
namespace al {
struct ActorParamMove;
}
class FlyerStateWanderParam {
public:
FlyerStateWanderParam(s32, s32 wanderTime, s32 waitTime, const char* actionName,
const al::ActorParamMove* actorParamMove);
s32 get_0() const { return _0; }
s32 getWanderTime() const { return mWanderTime; }
s32 getWaitTime() const { return mWaitTime; }
const char* getActionName() const { return mActionName.cstr(); }
const al::ActorParamMove* getActorParamMove() const { return mActorParamMove; }
private:
s32 _0;
s32 mWanderTime;
s32 mWaitTime;
sead::FixedSafeString<32> mActionName;
const al::ActorParamMove* mActorParamMove;
};
static_assert(sizeof(FlyerStateWanderParam) == 0x50);
class FlyerStateWander : public al::ActorStateBase {
public:
FlyerStateWander(al::LiveActor* actor, const FlyerStateWanderParam* param);
void appear() override;
void exeWander();
void exeWait();
private:
s32 mNerveTime = 0;
sead::Vector3f mStartTrans = {0.0f, 0.0f, 0.0f};
const FlyerStateWanderParam* mFlyerStateWanderParam;
};
static_assert(sizeof(FlyerStateWander) == 0x38);