| 3749 | } |
| 3750 | |
| 3751 | bool Player::SetModifier(Modifier modifier, const std::shared_ptr<ActorBase>& decor) |
| 3752 | { |
| 3753 | if (_activeModifier == modifier) { |
| 3754 | return false; |
| 3755 | } |
| 3756 | |
| 3757 | if (_activeModifierDecor != nullptr) { |
| 3758 | _activeModifierDecor->OnDetach(this); |
| 3759 | _activeModifierDecor = nullptr; |
| 3760 | } |
| 3761 | |
| 3762 | switch (modifier) { |
| 3763 | case Modifier::Airboard: { |
| 3764 | _controllable = true; |
| 3765 | EndDamagingMove(); |
| 3766 | SetState(ActorState::ApplyGravitation, false); |
| 3767 | |
| 3768 | _speed.Y = 0.0f; |
| 3769 | _externalForce.Y = 0.0f; |
| 3770 | _internalForceY = 0.0f; |
| 3771 | |
| 3772 | _activeModifier = Modifier::Airboard; |
| 3773 | |
| 3774 | MoveInstantly(Vector2f(0.0f, -16.0f), MoveType::Relative); |
| 3775 | break; |
| 3776 | } |
| 3777 | case Modifier::Copter: { |
| 3778 | _controllable = true; |
| 3779 | EndDamagingMove(); |
| 3780 | SetState(ActorState::ApplyGravitation, false); |
| 3781 | |
| 3782 | _speed.Y = 0.0f; |
| 3783 | _externalForce.Y = 0.0f; |
| 3784 | _internalForceY = 0.0f; |
| 3785 | |
| 3786 | _activeModifier = Modifier::Copter; |
| 3787 | |
| 3788 | _copterFramesLeft = 10.0f * FrameTimer::FramesPerSecond; |
| 3789 | |
| 3790 | #if defined(WITH_AUDIO) |
| 3791 | if (_copterSound == nullptr) { |
| 3792 | _copterSound = PlaySfx("Copter"_s, 0.6f, 1.5f); |
| 3793 | if (_copterSound != nullptr) { |
| 3794 | _copterSound->setLooping(true); |
| 3795 | } |
| 3796 | } |
| 3797 | #endif |
| 3798 | break; |
| 3799 | } |
| 3800 | case Modifier::LizardCopter: { |
| 3801 | _controllable = true; |
| 3802 | EndDamagingMove(); |
| 3803 | SetState(ActorState::ApplyGravitation, false); |
| 3804 | |
| 3805 | _speed.Y = 0.0f; |
| 3806 | _externalForce.Y = 0.0f; |
| 3807 | _internalForceY = 0.0f; |
| 3808 |
no test coverage detected