| 1 | #include "Player/PlayerJudgeWallPush.h" |
| 2 | |
| 3 | #include "Library/LiveActor/ActorPoseUtil.h" |
| 4 | #include "Library/Math/MathUtil.h" |
| 5 | |
| 6 | #include "Player/PlayerInput.h" |
| 7 | #include "Util/PlayerCollisionUtil.h" |
| 8 | #include "Util/PlayerUtil.h" |
| 9 | |
| 10 | PlayerJudgeWallPush::PlayerJudgeWallPush(const al::LiveActor* player, |
| 11 | const IUsePlayerCollision* collider, |
| 12 | const PlayerInput* input) |
| 13 | : mPlayer(player), mCollider(collider), mInput(input) {} |
| 14 | |
| 15 | void PlayerJudgeWallPush::reset() {} |
| 16 | |
| 17 | void PlayerJudgeWallPush::update() {} |
| 18 | |
| 19 | bool PlayerJudgeWallPush::judge() const { |
| 20 | if (rs::isPlayerCarrySomething(mPlayer) || !rs::isCollidedGround(mCollider) || |
| 21 | !rs::isCollidedWall(mCollider) || rs::isActionCodeNoActionWall(mCollider)) |
| 22 | return false; |
| 23 | |
| 24 | const sead::Vector3f& collidedGroundNormal = rs::getCollidedGroundNormal(mCollider); |
| 25 | const sead::Vector3f& collidedWallNormal = rs::getCollidedWallNormal(mCollider); |
| 26 | |
| 27 | if (sead::Mathf::abs(x: collidedGroundNormal.dot(t: collidedWallNormal)) > 0.17365f) // cos(80°) |
| 28 | return false; |
| 29 | |
| 30 | sead::Vector3f front = {0.0f, 0.0f, 0.0f}; |
| 31 | al::calcFrontDir(front: &front, actor: mPlayer); |
| 32 | al::verticalizeVec(out: &front, vertical: collidedGroundNormal, vec: front); |
| 33 | if (!al::tryNormalizeOrZero(out: &front)) |
| 34 | return false; |
| 35 | |
| 36 | if (front.dot(t: -collidedWallNormal) < 0.70711f || !mInput->isMove()) // cos(45°) |
| 37 | return false; |
| 38 | |
| 39 | sead::Vector3f up = {0.0f, 0.0f, 0.0f}; |
| 40 | al::calcUpDir(up: &up, actor: mPlayer); |
| 41 | sead::Vector3f moveDirection = {0.0f, 0.0f, 0.0f}; |
| 42 | mInput->calcMoveDirection(&moveDirection, up); |
| 43 | return !(moveDirection.dot(t: front) < 0.70711f); // cos(45°) |
| 44 | } |
| 45 | |