Exemple #1
0
//------------------------------------------------------------------------
void CScan::StartFire()
{
	if (!m_pWeapon->IsBusy())
	{
		if(m_pWeapon->GetOwnerActor())
		{
			// add the flash animation part here
			IEntity *pEntity = m_pWeapon->GetEntity();
			if(pEntity)
			{
				IEntityRenderProxy* pRenderProxy((IEntityRenderProxy*)pEntity->GetProxy(ENTITY_PROXY_RENDER));
				if (pRenderProxy)
				{
					IMaterial* pMtl(pRenderProxy->GetRenderMaterial(0));
					if (pMtl)
					{
						pMtl = pMtl->GetSafeSubMtl(2);
						if (pMtl)
						{
							const SShaderItem& shaderItem(pMtl->GetShaderItem());
							if (shaderItem.m_pShaderResources)
							{
								SEfResTexture* pTex = shaderItem.m_pShaderResources->GetTexture(0);
								if (pTex)
								{
									IDynTextureSource* pDynTexSrc = pTex->m_Sampler.m_pDynTexSource;
									if (pDynTexSrc)
									{
										IFlashPlayer* pFlashPlayer = (IFlashPlayer*) pDynTexSrc->GetSource(IDynTextureSource::DTS_I_FLASHPLAYER);
										if (pFlashPlayer)
											pFlashPlayer->Invoke0("startScan");
									}
								}
							}
						}
					}
				}
			}

			m_scanning=true;
			m_delayTimer=m_scanparams.delay;
			m_durationTimer=m_scanparams.duration;
			m_tagEntitiesDelay=m_scanparams.tagDelay;
			m_pWeapon->SetBusy(true);
		}

		m_pWeapon->PlayAction(m_scanactions.spin_up, 0, false, CItem::eIPAF_Default|CItem::eIPAF_CleanBlending);
		m_pWeapon->RequestStartFire();
		m_pWeapon->RequireUpdate(eIUS_FireMode);
	}
}
Exemple #2
0
//------------------------------------------------------------------------
void CScan::StopFire()
{
	if (!m_scanning)
		return;

	IEntity *pEntity = m_pWeapon->GetEntity();
	if(pEntity)
	{
		IEntityRenderProxy* pRenderProxy((IEntityRenderProxy*)pEntity->GetProxy(ENTITY_PROXY_RENDER));
		if (pRenderProxy)
		{
			IMaterial* pMtl(pRenderProxy->GetRenderMaterial(0));
			if (pMtl)
			{
				pMtl = pMtl->GetSafeSubMtl(2);
				if (pMtl)
				{
					const SShaderItem& shaderItem(pMtl->GetShaderItem());
					if (shaderItem.m_pShaderResources)
					{
						SEfResTexture* pTex = shaderItem.m_pShaderResources->GetTexture(0);
						if (pTex)
						{
							IDynTextureSource* pDynTexSrc = pTex->m_Sampler.m_pDynTexSource;
							if (pDynTexSrc)
							{
								IFlashPlayer* pFlashPlayer = (IFlashPlayer*) pDynTexSrc->GetSource(IDynTextureSource::DTS_I_FLASHPLAYER);
								if (pFlashPlayer)
									pFlashPlayer->Invoke0("cancelScan");
							}
						}
					}
				}
			}
		}
	}

	m_pWeapon->PlayAction(m_scanactions.spin_down, 0, false, CItem::eIPAF_Default|CItem::eIPAF_CleanBlending);

	m_scanning=false;
	m_pWeapon->SetBusy(false);
	m_pWeapon->RequestStopFire();

	if (m_scanLoopId != INVALID_SOUNDID)
	{
		m_pWeapon->StopSound(m_scanLoopId);
		m_scanLoopId = INVALID_SOUNDID;
	}
}