Player: Implement PlayerStateGroundSpin (#646)

This commit is contained in:
MonsterDruide1 2025-07-01 10:28:09 +02:00 committed by GitHub
parent 901a7f6eba
commit 89ef58b41f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 111 additions and 6 deletions

View file

@ -126619,24 +126619,24 @@ Player/PlayerStateGroundSpin.o:
label:
- _ZN21PlayerStateGroundSpinC1EPN2al9LiveActorEPK19IUsePlayerCollisionPK11PlayerInputPK11PlayerConstP14PlayerAnimator
- _ZN21PlayerStateGroundSpinC2EPN2al9LiveActorEPK19IUsePlayerCollisionPK11PlayerInputPK11PlayerConstP14PlayerAnimator
status: NotDecompiled
status: Matching
- offset: 0x46edc0
size: 68
label: _ZN21PlayerStateGroundSpin6appearEv
status: NotDecompiled
status: Matching
- offset: 0x46ee04
size: 576
label: _ZN21PlayerStateGroundSpin13exeGroundSpinEv
status: NotDecompiled
status: Matching
- offset: 0x46f044
size: 36
label: _ZN21PlayerStateGroundSpinD0Ev
status: NotDecompiled
status: Matching
lazy: true
- offset: 0x46f068
size: 8
label: _ZNK12_GLOBAL__N_134PlayerStateGroundSpinNrvGroundSpin7executeEPN2al11NerveKeeperE
status: NotDecompiled
status: Matching
guess: true
Player/PlayerStateHack.o:
'.text':

View file

@ -34,8 +34,18 @@ public:
f32 calcAccelRate(f32) const;
void updatePoseUpFront(const sead::Vector3f&, const sead::Vector3f&, f32);
const sead::Vector3f& getGroundNormal() const { return mGroundNormal; }
void set_c4(bool c4) { _c4 = c4; }
private:
void* filler[0xD8 / 8];
void* _0[5];
bool _28;
sead::Vector3f mGroundNormal;
void* _38[17];
f32 _c0;
bool _c4;
void* _c8[2];
};
static_assert(sizeof(PlayerActionGroundMoveControl) == 0xD8);

View file

@ -89,6 +89,8 @@ public:
void calcMoveInput(sead::Vector3f*, const sead::Vector3f&) const;
void calcMoveDirection(sead::Vector3f*, const sead::Vector3f&) const;
bool isSpinClockwise() const;
private:
const al::LiveActor* mLiveActor;
const IUsePlayerCollision* mPlayerCollision;

View file

@ -0,0 +1,66 @@
#include "Player/PlayerStateGroundSpin.h"
#include "Library/LiveActor/ActorMovementFunction.h"
#include "Library/LiveActor/ActorPoseUtil.h"
#include "Library/Math/MathUtil.h"
#include "Library/Nerve/NerveSetupUtil.h"
#include "Library/Nerve/NerveUtil.h"
#include "Player/PlayerActionGroundMoveControl.h"
#include "Player/PlayerAnimator.h"
#include "Player/PlayerConst.h"
#include "Player/PlayerInput.h"
#include "Util/ObjUtil.h"
namespace {
NERVE_IMPL(PlayerStateGroundSpin, GroundSpin);
NERVES_MAKE_STRUCT(PlayerStateGroundSpin, GroundSpin);
} // namespace
PlayerStateGroundSpin::PlayerStateGroundSpin(al::LiveActor* parent,
const IUsePlayerCollision* collision,
const PlayerInput* input, const PlayerConst* pConst,
PlayerAnimator* animator)
: ActorStateBase("地上スピン", parent), mCollision(collision), mPlayerInput(input),
mPlayerConst(pConst), mPlayerAnimator(animator) {
mGroundMoveCtrl = new PlayerActionGroundMoveControl(parent, pConst, input, collision);
mGroundMoveCtrl->set_c4(true);
mGroundMoveCtrl->setup(0.0f, 0.0f, 0, 0, 0, 0.0f, 0.0f, 0);
initNerve(&NrvPlayerStateGroundSpin.GroundSpin, 0);
}
void PlayerStateGroundSpin::appear() {
al::ActorStateBase::appear();
mGroundMoveCtrl->appear();
mIsSpinClockwise = mPlayerInput->isSpinClockwise();
al::setNerve(this, &NrvPlayerStateGroundSpin.GroundSpin);
}
void PlayerStateGroundSpin::exeGroundSpin() {
if (al::isFirstStep(this))
mPlayerAnimator->startAnim(mIsSpinClockwise ? "SpinGroundR" : "SpinGroundL");
sead::Vector3f velocity = {0.0f, 0.0f, 0.0f};
mGroundMoveCtrl->updateNormalAndSnap(&velocity);
sead::Vector3f input = {0.0f, 0.0f, 0.0f};
mPlayerInput->calcMoveInput(&input, mGroundMoveCtrl->getGroundNormal());
velocity *= mPlayerConst->getGroundSpinBrakeRate();
f32 maxSpeed = sead::Mathf::max(velocity.length(), mPlayerConst->getGroundSpinMoveSpeedMax());
velocity += mPlayerConst->getGroundSpinAccelRate() * input;
al::limitLength(&velocity, velocity, maxSpeed);
al::setVelocity(mActor,
velocity - mGroundMoveCtrl->getGroundNormal() * mPlayerConst->getGravityMove());
sead::Vector3f frontDir = {0.0f, 0.0f, 0.0f};
if (!al::tryNormalizeOrZero(&frontDir, velocity))
al::calcFrontDir(&frontDir, mActor);
rs::slerpUpFront(mActor, sead::Vector3f::ey, frontDir, mPlayerConst->getSlerpQuatRate(), 0.0f);
if (!al::isLessStep(this, mPlayerConst->getGroundSpinFrame()))
kill();
}

View file

@ -0,0 +1,27 @@
#pragma once
#include "Library/Nerve/NerveStateBase.h"
class IUsePlayerCollision;
class PlayerInput;
class PlayerConst;
class PlayerAnimator;
class PlayerActionGroundMoveControl;
class PlayerStateGroundSpin : public al::ActorStateBase {
public:
PlayerStateGroundSpin(al::LiveActor* parent, const IUsePlayerCollision* collision,
const PlayerInput* input, const PlayerConst* pConst,
PlayerAnimator* animator);
void appear() override;
void exeGroundSpin();
private:
const IUsePlayerCollision* mCollision;
const PlayerInput* mPlayerInput;
const PlayerConst* mPlayerConst;
PlayerAnimator* mPlayerAnimator;
PlayerActionGroundMoveControl* mGroundMoveCtrl = nullptr;
bool mIsSpinClockwise = false;
};