当前位置: 首页>>代码示例>>C++>>正文


C++ CEffectCreator类代码示例

本文整理汇总了C++中CEffectCreator的典型用法代码示例。如果您正苦于以下问题:C++ CEffectCreator类的具体用法?C++ CEffectCreator怎么用?C++ CEffectCreator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CEffectCreator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: CreateBeamEffect

ALERROR CEffectCreator::CreateBeamEffect (SDesignLoadCtx &Ctx, CXMLElement *pDesc, const CString &sUNID, CEffectCreator **retpCreator)

//	CreateBeamEffect
//
//	Create a beam effect

	{
	ALERROR error;

	//	Create the effect

	CEffectCreator *pCreator = new CBeamEffectCreator;
	pCreator->m_sUNID = sUNID;

	//	Type-specific creation

	if (error = pCreator->OnEffectCreateFromXML(Ctx, pDesc, sUNID))
		return error;

	//	Done

	*retpCreator = pCreator;

	return NOERROR;
	}
开发者ID:Sdw195,项目名称:Transcendence,代码行数:25,代码来源:CEffectCreator.cpp

示例2: CreateSimpleFromXML

ALERROR CEffectCreator::CreateSimpleFromXML (SDesignLoadCtx &Ctx, CXMLElement *pDesc, const CString &sUNID, CEffectCreator **retpCreator)

//	CreateSimpleFromXML
//
//	Creates the creator from an XML element

	{
	ALERROR error;
	CEffectCreator *pCreator;

	//	Create the effect based on the tag

	if (error = CreateFromTag(pDesc->GetTag(), &pCreator))
		{
		Ctx.sError = strPatternSubst(CONSTLIT("Invalid painter tag: %s"), pDesc->GetTag());
		return error;
		}

	if (pCreator == NULL)
		return ERR_MEMORY;

	pCreator->m_sUNID = sUNID;

	//	Type-specific creation

	if (error = pCreator->OnEffectCreateFromXML(Ctx, pDesc, sUNID))
		return error;

	//	Done

	*retpCreator = pCreator;

	return NOERROR;
	}
开发者ID:Sdw195,项目名称:Transcendence,代码行数:34,代码来源:CEffectCreator.cpp

示例3: CreateHitEffect

void CWeaponFireDesc::CreateHitEffect (CSystem *pSystem, SDamageCtx &DamageCtx)

//	CreateHitEffect
//
//	Creates an effect when the weapon hits an object

	{
	//	See if this weapon has a hit effect

	CEffectCreator *pHitEffect = m_pHitEffect;

	//	If not, compute a default hit effect depending on the weapon damage type

	if (pHitEffect == NULL)
		pHitEffect = g_pUniverse->FindDefaultHitEffect(m_Damage.GetDamageType());

	//	If we could not come up with a hit effect then we're done.

	if (pHitEffect == NULL)
		return;

	//	Create the effect

	pHitEffect->CreateEffect(pSystem,
			((DamageCtx.pObj && !DamageCtx.pObj->IsDestroyed()) ? DamageCtx.pObj : NULL),
			DamageCtx.vHitPos,
			(DamageCtx.pObj ? DamageCtx.pObj->GetVel() : CVector()),
			DamageCtx.iDirection,
			DamageCtx.iDamage);
	}
开发者ID:Sdw195,项目名称:Transcendence,代码行数:30,代码来源:CWeaponFireDesc.cpp

示例4: CreateFromXML

ALERROR CEffectCreator::CreateFromXML (SDesignLoadCtx &Ctx, CXMLElement *pDesc, const CString &sUNID, CEffectCreator **retpCreator)

//	CreateFromXML
//
//	Creates the creator from an XML element

	{
	ALERROR error;
	CEffectCreator *pCreator;

	//	Basic info

	CString sEffectUNID = sUNID;
	if (sEffectUNID.IsBlank())
		{
		DWORD dwUNID = pDesc->GetAttributeInteger(UNID_ATTRIB);
		if (dwUNID)
			sEffectUNID = strFromInt(dwUNID, FALSE);
		else
			sEffectUNID = STR_NO_UNID;
		}

	//	Create the effect based on the child tag

	if (pDesc->GetContentElementCount() == 0)
		{
		*retpCreator = NULL;
		return NOERROR;
		}
	else if (pDesc->GetContentElementCount() == 1)
		{
		if (error = CreateSimpleFromXML(Ctx, pDesc->GetContentElement(0), sEffectUNID, &pCreator))
			return error;
		}
	else
		{
		pCreator = new CEffectGroupCreator;
		if (pCreator == NULL)
			return ERR_MEMORY;

		pCreator->m_sUNID = sEffectUNID;

		//	Type-specific creation

		if (error = pCreator->OnEffectCreateFromXML(Ctx, pDesc, sEffectUNID))
			return error;
		}

	//	Sound Effect (resolved later)

	pCreator->m_dwSoundUNID = pDesc->GetAttributeInteger(SOUND_ATTRIB);
	pCreator->m_iSound = -1;
	
	//	Done

	*retpCreator = pCreator;

	return NOERROR;
	}
