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


C++ IWeapon::AddEventListener方法代码示例

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


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

示例1: Serialize

	void Serialize(SActivationInfo* pActInfo, TSerialize ser)
	{
		ser.Value("active", m_active);
		ser.Value("ammo", m_ammo);
		ser.Value("weaponId", m_weapId);

		if (ser.IsReading())
		{
			if (m_active && m_weapId != 0)
			{
				IItemSystem* pItemSys = CCryAction::GetCryAction()->GetIItemSystem();

				IItem* pItem = pItemSys->GetItem(m_weapId);

				if (!pItem || !pItem->GetIWeapon())
				{
					GameWarning("[flow] CFlowNode_WeaponListener: Serialize no item/weapon.");
					return;
				}
				IWeapon* pWeapon = pItem->GetIWeapon();
				// set weapon listener
				pWeapon->AddEventListener(this, "CFlowNode_WeaponListener");
				// CryLog("[flow] CFlowNode_WeaponListener::Serialize() successfully created on '%s'", pItem->GetEntity()->GetName());
			}
			else
			{
				Reset();
			}
		}
	}
开发者ID:aronarts,项目名称:FireNET,代码行数:30,代码来源:FlowWeaponNodes.cpp

示例2: ProcessEvent

	void ProcessEvent( EFlowEvent event, SActivationInfo *pActInfo )
	{     
		IWeapon* pWeapon = GetWeapon(pActInfo);

		if (!pWeapon) 
			return;
			
		switch (event)
		{
			case eFE_Initialize:
			{
				m_isFiring = false;   
				m_numShots = GetPortInt( pActInfo, IN_NUMBEROFSHOTS );
				m_actInfo = *pActInfo;
				m_numShotsDone = 0;

				pWeapon->StopFire();

				if (pActInfo->pEntity->GetId() != m_weapId)
					RemoveListener(m_weapId, this);

				m_weapId = pActInfo->pEntity->GetId();
				pWeapon->AddEventListener(this, __FUNCTION__);

#ifdef DEBUG_NODEFIREWEAPON
				pActInfo->pGraph->SetRegularlyUpdated( pActInfo->myID, true );
#endif
				break;
			}
		
			case eFE_Activate:
			{ 
				m_actInfo = *pActInfo;
				if (IsPortActive(pActInfo, IN_NUMBEROFSHOTS))
					m_numShots = GetPortBool( pActInfo, IN_NUMBEROFSHOTS );
				
				if (IsPortActive(pActInfo, IN_STOPFIRE))
				{
					StopFiring( pActInfo, pWeapon );
				}
				if (IsPortActive(pActInfo, IN_STARTFIRE))
				{
					m_numShotsDone = 0;
					ReplenishAmmo( pWeapon );
					pWeapon->StopFire();
					StartFiring( pActInfo, pWeapon );
				}
				break;
			}
			
			case eFE_Update:
			{
				// this fixes the problem when the entity is being externally moved/rotated, in the interval of time between when the weapon is aimed an the actual shot happens
				if (m_isFiring && GetPortBool( pActInfo, IN_ALIGNTOTARGET ))
					if (pActInfo->pEntity->GetWorldPos()!=m_lastPos || pActInfo->pEntity->GetWorldRotation()!=m_lastRotation)
						CalcFiringPosition( pActInfo, pWeapon );
			
#ifdef DEBUG_NODEFIREWEAPON
				ColorB colorRed( 255,0,0 );
				ColorB colorGreen( 0,255,0 );
				gEnv->pRenderer->GetIRenderAuxGeom()->DrawLine( posOrig, colorRed, posTarget, colorRed );
				gEnv->pRenderer->GetIRenderAuxGeom()->DrawLine( posTarget, colorGreen, posShot, colorGreen );
#endif
				break;
			}
		}
	}
开发者ID:aronarts,项目名称:FireNET,代码行数:67,代码来源:FlowWeaponNodes.cpp


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