Exemple #1
0
ALERROR CDisintegrationEffect::Create (CSystem *pSystem,
				const CVector &vPos,
				const CVector &vVel,
				const CObjectImageArray &MaskImage,
				int iMaskTick,
				int iMaskRotation,
				CDisintegrationEffect **retpEffect)

//	Create
//
//	Creates a new effects object

	{
	DEBUG_TRY

	ALERROR error;
	CDisintegrationEffect *pEffect;

	pEffect = new CDisintegrationEffect;
	if (pEffect == NULL)
		return ERR_MEMORY;

	pEffect->Place(vPos, vVel);

	ASSERT(MaskImage.GetBitmapUNID());
	pEffect->m_MaskImage = MaskImage;
	pEffect->m_iMaskTick = iMaskTick;
	pEffect->m_iMaskRotation = iMaskRotation;
	pEffect->m_iTick = 0;

	ASSERT(pEffect->m_iMaskTick == 0);
	ASSERT(pEffect->m_iMaskRotation < pEffect->m_MaskImage.GetRotationCount() && pEffect->m_iMaskRotation >= 0);

	//	Create the particles

	pEffect->m_iParticleCount = PARTICLE_COUNT;
	pEffect->m_pParticles = new SParticle [pEffect->m_iParticleCount];
	for (int i = 0; i < pEffect->m_iParticleCount; i++)
		{
		SParticle *pParticle = &pEffect->m_pParticles[i];
		pEffect->InitParticle(pParticle);
		}

	//	Add to system

	if (error = pEffect->AddToSystem(pSystem))
		{
		delete pEffect;
		return error;
		}

	//	Done

	if (retpEffect)
		*retpEffect = pEffect;

	return NOERROR;

	DEBUG_CATCH
	}