开发者ID:Sdw195,项目名称:Transcendence,代码行数:59,代码来源:CEffectCreator.cpp

示例5: PolarToVector

CSpaceObject::DamageResults CMissile::Damage (CSpaceObject *pCause, const CVector &vHitPos, int iDirection, const DamageDesc &Damage)

//	Damage
//
//	Object takes damage from the given source

	{
	CSpaceObject *pAttacker = pCause->GetDamageCause();

	//	Compute damage

	bool bDestroy = false;
	int iDamage = Damage.RollDamage();
	if (iDamage == 0)
		return damageNoDamage;

	//	If this is a momentum attack then we are pushed

	int iMomentum;
	if (iMomentum = Damage.GetMomentumDamage())
		{
		CVector vAccel = PolarToVector(iDirection, -10 * iMomentum * iMomentum);
		Accelerate(vAccel, g_MomentumConstant);
		ClipSpeed(GetMaxSpeed());
		}

	//	Create a hit effect

	CEffectCreator *pEffect = g_pUniverse->FindEffectType(g_HitEffectUNID);
	if (pEffect)
		pEffect->CreateEffect(GetSystem(),
				this,
				vHitPos,
				GetVel());

	//	Take damage

	if (iDamage < m_iHitPoints)
		{
		m_iHitPoints -= iDamage;
		return damageArmorHit;
		}

	//	We are destroyed

	m_iHitPoints = 0;
	if (m_pDesc->m_iVaporTrailLength)
		{
		m_fDestroyed = true;
		m_iLifeLeft = m_pDesc->m_iVaporTrailLength;
		}
	else
		Destroy(killedByDamage, pAttacker);

	//	A missile might be able to pass through after hitting us

	return damagePassthrough;
	}
开发者ID:alanhorizon,项目名称:Transport,代码行数:58,代码来源:CMissile.cpp

示例6: ValidateClass

ALERROR IEffectPainter::ValidateClass (SLoadCtx &Ctx, const CString &sOriginalClass)

//	ValidateClass
//
//	Reads the class string. If the class does not match the current painter,
//	we read the old data and return ERR_FAIL.

	{
	if (Ctx.dwVersion >= 40)
		{
		CString sClass;
		sClass.ReadFromStream(Ctx.pStream);

		//	If the original class doesn't match the current one, then it means
		//	that the design changed. In that case, we load the painter using the
		//	old class.

		if (!strEquals(sClass, sOriginalClass))
			{
			//	If sClass is blank, then it means that the original did not have
			//	an effect painter (but the current design does)

			if (!sClass.IsBlank())
				{
				//	Get the original creator

				CEffectCreator *pOriginalCreator;
				if (CEffectCreator::CreateFromTag(sClass, &pOriginalCreator) != NOERROR)
					{
					kernelDebugLogMessage("Unable to find original effect creator: %s", sClass.GetASCIIZPointer());
					return ERR_FAIL;
					}

				//	Load the original painter

				IEffectPainter *pOriginalPainter = pOriginalCreator->CreatePainter();
				pOriginalPainter->ReadFromStream(Ctx);

				//	Discard

				pOriginalPainter->Delete();
				delete pOriginalCreator;
				}

			//	Done

			return ERR_FAIL;
			}
		}

	return NOERROR;
	}
开发者ID:Sdw195,项目名称:Transcendence,代码行数:52,代码来源:CEffectCreator.cpp

示例7: CreateHitEffect

void CMissile::CreateHitEffect (const CVector &vPos, int iRotation)

//	CreateHitEffect
//
//	Create hit effect

{
    CEffectCreator *pEffect;
    if (pEffect = m_pDesc->GetHitEffect())
        pEffect->CreateEffect(GetSystem(),
                              (m_iHitDir == -1 ? NULL : m_pHit),
                              vPos,
                              CVector(),
                              iRotation);
}
开发者ID:alanhorizon,项目名称:Transcendence,代码行数:15,代码来源:CMissile.cpp

示例8: Damage

CSpaceObject::DamageResults CParticleEffect::Damage (CSpaceObject *pCause, const CVector &vHitPos, int iDirection, const DamageDesc &Damage)

//	Damage
//
//	Damage the particle field

	{
	//	Create hit effect

	CEffectCreator *pEffect = g_pUniverse->FindEffectType(g_HitEffectUNID);
	if (pEffect)
		pEffect->CreateEffect(GetSystem(),
				this,
				vHitPos,
				GetVel());

	return damagePassthrough;
	}
