| 601 | } |
| 602 | |
| 603 | bool SpeedboatUserControl(ItemInfo* speedboatItem, ItemInfo* laraItem) |
| 604 | { |
| 605 | auto* speedboat = GetSpeedboatInfo(speedboatItem); |
| 606 | auto* lara = GetLaraInfo(laraItem); |
| 607 | |
| 608 | bool noTurn = true; |
| 609 | int maxVelocity; |
| 610 | |
| 611 | if (speedboatItem->Pose.Position.y >= speedboat->Water - CLICK(0.5f) && speedboat->Water != NO_HEIGHT) |
| 612 | { |
| 613 | if ((!IsHeld(In::Brake) && !IsHeld(In::Look)) || speedboatItem->Animation.Velocity.z) |
| 614 | { |
| 615 | if ((IsHeld(In::Left) && !IsHeld(In::Reverse)) || (IsHeld(In::Right) && IsHeld(In::Reverse))) |
| 616 | { |
| 617 | if (speedboat->TurnRate > 0) |
| 618 | speedboat->TurnRate -= SPEEDBOAT_TURN_RATE_DECEL; |
| 619 | else |
| 620 | { |
| 621 | speedboat->TurnRate -= SPEEDBOAT_TURN_RATE_ACCEL; |
| 622 | if (speedboat->TurnRate < -SPEEDBOAT_TURN_RATE_MAX) |
| 623 | speedboat->TurnRate = -SPEEDBOAT_TURN_RATE_MAX; |
| 624 | } |
| 625 | |
| 626 | noTurn = false; |
| 627 | } |
| 628 | else if ((IsHeld(In::Right) && !IsHeld(In::Reverse)) || (IsHeld(In::Left) && IsHeld(In::Reverse))) |
| 629 | { |
| 630 | if (speedboat->TurnRate < 0) |
| 631 | speedboat->TurnRate += SPEEDBOAT_TURN_RATE_DECEL; |
| 632 | else |
| 633 | { |
| 634 | speedboat->TurnRate += SPEEDBOAT_TURN_RATE_ACCEL; |
| 635 | if (speedboat->TurnRate > SPEEDBOAT_TURN_RATE_MAX) |
| 636 | speedboat->TurnRate = SPEEDBOAT_TURN_RATE_MAX; |
| 637 | } |
| 638 | |
| 639 | noTurn = false; |
| 640 | } |
| 641 | |
| 642 | if (IsHeld(In::Reverse)) |
| 643 | { |
| 644 | if (speedboatItem->Animation.Velocity.z > 0) |
| 645 | speedboatItem->Animation.Velocity.z -= SPEEDBOAT_VELOCITY_BRAKE_DECEL; |
| 646 | else if (speedboatItem->Animation.Velocity.z > -SPEEDBOAT_REVERSE_VELOCITY_MAX) |
| 647 | speedboatItem->Animation.Velocity.z -= SPEEDBOAT_REVERSE_VELOCITY_DECEL; |
| 648 | } |
| 649 | else if (IsHeld(In::Accelerate)) |
| 650 | { |
| 651 | if (IsHeld(In::Faster)) |
| 652 | maxVelocity = SPEEDBOAT_FAST_VELOCITY_MAX; |
| 653 | else |
| 654 | maxVelocity = (IsHeld(In::Slower)) ? SPEEDBOAT_SLOW_VELOCITY_MAX : SPEEDBOAT_NORMAL_VELOCITY_MAX; |
| 655 | |
| 656 | if (speedboatItem->Animation.Velocity.z < maxVelocity) |
| 657 | speedboatItem->Animation.Velocity.z += (SPEEDBOAT_VELOCITY_ACCEL / 2) + (SPEEDBOAT_VELOCITY_ACCEL * (speedboatItem->Animation.Velocity.z / (maxVelocity * 2))); |
| 658 | else if (speedboatItem->Animation.Velocity.z > (maxVelocity + SPEEDBOAT_VELOCITY_DECEL)) |
| 659 | speedboatItem->Animation.Velocity.z -= SPEEDBOAT_VELOCITY_DECEL; |
| 660 | } |
no test coverage detected