Exemple #1
0
//------------------------------------------------------------------------
bool CItem::PlayFragment(IAction* pAction, float speedOverride, float timeOverride, float animWeight, float ffeedbackWeight, bool concentratedFire)
{
    _smart_ptr<IAction> pActionPtr(pAction);

    CRY_ASSERT(pAction);
    if(!pAction)
        {
            return false;
        }

    CWeapon *pWeapon = static_cast<CWeapon*>(GetIWeapon());
    if (pWeapon && pWeapon->IsProxyWeapon())
        {
            return false;
        }

    bool success = false;

    float speed = (float)__fsel(-speedOverride, 1.0f, speedOverride);
    FragmentID fragID = pAction->GetFragmentID();
    pAction->SetSubContext(m_subContext);
    IActionController *pActionController = GetActionController();
    if ((fragID != FRAGMENT_ID_INVALID) && pActionController)
        {
            float fragmentDuration, transitionDuration;
            if (pActionController->QueryDuration(*pAction, fragmentDuration, transitionDuration))
                {
                    float duration = fragmentDuration+transitionDuration;
                    if ((duration > 0.0f) && (timeOverride > 0.0f))
                        {
                            speed = (duration / timeOverride);
                            CRY_ASSERT((speed > 0.0f) && (speed < 99999.0f));
                        }

                    if(duration > 0.f)
                        {
                            m_animationTime[eIGS_Owner] = (uint32) MAX((duration*1000.0f/speed) - 20, 0.0f);
                        }

                    pAction->SetSpeedBias(speed);
                    pAction->SetAnimWeight(animWeight);

                    if(concentratedFire)
                        {
                            pAction->SetParam(CItem::sActionParamCRCs.concentratedFire, 1.f);
                        }

                    if(ffeedbackWeight != 1.f)
                        {
                            pAction->SetParam(CItem::sActionParamCRCs.ffeedbackScale, ffeedbackWeight);
                        }

                    pActionController->Queue(pAction);

                    success = true;
                }
        }

    return success;
}