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


C++ CGameRules::ServerHit方法代码示例

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


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

示例1: Update

//------------------------------------------------------------------------
void CVehicleDamageBehaviorBurn::Update(const float deltaTime)
{
	m_timeCounter -= deltaTime;

	if(m_timeCounter <= 0.0f)
	{
		CGameRules *pGameRules = g_pGame->GetGameRules();

		if(pGameRules && gEnv->bServer)
		{
			Vec3 worldPos;

			if(m_pHelper)
				worldPos = m_pHelper->GetWorldSpaceTranslation();
			else
				worldPos = m_pVehicle->GetEntity()->GetWorldTM().GetTranslation();

			SEntityProximityQuery query;
			query.box = AABB(worldPos-Vec3(m_radius), worldPos+Vec3(m_radius));
			gEnv->pEntitySystem->QueryProximity(query);

			IEntity *pEntity = 0;

			for(int i = 0; i < query.nCount; ++i)
			{
				if((pEntity = query.pEntities[i]) && pEntity->GetPhysics())
				{
					float damage = (pEntity->GetId() == m_pVehicle->GetEntityId()) ? m_selfDamage : m_damage;

					// SNH: need to check vertical distance here as the QueryProximity() call seems to work in 2d only
					Vec3 pos = pEntity->GetWorldPos();

					if(abs(pos.z - worldPos.z) < m_radius)
					{
						if(damage > 0.f)
						{
							HitInfo hitInfo;
							hitInfo.damage = damage;
							hitInfo.pos = worldPos;
							hitInfo.radius = m_radius;
							hitInfo.targetId = pEntity->GetId();
							hitInfo.shooterId = m_shooterId;
							hitInfo.weaponId = m_pVehicle->GetEntityId();
							hitInfo.type = pGameRules->GetHitTypeId("fire");
							pGameRules->ServerHit(hitInfo);
						}
					}
				}
			}

			if(gEnv->pAISystem)
				gEnv->pAISystem->RegisterDamageRegion(this, Sphere(worldPos, m_radius));
		}

		m_timeCounter = m_interval;
	}

	m_pVehicle->NeedsUpdate();
}
开发者ID:super-nova,项目名称:NovaRepo,代码行数:60,代码来源:VehicleDamageBehaviorBurn.cpp

示例2: DestructionDamageRatioReached

void CVTOLVehicleManager::DestructionDamageRatioReached(IVehicle* pVehicle, SVTOLInfo& info, float frameTime)
{
	pVehicle->ClientEvictAllPassengers();
	LockSeats(pVehicle, true);

	IPhysicalEntity* pPhysics = pVehicle->GetEntity()->GetPhysics();
	if(pPhysics)
	{
		DestroyVTOL(pVehicle->GetEntity(), info);

		CGameRules::SModuleRMIEntityParams params;
		params.m_listenerIndex = m_moduleRMIIndex;
		params.m_entityId = info.entityId;
		params.m_data = eRMITypeSingleEntity_vtol_destroyed;

		// RMI will patch entityIDs between clients
		g_pGame->GetGameRules()->GetGameObject()->InvokeRMIWithDependentObject(CGameRules::ClModuleRMISingleEntity(), params, eRMI_ToRemoteClients, info.entityId);
	}

	//Damage any players inside
	CGameRules* pGameRules = g_pGame->GetGameRules();
	CVehicleMovementMPVTOL* pMovement = static_cast<CVehicleMovementMPVTOL*>(pVehicle->GetMovement());

	if (pGameRules && pMovement)
	{
		EntityId destroyerId = pMovement->GetDestroyerId();

		HitInfo hitInfo(destroyerId, 0, pVehicle->GetEntityId(), g_pGameCVars->g_VTOLOnDestructionPlayerDamage, 0, 0, 0, CGameRules::EHitType::VTOLExplosion);

		TPlayerList& currentPlayerList = info.playersInside;
		TPlayerList::const_iterator iter = currentPlayerList.begin();
		TPlayerList::const_iterator end = currentPlayerList.end();
		while(iter != end)
		{
			hitInfo.targetId = *iter;
			pGameRules->ServerHit(hitInfo);

			++iter;
		}
	}
}
开发者ID:souxiaosou,项目名称:FireNET,代码行数:41,代码来源:VTOLVehicleManager.cpp


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