bool VAnimationComponent::Resume(const char * szAnimationName /* = NULL */, bool bLoop /* = true */, const char * szEndEventName /* = NULL*/, bool bEndEventOnce /* = true*/) { //try to resume if(m_pAnimCtrl && (szAnimationName==NULL || (m_sCurrentAnim == szAnimationName))) { int iFlags = m_pAnimCtrl->GetFlags(); bool bLoopActive = (iFlags&VANIMCTRL_LOOP)!=0; if(bLoop) { if(!bLoopActive)m_pAnimCtrl->SetFlags(iFlags|VANIMCTRL_LOOP); } else { if(bLoopActive) m_pAnimCtrl->SetFlags(iFlags&~VANIMCTRL_LOOP); } //resume if the animation is not running... if(!m_pAnimCtrl->IsPlaying()) { m_pAnimCtrl->Resume(); } //register event if specified if(szEndEventName) AddEndEvent(szEndEventName, bEndEventOnce); return true; } //just in case the user calls resume for a different animation, we rest using VAnimationComponent::Play return Play(szAnimationName, bLoop, szEndEventName, bEndEventOnce); }
bool VAnimationComponent::Play(const char * szAnimationName, bool bLoop, const char * szEndEventName, bool bEndEventOnce) { if (GetOwner() == NULL) return false; if(m_pAnimCtrl != NULL) m_pAnimCtrl->RemoveEventListener(m_pOwner); // we know, that the owner is at least a VisBaseEntity_cl, // since the component is only attachable to VisBaseEntity_cl or inherited classes m_pAnimCtrl = VisAnimConfig_cl::StartSkeletalAnimation((VisBaseEntity_cl *)m_pOwner, szAnimationName, bLoop ? VANIMCTRL_LOOP : VSKELANIMCTRL_DEFAULTS); // fall back for vertex animations if(m_pAnimCtrl == NULL) { m_pAnimCtrl = VisAnimConfig_cl::StartVertexAnimation((VisBaseEntity_cl *)m_pOwner, szAnimationName, bLoop ? VANIMCTRL_LOOP : VVERTANIMCTRL_DEFAULTS); if(m_pAnimCtrl == NULL) return false; } // register event if specified if(szEndEventName) AddEndEvent(szEndEventName, bEndEventOnce); m_pAnimCtrl->AddEventListener(m_pOwner); m_sCurrentAnim = szAnimationName; return true; }
bool VAnimationComponent::Play(const char * szAnimationName, bool bLoop, const char * szEndEventName, bool bEndEventOnce) { VisBaseEntity_cl* pOwnerEntity = vstatic_cast<VisBaseEntity_cl*>(GetOwner()); if (pOwnerEntity == NULL) return false; if(m_pAnimCtrl != NULL) m_pAnimCtrl->RemoveEventListener(m_pOwner); // we know, that the owner is at least a VisBaseEntity_cl, // since the component is only attachable to VisBaseEntity_cl or inherited classes m_pAnimCtrl = VisAnimConfig_cl::StartSkeletalAnimation(pOwnerEntity, szAnimationName, bLoop ? VANIMCTRL_LOOP : VSKELANIMCTRL_DEFAULTS); // fall back for vertex animations if(m_pAnimCtrl == NULL) { m_pAnimCtrl = VisAnimConfig_cl::StartVertexAnimation(pOwnerEntity, szAnimationName, bLoop ? VANIMCTRL_LOOP : VVERTANIMCTRL_DEFAULTS); if(m_pAnimCtrl == NULL) return false; } // register event if specified if(szEndEventName) AddEndEvent(szEndEventName, bEndEventOnce); m_pAnimCtrl->AddEventListener(m_pOwner); VisAnimConfig_cl* pAnimConfig = pOwnerEntity->GetAnimConfig(); if (pAnimConfig != NULL) { pAnimConfig->SetFlags(pAnimConfig->GetFlags() | MULTITHREADED_ANIMATION); } m_sCurrentAnim = szAnimationName; return true; }