| 1 | #include "Player/PlayerJudgeTalkGround.h" |
| 2 | |
| 3 | #include <math/seadVector.h> |
| 4 | |
| 5 | #include "Library/LiveActor/ActorMovementFunction.h" |
| 6 | #include "Library/LiveActor/ActorPoseUtil.h" |
| 7 | #include "Library/Math/MathUtil.h" |
| 8 | |
| 9 | #include "Player/IPlayerModelChanger.h" |
| 10 | #include "Player/PlayerCarryKeeper.h" |
| 11 | #include "Player/PlayerConst.h" |
| 12 | #include "Player/PlayerHackKeeper.h" |
| 13 | #include "Player/PlayerInput.h" |
| 14 | #include "Player/PlayerStateWait.h" |
| 15 | #include "Util/PlayerCollisionUtil.h" |
| 16 | |
| 17 | PlayerJudgeTalkGround::PlayerJudgeTalkGround( |
| 18 | const al::LiveActor* playerActor, const IPlayerModelChanger* playerModelChanger, |
| 19 | const PlayerHackKeeper* playerHackKeeper, const PlayerCarryKeeper* playerCarryKeeper, |
| 20 | const IUsePlayerCollision* playerCollider, const PlayerInput* playerInput, |
| 21 | const PlayerConst* playerConst, const PlayerStateWait* playerStateWait) |
| 22 | : mPlayerActor(playerActor), mPlayerModelChanger(playerModelChanger), |
| 23 | mPlayerHackKeeper(playerHackKeeper), mPlayerCarryKeeper(playerCarryKeeper), |
| 24 | mCollider(playerCollider), mPlayerInput(playerInput), mPlayerConst(playerConst), |
| 25 | mPlayerStateWait(playerStateWait) {} |
| 26 | |
| 27 | bool PlayerJudgeTalkGround::judge() const { |
| 28 | auto* currentHackActor = mPlayerHackKeeper->getCurrentHackActor(); |
| 29 | if (mPlayerHackKeeper->getUnkHitSensor()) { |
| 30 | if (!rs::isPlayerOnGround(currentHackActor) || mPlayerInput->isMove()) |
| 31 | return false; |
| 32 | |
| 33 | return !(mPlayerConst->getNormalMaxSpeed() * 0.65f < al::calcSpeedH(actor: currentHackActor)); |
| 34 | } |
| 35 | |
| 36 | if (mPlayerModelChanger->is2DModel() || !rs::isOnGround(mPlayerActor, mCollider) || |
| 37 | rs::isJustLand(mCollider) || |
| 38 | (!mPlayerStateWait->isDead() && !mPlayerStateWait->isEnableCancelAction()) || |
| 39 | mPlayerInput->isMove() || mPlayerCarryKeeper->isThrowHold()) |
| 40 | return false; |
| 41 | |
| 42 | const sead::Vector3f& gravity = rs::isJustLand(mCollider) ? |
| 43 | al::getGravity(actor: mPlayerActor) : |
| 44 | rs::getCollidedGroundNormal(mCollider); |
| 45 | sead::Vector3f velocity = al::getVelocity(actor: mPlayerActor); |
| 46 | al::verticalizeVec(out: &velocity, vertical: gravity, vec: velocity); |
| 47 | return !(mPlayerConst->getNormalMaxSpeed() * 0.65f < velocity.length()); |
| 48 | } |
| 49 | |