| 1 | #include "Player/PlayerJudgeWallCatch.h" |
| 2 | |
| 3 | #include "Library/Collision/CollisionParts.h" |
| 4 | #include "Library/LiveActor/ActorPoseUtil.h" |
| 5 | #include "Library/Math/MathUtil.h" |
| 6 | |
| 7 | #include "Player/IPlayerModelChanger.h" |
| 8 | #include "Player/PlayerCarryKeeper.h" |
| 9 | #include "Player/PlayerConst.h" |
| 10 | #include "Player/PlayerCounterForceRun.h" |
| 11 | #include "Player/PlayerExternalVelocity.h" |
| 12 | #include "Player/PlayerInput.h" |
| 13 | #include "Player/PlayerTrigger.h" |
| 14 | #include "Util/ObjUtil.h" |
| 15 | #include "Util/PlayerCollisionUtil.h" |
| 16 | |
| 17 | PlayerJudgeWallCatch::PlayerJudgeWallCatch(const al::LiveActor* player, const PlayerConst* pConst, |
| 18 | const IUsePlayerCollision* collider, |
| 19 | const IPlayerModelChanger* modelChanger, |
| 20 | const PlayerCarryKeeper* carryKeeper, |
| 21 | const PlayerExternalVelocity* externalVelocity, |
| 22 | const PlayerInput* input, const PlayerTrigger* trigger, |
| 23 | const PlayerCounterForceRun* counterForceRun) |
| 24 | : mPlayer(player), mConst(pConst), mCollision(collider), mModelChanger(modelChanger), |
| 25 | mCarryKeeper(carryKeeper), mExternalVelocity(externalVelocity), mInput(input), |
| 26 | mTrigger(trigger), mCounterForceRun(counterForceRun) {} |
| 27 | |
| 28 | void PlayerJudgeWallCatch::reset() { |
| 29 | mIsJudge = false; |
| 30 | mPosition = {0.0f, 0.0f, 0.0f}; |
| 31 | mCollidedWallNormal = {0.0f, 0.0f, 0.0f}; |
| 32 | mNormalAtPos = {0.0f, 0.0f, 0.0f}; |
| 33 | } |
| 34 | |
| 35 | void PlayerJudgeWallCatch::update() { |
| 36 | mIsJudge = false; |
| 37 | if (mCarryKeeper->isCarry() || mModelChanger->is2DModel() || mCounterForceRun->isForceRun() || |
| 38 | mExternalVelocity->isExistForce() || !rs::isCollidedWall(mCollision) || |
| 39 | rs::isCollidedGround(mCollision) || rs::isActionCodeNoWallGrab(mCollision)) |
| 40 | return; |
| 41 | |
| 42 | sead::Vector3f facingDir = {0.0f, 0.0f, 0.0f}; |
| 43 | if (mTrigger->isOn(PlayerTrigger::EActionTrigger_val30)) { |
| 44 | if (!mInput->isMoveDeepDown()) |
| 45 | return; |
| 46 | sead::Vector3f moveDir = {0.0f, 0.0f, 0.0f}; |
| 47 | mInput->calcMoveInput(&moveDir, -al::getGravity(actor: mPlayer)); |
| 48 | al::normalize(out: &facingDir, vec: moveDir); |
| 49 | } else { |
| 50 | al::calcFrontDir(front: &facingDir, actor: mPlayer); |
| 51 | } |
| 52 | |
| 53 | mCollidedWallPart = rs::getCollidedWallCollisionParts(mCollision); |
| 54 | sead::Vector3f movePower = {0.0f, 0.0f, 0.0f}; |
| 55 | mCollidedWallPart->calcForceMovePower(&movePower, rs::getCollidedWallPos(mCollision)); |
| 56 | sead::Vector3f finalWallPos = rs::getCollidedWallPos(mCollision) + movePower; |
| 57 | mCollidedWallNormal.set(rs::getCollidedWallNormal(mCollision)); |
| 58 | |
| 59 | mIsJudge = rs::findWallCatchPos( |
| 60 | &mCollidedWallPart, &mPosition, &mNormalAtPos, mPlayer, facingDir, finalWallPos, |
| 61 | mCollidedWallNormal, mConst->getWallKeepDegree(), mConst->getWallCatchDegree(), |
| 62 | mConst->getWallCatchHeightEdgeTop(), 0.0f, mConst->getWallCatchHeightBottom(), |
| 63 | mConst->getCollisionRadius(), mConst->getCollisionRadiusStand()); |
| 64 | } |
| 65 | |
| 66 | bool PlayerJudgeWallCatch::judge() const { |
| 67 | return mIsJudge; |
| 68 | } |
| 69 | |