开发者ID:alanhorizon,项目名称:Transport,代码行数:18,代码来源:CParticleEffect.cpp

示例9: Paint

void CEffectVariantPainter::Paint (CG16bitImage &Dest, int x, int y, SViewportPaintCtx &Ctx)

//	Paint
//
//	Paint the effect

	{
	//	Find the appropriate effect

	int iIndex = m_pCreator->GetVariantCreatorIndex(Ctx.iVariant);
	if (m_Cache[iIndex] == NULL)
		{
		CEffectCreator *pCreator = m_pCreator->GetVariantCreator(iIndex);
		m_Cache[iIndex] = pCreator->CreatePainter(CCreatePainterCtx());
		}

	//	Paint

	m_Cache[iIndex]->Paint(Dest, x, y, Ctx);
	}
开发者ID:dogguts,项目名称:Transcendence,代码行数:20,代码来源:SFXVariants.cpp

示例10: strParseInt

CEffectCreator *CEffectCreator::OnFindEffectCreator (const CString &sUNID)

//	OnFindEffectCreator
//
//	Finds the effect creator by UNID

	{
	char *pPos = sUNID.GetASCIIZPointer();

	//	If we're done, then we mean ourselves

	if (*pPos == '\0')
		return this;

	if (*pPos++ != '/')
		return NULL;

	//	Damage selector?

	if (*pPos == 'd')
		{
		pPos++;

		if (m_pDamage == NULL)
			return NULL;

		return m_pDamage->FindEffectCreator(CString(pPos));
		}

	//	Sub effect

	int iSubEffect = strParseInt(pPos, -1, 0, &pPos);
	if (iSubEffect == -1)
		return NULL;

	CEffectCreator *pSubEffect = GetSubEffect(iSubEffect);
	if (pSubEffect == NULL)
		return NULL;

	return pSubEffect->FindEffectCreatorInType(CString(pPos));
	}
开发者ID:Sdw195,项目名称:Transcendence,代码行数:41,代码来源:CEffectCreator.cpp

示例11: m_pCreator

CSmokeTrailPainter::CSmokeTrailPainter (CSmokeTrailEffectCreator *pCreator) : 
		m_pCreator(pCreator),
		m_iLastDirection(-1),
		m_iTick(0)

//	CSmokeTrailPainter constructor

	{
	int iMaxParticleCount = m_pCreator->GetParticleLifetimeMax() * m_pCreator->GetNewParticleMax();

	m_Particles.Init(iMaxParticleCount);

	int iTotalLifetime = m_pCreator->GetLifetime();
	m_iEmitLifetime = (iTotalLifetime == -1 ? -1 : m_pCreator->GetEmitLifetime() * iTotalLifetime / 100);

	CEffectCreator *pEffect = pCreator->GetParticleEffect();
	if (pEffect)
		m_pParticlePainter = pEffect->CreatePainter();
	else
		m_pParticlePainter = NULL;
	}
开发者ID:alanhorizon,项目名称:Transcendence,代码行数:21,代码来源:SFXSmokeTrail.cpp

示例12: InitDamagePainters

void CCompositeImageDesc::InitDamagePainters (void)

//	InitDamagePainters
//
//	Initializes station damage bitmaps

	{
	if (g_pMediumDamage == NULL)
		{
		CEffectCreator *pEffect = g_pUniverse->FindEffectType(MEDIUM_STATION_DAMAGE_UNID);
		if (pEffect)
			g_pMediumDamage = pEffect->CreatePainter();
		}

	if (g_pLargeDamage == NULL)
		{
		CEffectCreator *pEffect = g_pUniverse->FindEffectType(LARGE_STATION_DAMAGE_UNID);
		if (pEffect)
			g_pLargeDamage = pEffect->CreatePainter();
		}
	}
开发者ID:smileyninja,项目名称:Transcendence,代码行数:21,代码来源:CCompositeImageDesc.cpp

示例13: m_pCreator

CParticleJetEffectPainter::CParticleJetEffectPainter (CCreatePainterCtx &Ctx, CParticleJetEffectCreator *pCreator) : 
		m_pCreator(pCreator),
		m_iXformRotation(0),
		m_rXformTime(1.0),
		m_iLifetime(0),
		m_iCurDirection(-1),
		m_iLastDirection(-1),
		m_bUseObjectCenter(Ctx.UseObjectCenter()),
		m_bUseObjectMotion(false),
		m_bTrackingObject(Ctx.IsTracking())

