| 1 | #include "Player/PlayerInput.h" |
| 2 | |
| 3 | #include "Library/Controller/InputFunction.h" |
| 4 | #include "Library/Controller/JoyPadAccelPoseAnalyzer.h" |
| 5 | #include "Library/LiveActor/LiveActor.h" |
| 6 | #include "Library/Math/MathUtil.h" |
| 7 | |
| 8 | #include "Player/PlayerFunction.h" |
| 9 | #include "Player/PlayerInputFunction.h" |
| 10 | #include "Util/ActorDimensionKeeper.h" |
| 11 | |
| 12 | bool PlayerInput::isEnableCarry() const { |
| 13 | if (mIsDisableInput) |
| 14 | return false; |
| 15 | |
| 16 | return PlayerInputFunction::isHoldAction(mLiveActor, |
| 17 | PlayerFunction::getPlayerInputPort(mLiveActor)); |
| 18 | } |
| 19 | |
| 20 | bool PlayerInput::isTriggerCarryStart() const { |
| 21 | if (mIsDisableInput) |
| 22 | return false; |
| 23 | |
| 24 | return PlayerInputFunction::isTriggerAction(mLiveActor, |
| 25 | PlayerFunction::getPlayerInputPort(mLiveActor)); |
| 26 | } |
| 27 | |
| 28 | bool PlayerInput::isTriggerCarryRelease() const { |
| 29 | if (mIsDisableInput) |
| 30 | return false; |
| 31 | |
| 32 | if (PlayerInputFunction::isTriggerAction(mLiveActor, |
| 33 | PlayerFunction::getPlayerInputPort(mLiveActor))) |
| 34 | return true; |
| 35 | |
| 36 | if (mIsDisableInput) |
| 37 | return false; |
| 38 | |
| 39 | return mJoyPadAccelPoseAnalyzer1->isSwingAnyHand(); |
| 40 | } |
| 41 | |
| 42 | bool PlayerInput::isTriggerSwingActionMario() const { |
| 43 | if (mIsDisableInput) |
| 44 | return false; |
| 45 | |
| 46 | return mJoyPadAccelPoseAnalyzer1->isSwingAnyHand(); |
| 47 | } |
| 48 | |
| 49 | bool PlayerInput::isTriggerCarryReleaseBySwing() const { |
| 50 | if (mIsDisableInput) |
| 51 | return false; |
| 52 | if (!PlayerInputFunction::isTriggerAction(mLiveActor, |
| 53 | PlayerFunction::getPlayerInputPort(mLiveActor))) { |
| 54 | if (mIsDisableInput) |
| 55 | return false; |
| 56 | if (!mJoyPadAccelPoseAnalyzer1->isSwingAnyHand()) |
| 57 | return false; |
| 58 | } |
| 59 | if (mIsDisableInput) |
| 60 | return false; |
| 61 | return mJoyPadAccelPoseAnalyzer1->isSwingAnyHand(); |
| 62 | } |
| 63 | |
| 64 | bool PlayerInput::isTriggerAction() const { |
| 65 | if (mIsDisableInput) |
| 66 | return false; |
| 67 | return PlayerInputFunction::isTriggerAction(mLiveActor, |
| 68 | PlayerFunction::getPlayerInputPort(mLiveActor)); |
| 69 | } |
| 70 | |
| 71 | bool PlayerInput::isTriggerJump() const { |
| 72 | if (mIsDisableInput) |
| 73 | return false; |
| 74 | auto* dimension = mDimension; |
| 75 | if (dimension && rs::is2D(dimension) && rs::isIn2DArea(dimension)) { |
| 76 | if (!mIsDisableInput && mJoyPadAccelPoseAnalyzer1->isSwingAnyHand()) |
| 77 | return true; |
| 78 | } |
| 79 | return PlayerInputFunction::isTriggerJump(mLiveActor, |
| 80 | PlayerFunction::getPlayerInputPort(mLiveActor)); |
| 81 | } |
| 82 | |
| 83 | bool PlayerInput::isTriggerHipDrop() const { |
| 84 | if (mIsDisableInput) |
| 85 | return false; |
| 86 | return PlayerInputFunction::isTriggerSubAction(mLiveActor, |
| 87 | PlayerFunction::getPlayerInputPort(mLiveActor)); |
| 88 | } |
| 89 | |
| 90 | bool PlayerInput::isTriggerHeadSliding() const { |
| 91 | if (mIsDisableInput) |
| 92 | return false; |
| 93 | if (PlayerInputFunction::isTriggerAction(mLiveActor, |
| 94 | PlayerFunction::getPlayerInputPort(mLiveActor))) |
| 95 | return true; |
| 96 | if (mIsDisableInput) |
| 97 | return false; |
| 98 | return mJoyPadAccelPoseAnalyzer1->isSwingAnyHand(); |
| 99 | } |
| 100 | |
| 101 | bool PlayerInput::isTriggerPaddle() const { |
| 102 | if (mIsDisableInput) |
| 103 | return false; |
| 104 | return PlayerInputFunction::isTriggerJump(mLiveActor, |
| 105 | PlayerFunction::getPlayerInputPort(mLiveActor)); |
| 106 | } |
| 107 | |
| 108 | bool PlayerInput::isTriggerRolling(bool a1) const { |
| 109 | if (mIsDisableInput) |
| 110 | return false; |
| 111 | if (!PlayerInputFunction::isHoldSubAction(mLiveActor, |
| 112 | PlayerFunction::getPlayerInputPort(mLiveActor)) && |
| 113 | !a1) |
| 114 | return false; |
| 115 | if (PlayerInputFunction::isTriggerAction(mLiveActor, |
| 116 | PlayerFunction::getPlayerInputPort(mLiveActor))) |
| 117 | return true; |
| 118 | if (mIsDisableInput) |
| 119 | return false; |
| 120 | return mJoyPadAccelPoseAnalyzer1->isSwingAnyHand(); |
| 121 | } |
| 122 | |
| 123 | bool PlayerInput::isTriggerRollingRestartSwing() const { |
| 124 | if (mIsDisableInput) |
| 125 | return false; |
| 126 | return mJoyPadAccelPoseAnalyzer1->isSwingAnyHand(); |
| 127 | } |
| 128 | |
| 129 | bool PlayerInput::isTriggerRollingCancelHipDrop(bool a1) const { |
| 130 | if (mIsDisableInput) |
| 131 | return false; |
| 132 | if (!PlayerInputFunction::isHoldSubAction(mLiveActor, |
| 133 | PlayerFunction::getPlayerInputPort(mLiveActor)) && |
| 134 | !a1) |
| 135 | return false; |
| 136 | if (PlayerInputFunction::isTriggerAction(mLiveActor, |
| 137 | PlayerFunction::getPlayerInputPort(mLiveActor))) |
| 138 | return true; |
| 139 | if (mIsDisableInput) |
| 140 | return false; |
| 141 | return mJoyPadAccelPoseAnalyzer1->isSwingAnyHand(); |
| 142 | } |
| 143 | |
| 144 | bool PlayerInput::isTriggerHackAction() const { |
| 145 | if (mIsDisableInput) |
| 146 | return false; |
| 147 | return PlayerInputFunction::isTriggerAction(mLiveActor, |
| 148 | PlayerFunction::getPlayerInputPort(mLiveActor)); |
| 149 | } |
| 150 | |
| 151 | bool PlayerInput::isTriggerHackJump() const { |
| 152 | if (mIsDisableInput) |
| 153 | return false; |
| 154 | return PlayerInputFunction::isTriggerJump(mLiveActor, |
| 155 | PlayerFunction::getPlayerInputPort(mLiveActor)); |
| 156 | } |
| 157 | |
| 158 | bool PlayerInput::isTriggerHackSwing() const { |
| 159 | if (mIsDisableInput) |
| 160 | return false; |
| 161 | return mJoyPadAccelPoseAnalyzer1->isSwingAnyHand(); |
| 162 | } |
| 163 | |
| 164 | bool PlayerInput::isTriggerHackEnd() const { |
| 165 | if (mIsDisableInput) |
| 166 | return false; |
| 167 | u32 inputPort = PlayerFunction::getPlayerInputPort(mLiveActor); |
| 168 | return PlayerInputFunction::isTriggerSubAction(mLiveActor, inputPort); |
| 169 | } |
| 170 | |
| 171 | bool PlayerInput::isTriggerHackSeparateJump() const { |
| 172 | if (mIsDisableInput) |
| 173 | return false; |
| 174 | if (!rs::isSeparatePlay(mLiveActor)) |
| 175 | return false; |
| 176 | s32 inputPort = al::getPlayerControllerPort(index: 1); |
| 177 | return PlayerInputFunction::isTriggerJump(mLiveActor, inputPort); |
| 178 | } |
| 179 | |
| 180 | bool PlayerInput::isTriggerSeparateCapJangoHelp() const { |
| 181 | if (mIsDisableInput) |
| 182 | return false; |
| 183 | if (!rs::isSeparatePlay(mLiveActor)) |
| 184 | return false; |
| 185 | s32 inputPort = al::getPlayerControllerPort(index: 1); |
| 186 | return PlayerInputFunction::isTriggerAction(mLiveActor, inputPort) || |
| 187 | PlayerInputFunction::isTriggerJump(mLiveActor, inputPort) || |
| 188 | PlayerInputFunction::isTriggerSubAction(mLiveActor, inputPort); |
| 189 | } |
| 190 | |
| 191 | bool PlayerInput::isHoldHackSeparateJump() const { |
| 192 | if (mIsDisableInput) |
| 193 | return false; |
| 194 | if (!rs::isSeparatePlay(mLiveActor)) |
| 195 | return false; |
| 196 | s32 inputPort = al::getPlayerControllerPort(index: 1); |
| 197 | return PlayerInputFunction::isHoldJump(mLiveActor, inputPort); |
| 198 | } |
| 199 | |
| 200 | bool PlayerInput::isTriggerGetOff() const { |
| 201 | if (mIsDisableInput) |
| 202 | return false; |
| 203 | return PlayerInputFunction::isTriggerSubAction(mLiveActor, |
| 204 | PlayerFunction::getPlayerInputPort(mLiveActor)); |
| 205 | } |
| 206 | |
| 207 | bool PlayerInput::isHoldAction() const { |
| 208 | if (mIsDisableInput) |
| 209 | return false; |
| 210 | return PlayerInputFunction::isHoldAction(mLiveActor, |
| 211 | PlayerFunction::getPlayerInputPort(mLiveActor)); |
| 212 | } |
| 213 | |
| 214 | bool PlayerInput::isHoldJump() const { |
| 215 | if (mIsDisableInput) |
| 216 | return false; |
| 217 | auto* dimension = mDimension; |
| 218 | if (dimension && rs::is2D(dimension) && rs::isIn2DArea(dimension) && _88 > 0) |
| 219 | return true; |
| 220 | return PlayerInputFunction::isHoldJump(mLiveActor, |
| 221 | PlayerFunction::getPlayerInputPort(mLiveActor)); |
| 222 | } |
| 223 | |
| 224 | bool PlayerInput::isHoldHipDrop() const { |
| 225 | if (mIsDisableInput) |
| 226 | return false; |
| 227 | return PlayerInputFunction::isHoldSubAction(mLiveActor, |
| 228 | PlayerFunction::getPlayerInputPort(mLiveActor)); |
| 229 | } |
| 230 | |
| 231 | bool PlayerInput::isTriggerStartTalk() const { |
| 232 | if (mIsDisableInput) |
| 233 | return false; |
| 234 | return PlayerInputFunction::isTriggerTalk(mLiveActor, |
| 235 | PlayerFunction::getPlayerInputPort(mLiveActor)); |
| 236 | } |
| 237 | |
| 238 | bool PlayerInput::isTriggerStartWorldWarp() const { |
| 239 | if (mIsDisableInput) |
| 240 | return false; |
| 241 | return PlayerInputFunction::isTriggerStartWorldWarp( |
| 242 | mLiveActor, PlayerFunction::getPlayerInputPort(mLiveActor)); |
| 243 | } |
| 244 | |
| 245 | bool PlayerInput::isTriggerCancelWorldWarp() const { |
| 246 | if (mIsDisableInput) |
| 247 | return false; |
| 248 | return PlayerInputFunction::isTriggerCancelWorldWarp( |
| 249 | mLiveActor, PlayerFunction::getPlayerInputPort(mLiveActor)); |
| 250 | } |
| 251 | |
| 252 | bool PlayerInput::isTriggerSpinCap() const { |
| 253 | if (mIsDisableInput) |
| 254 | return false; |
| 255 | u32 inputPort = PlayerFunction::getPlayerInputPort(mLiveActor); |
| 256 | if (PlayerInputFunction::isTriggerAction(mLiveActor, inputPort)) |
| 257 | return true; |
| 258 | if (mIsDisableInput) |
| 259 | return false; |
| 260 | return mJoyPadAccelPoseAnalyzer1->isSwingAnyHand(); |
| 261 | } |
| 262 | |
| 263 | bool PlayerInput::isTriggerToggleStayCap() const { |
| 264 | if (mIsDisableInput) |
| 265 | return false; |
| 266 | if (!rs::isSeparatePlay(mLiveActor)) |
| 267 | return false; |
| 268 | s32 inputPort = al::getPlayerControllerPort(index: 1); |
| 269 | return PlayerInputFunction::isTriggerAction(mLiveActor, inputPort); |
| 270 | } |
| 271 | |
| 272 | bool PlayerInput::isTriggerSpinAttackSeparate() const { |
| 273 | if (mIsDisableInput) |
| 274 | return false; |
| 275 | if (!rs::isSeparatePlay(mLiveActor)) |
| 276 | return false; |
| 277 | if (!mIsDisableInput && mJoyPadAccelPoseAnalyzer1->isSwingAnyHand()) |
| 278 | return true; |
| 279 | return PlayerInputFunction::isTriggerAction(mLiveActor, al::getPlayerControllerPort(index: 0)); |
| 280 | } |
| 281 | |
| 282 | s32 PlayerInput::getSeparatePlay1P() { |
| 283 | return al::getPlayerControllerPort(index: 0); |
| 284 | } |
| 285 | |
| 286 | bool PlayerInput::isTriggerCapReturn() const { |
| 287 | if (mIsDisableInput) |
| 288 | return false; |
| 289 | if (!rs::isSeparatePlay(mLiveActor)) { |
| 290 | if (mIsDisableInput) |
| 291 | return false; |
| 292 | u32 inputPort = PlayerFunction::getPlayerInputPort(mLiveActor); |
| 293 | if (PlayerInputFunction::isTriggerAction(mLiveActor, inputPort)) |
| 294 | return true; |
| 295 | if (mIsDisableInput) |
| 296 | return false; |
| 297 | return mJoyPadAccelPoseAnalyzer1->isSwingAnyHand(); |
| 298 | } |
| 299 | if (mIsDisableInput || !rs::isSeparatePlay(mLiveActor)) |
| 300 | return false; |
| 301 | s32 inputPort = al::getPlayerControllerPort(index: 1); |
| 302 | if (PlayerInputFunction::isTriggerAction(mLiveActor, inputPort)) |
| 303 | return true; |
| 304 | if (mIsDisableInput || !rs::isSeparatePlay(mLiveActor)) |
| 305 | return false; |
| 306 | return mJoyPadAccelPoseAnalyzer2->isSwingAnyHand(); |
| 307 | } |
| 308 | |
| 309 | bool PlayerInput::isTriggerCapAttackSeparate() const { |
| 310 | if (mIsDisableInput || !rs::isSeparatePlay(mLiveActor)) |
| 311 | return false; |
| 312 | s32 inputPort = al::getPlayerControllerPort(index: 1); |
| 313 | if (PlayerInputFunction::isTriggerAction(mLiveActor, inputPort)) |
| 314 | return true; |
| 315 | if (mIsDisableInput || !rs::isSeparatePlay(mLiveActor)) |
| 316 | return false; |
| 317 | return mJoyPadAccelPoseAnalyzer2->isSwingAnyHand(); |
| 318 | } |
| 319 | |
| 320 | bool PlayerInput::isTriggerSwingActionCap() const { |
| 321 | if (mIsDisableInput || !rs::isSeparatePlay(mLiveActor)) |
| 322 | return false; |
| 323 | return mJoyPadAccelPoseAnalyzer2->isSwingAnyHand(); |
| 324 | } |
| 325 | |
| 326 | bool PlayerInput::isTriggerCapSingleHandThrow() const { |
| 327 | if (mIsDisableInput) |
| 328 | return false; |
| 329 | return mJoyPadAccelPoseAnalyzer1->isSwingAnyHand(); |
| 330 | } |
| 331 | |
| 332 | bool PlayerInput::isTriggerCapDoubleHandThrow() const { |
| 333 | if (mIsDisableInput) |
| 334 | return false; |
| 335 | return mJoyPadAccelPoseAnalyzer1->isSwingDoubleHandSameDir(); |
| 336 | } |
| 337 | |
| 338 | bool PlayerInput::isTriggerCapSeparateJump() const { |
| 339 | if (mIsDisableInput) |
| 340 | return false; |
| 341 | if (!rs::isSeparatePlay(mLiveActor)) |
| 342 | return false; |
| 343 | s32 inputPort = al::getPlayerControllerPort(index: 1); |
| 344 | return PlayerInputFunction::isTriggerJump(mLiveActor, inputPort); |
| 345 | } |
| 346 | |
| 347 | bool PlayerInput::isTriggerCapSeparateHipDrop() const { |
| 348 | if (mIsDisableInput) |
| 349 | return false; |
| 350 | if (!rs::isSeparatePlay(mLiveActor)) |
| 351 | return false; |
| 352 | s32 inputPort = al::getPlayerControllerPort(index: 1); |
| 353 | return PlayerInputFunction::isTriggerSubAction(mLiveActor, inputPort); |
| 354 | } |
| 355 | |
| 356 | bool PlayerInput::isTriggerSwingPoleClimbFast() const { |
| 357 | if (mIsDisableInput) |
| 358 | return false; |
| 359 | return mJoyPadAccelPoseAnalyzer1->isSwingAnyHand(); |
| 360 | } |
| 361 | |
| 362 | bool PlayerInput::isHoldPoleClimbDown() const { |
| 363 | if (mIsDisableInput) |
| 364 | return false; |
| 365 | return PlayerInputFunction::isHoldSubAction(mLiveActor, |
| 366 | PlayerFunction::getPlayerInputPort(mLiveActor)); |
| 367 | } |
| 368 | |
| 369 | bool PlayerInput::isTriggerAppendCapAttack(bool a1) const { |
| 370 | if (mIsDisableInput) |
| 371 | return false; |
| 372 | if (!rs::isSeparatePlay(mLiveActor) || a1) { |
| 373 | if (mIsDisableInput) |
| 374 | return false; |
| 375 | return mJoyPadAccelPoseAnalyzer1->isSwingAnyHand(); |
| 376 | } |
| 377 | if (mIsDisableInput || !rs::isSeparatePlay(mLiveActor)) |
| 378 | return false; |
| 379 | return mJoyPadAccelPoseAnalyzer2->isSwingAnyHand(); |
| 380 | } |
| 381 | |
| 382 | bool PlayerInput::isHoldSpinCap() const { |
| 383 | if (mIsDisableInput || rs::isSeparatePlay(mLiveActor)) |
| 384 | return false; |
| 385 | return PlayerInputFunction::isHoldAction(mLiveActor, |
| 386 | PlayerFunction::getPlayerInputPort(mLiveActor)); |
| 387 | } |
| 388 | |
| 389 | bool PlayerInput::isHoldCapAction() const { |
| 390 | if (mIsDisableInput) |
| 391 | return false; |
| 392 | if (rs::isSeparatePlay(mLiveActor)) |
| 393 | return !PlayerInputFunction::isTriggerAction(mLiveActor, al::getPlayerControllerPort(index: 1)); |
| 394 | return PlayerInputFunction::isHoldAction(mLiveActor, |
| 395 | PlayerFunction::getPlayerInputPort(mLiveActor)); |
| 396 | } |
| 397 | |
| 398 | bool PlayerInput::isHoldPoleClimbFast() const { |
| 399 | if (mIsDisableInput) |
| 400 | return false; |
| 401 | return PlayerInputFunction::isHoldAction(mLiveActor, |
| 402 | PlayerFunction::getPlayerInputPort(mLiveActor)); |
| 403 | } |
| 404 | |
| 405 | bool PlayerInput::isHoldWallCatchMoveFast() const { |
| 406 | if (mIsDisableInput) |
| 407 | return false; |
| 408 | return PlayerInputFunction::isHoldAction(mLiveActor, |
| 409 | PlayerFunction::getPlayerInputPort(mLiveActor)); |
| 410 | } |
| 411 | |
| 412 | bool PlayerInput::isHoldHackAction() const { |
| 413 | if (mIsDisableInput) |
| 414 | return false; |
| 415 | return PlayerInputFunction::isHoldAction(mLiveActor, |
| 416 | PlayerFunction::getPlayerInputPort(mLiveActor)); |
| 417 | } |
| 418 | |
| 419 | bool PlayerInput::isHoldHackJump() const { |
| 420 | if (mIsDisableInput) |
| 421 | return false; |
| 422 | return PlayerInputFunction::isHoldJump(mLiveActor, |
| 423 | PlayerFunction::getPlayerInputPort(mLiveActor)); |
| 424 | } |
| 425 | |
| 426 | bool PlayerInput::isTriggerChange2D() const { |
| 427 | if (mIsDisableInput) |
| 428 | return false; |
| 429 | u32 inputPort = PlayerFunction::getPlayerInputPort(mLiveActor); |
| 430 | return al::isPadTriggerZL(port: inputPort) || al::isPadTriggerZR(port: inputPort); |
| 431 | } |
| 432 | |
| 433 | bool PlayerInput::isTriggerChange3D() const { |
| 434 | if (mIsDisableInput) |
| 435 | return false; |
| 436 | u32 inputPort = PlayerFunction::getPlayerInputPort(mLiveActor); |
| 437 | return al::isPadTriggerZL(port: inputPort) || al::isPadTriggerZR(port: inputPort); |
| 438 | } |
| 439 | |
| 440 | bool PlayerInput::isReleaseJump() const { |
| 441 | if (mIsDisableInput) |
| 442 | return false; |
| 443 | return PlayerInputFunction::isReleaseJump(mLiveActor, |
| 444 | PlayerFunction::getPlayerInputPort(mLiveActor)); |
| 445 | } |
| 446 | |
| 447 | bool PlayerInput::isReleaseHackAction() const { |
| 448 | if (mIsDisableInput) |
| 449 | return false; |
| 450 | return PlayerInputFunction::isReleaseAction(mLiveActor, |
| 451 | PlayerFunction::getPlayerInputPort(mLiveActor)); |
| 452 | } |
| 453 | |
| 454 | bool PlayerInput::isReleaseHackJump() const { |
| 455 | if (mIsDisableInput) |
| 456 | return false; |
| 457 | return PlayerInputFunction::isReleaseJump(mLiveActor, |
| 458 | PlayerFunction::getPlayerInputPort(mLiveActor)); |
| 459 | } |
| 460 | |
| 461 | bool PlayerInput::isEnableDashInput() const { |
| 462 | if (mIsDisableInput) |
| 463 | return false; |
| 464 | return PlayerInputFunction::isHoldAction(mLiveActor, |
| 465 | PlayerFunction::getPlayerInputPort(mLiveActor)); |
| 466 | } |
| 467 | |
| 468 | bool PlayerInput::isThrowTypeSpiral(const sead::Vector2f& a1) const { |
| 469 | if (al::isNearZero(vec: a1, tolerance: 0.001)) |
| 470 | return false; |
| 471 | f32 absX = (a1.x > 0 ? a1.x : -a1.x); |
| 472 | f32 absY = (a1.y > 0 ? a1.y : -a1.y); |
| 473 | return absX > absY; |
| 474 | } |
| 475 | |
| 476 | bool PlayerInput::isThrowTypeRolling(const sead::Vector2f& a1) const { |
| 477 | if (al::isNearZero(vec: a1, tolerance: 0.001)) |
| 478 | return !al::isNearZero(value: a1.y, tolerance: 0.001); |
| 479 | f32 absX = (a1.x > 0 ? a1.x : -a1.x); |
| 480 | f32 absY = (a1.y > 0 ? a1.y : -a1.y); |
| 481 | return !(absX > absY) && !al::isNearZero(value: a1.y, tolerance: 0.001); |
| 482 | } |
| 483 | |