diff --git a/data/odyssey_functions.csv b/data/odyssey_functions.csv index 2a5b6dbe2..d291eb29d 100644 --- a/data/odyssey_functions.csv +++ b/data/odyssey_functions.csv @@ -27974,10 +27974,10 @@ Address,Quality,Size,Name 0x000000710045b6f4,U,000108,_ZNK23PlayerJudgeStartRolling21isTriggerRestartSwingEv 0x000000710045b760,U,000004,_ZN23PlayerJudgeStartRolling5resetEv 0x000000710045b764,U,000004,_ZN23PlayerJudgeStartRolling6updateEv -0x000000710045b768,U,000028,_ZN19PlayerJudgeStartRunC1EPKN2al9LiveActorEPK11PlayerConstPK19IUsePlayerCollisionPK11PlayerInputPK21PlayerCounterForceRunPK6IJudge -0x000000710045b784,U,000124,_ZNK19PlayerJudgeStartRun5judgeEv -0x000000710045b800,U,000004,_ZN19PlayerJudgeStartRun5resetEv -0x000000710045b804,U,000004,_ZN19PlayerJudgeStartRun6updateEv +0x000000710045b768,O,000028,_ZN19PlayerJudgeStartRunC1EPKN2al9LiveActorEPK11PlayerConstPK19IUsePlayerCollisionPK11PlayerInputPK21PlayerCounterForceRunPK6IJudge +0x000000710045b784,W,000124,_ZNK19PlayerJudgeStartRun5judgeEv +0x000000710045b800,O,000004,_ZN19PlayerJudgeStartRun5resetEv +0x000000710045b804,O,000004,_ZN19PlayerJudgeStartRun6updateEv 0x000000710045b808,U,000028,_ZN22PlayerJudgeStartRunOldC1EPKN2al9LiveActorEPK19IUsePlayerCollisionPK11PlayerInput 0x000000710045b824,U,000008,_ZN22PlayerJudgeStartRunOld5resetEv 0x000000710045b82c,U,000084,_ZN22PlayerJudgeStartRunOld6updateEv diff --git a/src/Player/PlayerCounterForceRun.h b/src/Player/PlayerCounterForceRun.h index 0ea60c34a..83af7452c 100644 --- a/src/Player/PlayerCounterForceRun.h +++ b/src/Player/PlayerCounterForceRun.h @@ -9,6 +9,7 @@ class PlayerCounterForceRun { void setupForceRun(s32 frames, f32 speed); void update(); + bool isForceRun() const { return mCounter > 0; } s32 getCounter() const { return mCounter; } f32 getSpeed() const { return mSpeed; } diff --git a/src/Player/PlayerInput.h b/src/Player/PlayerInput.h index 971c2992e..417e6b013 100644 --- a/src/Player/PlayerInput.h +++ b/src/Player/PlayerInput.h @@ -74,6 +74,8 @@ class PlayerInput { bool isThrowTypeSpiral(const sead::Vector2f&) const; bool isThrowTypeRolling(const sead::Vector2f&) const; + bool isMove() const; + private: const al::LiveActor* mLiveActor; const IUsePlayerCollision* mPlayerCollision; diff --git a/src/Player/PlayerJudgeStartRun.cpp b/src/Player/PlayerJudgeStartRun.cpp new file mode 100644 index 000000000..78f911cef --- /dev/null +++ b/src/Player/PlayerJudgeStartRun.cpp @@ -0,0 +1,29 @@ +#include "Player/PlayerJudgeStartRun.h" +#include "Player/PlayerCounterForceRun.h" +#include "Player/PlayerInput.h" +#include "Util/PlayerCollisionUtil.h" +#include "Util/StageSceneFunction.h" + +PlayerJudgeStartRun::PlayerJudgeStartRun(const al::LiveActor* player, const PlayerConst* pConst, + const IUsePlayerCollision* collision, + const PlayerInput* input, + const PlayerCounterForceRun* counterForceRun, + const IJudge* judgeWaterSurfaceRun) + : mPlayer(player), mCollision(collision), mInput(input), mCounterForceRun(counterForceRun), + mJudgeForceLand(judgeWaterSurfaceRun) {} + +bool PlayerJudgeStartRun::judge() const { + if (!rs::isCollidedGround(mCollision)) + return false; + if (mCounterForceRun->isForceRun()) + return true; + if (rs::isJudge(mJudgeForceLand)) + return false; + if (mInput->isMove()) + return true; + return rs::isAutoRunOnGroundSkateCode(mPlayer, mCollision, 0.5f); +} + +void PlayerJudgeStartRun::reset() {} + +void PlayerJudgeStartRun::update() {} diff --git a/src/Player/PlayerJudgeStartRun.h b/src/Player/PlayerJudgeStartRun.h new file mode 100644 index 000000000..e27b8b4c2 --- /dev/null +++ b/src/Player/PlayerJudgeStartRun.h @@ -0,0 +1,32 @@ +#pragma once + +#include + +#include "Player/IJudge.h" + +namespace al { +class LiveActor; +} +class IUsePlayerCollision; +class PlayerConst; +class PlayerInput; +class PlayerCounterForceRun; + +class PlayerJudgeStartRun : public IJudge { +public: + PlayerJudgeStartRun(const al::LiveActor* player, const PlayerConst* pConst, + const IUsePlayerCollision* collision, const PlayerInput* input, + const PlayerCounterForceRun* counterForceRun, + const IJudge* judgeWaterSurfaceRun); + + void reset() override; + void update() override; + bool judge() const override; + +private: + const al::LiveActor* mPlayer; + const IUsePlayerCollision* mCollision; + const PlayerInput* mInput; + const PlayerCounterForceRun* mCounterForceRun; + const IJudge* mJudgeForceLand; +}; diff --git a/src/Util/PlayerCollisionUtil.h b/src/Util/PlayerCollisionUtil.h index 043e6cd91..a92b9b490 100644 --- a/src/Util/PlayerCollisionUtil.h +++ b/src/Util/PlayerCollisionUtil.h @@ -2,10 +2,18 @@ #include +namespace al { +class LiveActor; +} class IUsePlayerHeightCheck; +class IUsePlayerCollision; namespace rs { f32 getGroundHeight(const IUsePlayerHeightCheck*); -} +bool isCollidedGround(const IUsePlayerCollision*); + +bool isAutoRunOnGroundSkateCode(const al::LiveActor*, const IUsePlayerCollision*, float); + +} // namespace rs