//	CParticleJetEffectPainter constructor

	{
	//	Initialize the single particle painter

	CEffectCreator *pEffect = m_pCreator->GetParticleEffect();
	if (pEffect)
		m_pParticlePainter = pEffect->CreatePainter(Ctx);
	else
		m_pParticlePainter = NULL;
	}
开发者ID:bmer,项目名称:Mammoth,代码行数:22,代码来源:SFXParticleJet.cpp

示例14: ASSERT

CWeaponFireDesc *CWeaponFireDesc::FindWeaponFireDescFromFullUNID (const CString &sUNID)

//	FindWeaponFireDesc
//
//	Finds the descriptor by name

	{
	char *pPos = sUNID.GetPointer();

	//	Get the UNID of the type

	DWORD dwUNID = (DWORD)strParseInt(pPos, 0, &pPos);
	if (dwUNID == 0)
		return NULL;

	//	Get the type

	CDesignType *pType = g_pUniverse->FindDesignType(dwUNID);
	if (pType == NULL)
		return NULL;

	//	If this is an item, then it must be a weapon

	if (pType->GetType() == designItemType)
		{
		CItemType *pItemType = CItemType::AsType(pType);
		ASSERT(pItemType);

		CDeviceClass *pDevice = pItemType->GetDeviceClass();
		if (pDevice == NULL)
			return NULL;

		CWeaponClass *pClass = pDevice->AsWeaponClass();
		if (pClass == NULL)
			return NULL;

		//	Get the ordinal

		ASSERT(*pPos == '/');
		pPos++;
		int iOrdinal = strParseInt(pPos, 0, &pPos);

		//	Get the weapon fire desc of the ordinal

		CWeaponFireDesc *pDesc = pClass->GetVariant(iOrdinal);
		if (pDesc == NULL)
			return NULL;

		//	Continue parsing

		return pDesc->FindWeaponFireDesc(CString(pPos));
		}

	//	If this is an effect, then get it from that

	else if (pType->GetType() == designEffectType)
		{
		CEffectCreator *pEffectType = CEffectCreator::AsType(pType);
		ASSERT(pEffectType);

		//	Expect /d

		ASSERT(*pPos == '/');
		pPos++;
		ASSERT(*pPos == 'd');
		pPos++;

		CWeaponFireDesc *pDesc = pEffectType->GetDamageDesc();
		if (pDesc == NULL)
			return NULL;

		//	Continue parsing

		return pDesc->FindWeaponFireDesc(CString(pPos));
		}

	//	Otherwise, we don't know

	else
		return NULL;
	}
开发者ID:Sdw195,项目名称:Transcendence,代码行数:81,代码来源:CWeaponFireDesc.cpp

示例15: sizeof

IEffectPainter *CEffectCreator::CreatePainterFromStream (SLoadCtx &Ctx, bool bNullCreator)

//	CreatePainterFromStream
//
//	Load a painter from a stream

	{
	CEffectCreator *pCreator;

	//	For previous versions, we only stored UNID if we had a creator

	if (Ctx.dwVersion < 43 && bNullCreator)
		return NULL;

	//	At version 15 we started saving versions as string UNIDs. We need to do this
	//	because sometimes the effect creator is inside a weapon fire desc
	//	structure (also identified by string UNIDs).

	if (Ctx.dwVersion >= 15)
		{
		CString sUNID;
		sUNID.ReadFromStream(Ctx.pStream);

		pCreator = (sUNID.IsBlank() ? NULL : CEffectCreator::FindEffectCreator(sUNID));

		//	Load the creator class that saved the painter

		if (IEffectPainter::ValidateClass(Ctx, (pCreator ? pCreator->GetTag() : NULL_STR)) != NOERROR)
			return NULL;

		//	Error

		if (pCreator == NULL)
			{
			if (!sUNID.IsBlank())
				kernelDebugLogMessage("Invalid painter creator: %s", sUNID.GetASCIIZPointer());
			return NULL;
			}
		}

	//	Old style uses DWORD UNIDs

	else
		{
		//	The first DWORD is the UNID of the creator

		DWORD dwUNID;
		Ctx.pStream->Read((char *)&dwUNID, sizeof(DWORD));
		if (dwUNID == 0)
			return NULL;

		pCreator = g_pUniverse->FindEffectType(dwUNID);

		//	Error

		if (pCreator == NULL)
			{
			kernelDebugLogMessage("Invalid painter creator: %x", dwUNID);
			return NULL;
			}
		}

	//	Let the creator create the object

	IEffectPainter *pPainter = pCreator->CreatePainter();

	//	Load it

	pPainter->ReadFromStream(Ctx);

	//	Done

	return pPainter;
	}
开发者ID:Sdw195,项目名称:Transcendence,代码行数:74,代码来源:CEffectCreator.cpp


注:本文中的CEffectCreator类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。