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


C++ CGameRules类代码示例

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


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

示例1: ProcessEvent

	virtual void ProcessEvent(EFlowEvent event, SActivationInfo *pActInfo)
	{
		switch(event)
		{
		case eFE_Activate:
			CGameRules *pGR = g_pGame->GetGameRules();

			if(!pGR)
				return;

			if(!pActInfo->pEntity)
				return;

			const bool bUseVapor = GetPortBool(pActInfo, EIP_Vapor);

			if(IsPortActive(pActInfo, EIP_Freeze))
			{
				pGR->FreezeEntity(pActInfo->pEntity->GetId(), true, bUseVapor, true);
				ActivateOutput(pActInfo, EOP_Frozen, true);
			}
			else if(IsPortActive(pActInfo, EIP_UnFreeze))
			{
				pGR->FreezeEntity(pActInfo->pEntity->GetId(), false, bUseVapor);
				ActivateOutput(pActInfo, EOP_UnFrozen, true);
			}

			break;
		}
	}
开发者ID:super-nova,项目名称:NovaRepo,代码行数:29,代码来源:FlowHitInfoNode.cpp

示例2: GetInputActor

void CSetEquipmentLoadoutNode ::ProcessEvent( EFlowEvent event, SActivationInfo *pActInfo )
{
	if(event == eFE_Activate && IsPortActive(pActInfo, 0))
	{
		if(pActInfo->pEntity)
		{

			IActor* pActor = GetInputActor( pActInfo );
			CGameRules *pGameRules = g_pGame->GetGameRules();

			if(pActor)
			{
				int packIndex = GetPortInt(pActInfo, eI_EquipLoadout);
				CEquipmentLoadout *pEquipmentLoadout = g_pGame->GetEquipmentLoadout();
				if(pEquipmentLoadout)
				{
					pEquipmentLoadout->SetSelectedPackage(packIndex);
					pGameRules->SetPendingLoadoutChange();
				}
			}

		}

	}
}
开发者ID:PiratesAhoy,项目名称:HeartsOfOak-Core,代码行数:25,代码来源:FlowWeaponCustomizationNodes.cpp

示例3: ProcessTeamChangeVisualization

//------------------------------------------------------------------------
void CTeamVisualizationManager::ProcessTeamChangeVisualization(EntityId entityId) const
{
	if(!m_teamVisualizationPartsMap.empty())
	{
		if(entityId == g_pGame->GetClientActorId())
		{
			// If local player has changed team, refresh team materials for *all* players in game
			CGameRules* pGameRules = g_pGame->GetGameRules();
			CGameRules::TPlayers players;
			pGameRules->GetPlayers(players);

			CGameRules::TPlayers::const_iterator iter = players.begin();
			CGameRules::TPlayers::const_iterator end = players.end();
			while(iter != end)
			{
				RefreshPlayerTeamMaterial(*iter); 
				++iter;
			}
		}
		else // If remote player has changed team, just refresh that player.
		{
			RefreshPlayerTeamMaterial(entityId); 
		}
	}
}
开发者ID:PiratesAhoy,项目名称:HeartsOfOak-Core,代码行数:26,代码来源:TeamVisualizationManager.cpp

示例4: switch

//---------------------------------------
void CMiscAnnouncer::Update(const float dt)
{
	if(!ma_enabled || !AnnouncerRequired())
		return;

#if !defined(_RELEASE)
	switch(ma_debug)
	{
		case 2:    // debug OnWeaponFiredMap
			for (TWeaponFiredMap::iterator it=m_weaponFiredMap.begin(); it != m_weaponFiredMap.end(); ++it)
			{
				SOnWeaponFired &onWeaponFired = it->second;
				CryWatch("weaponFired: weapon=%s; announce=%s; played: friend=%s; enemy=%s", onWeaponFired.m_weaponEntityClass->GetName(), onWeaponFired.m_announcementName.c_str(), onWeaponFired.m_havePlayedFriendly ? "true" : "false", onWeaponFired.m_havePlayedEnemy ? "true" : "false");
			}
			break;
		case 3:			// debug listeners
		{
			CGameRules *pGameRules = g_pGame->GetGameRules();
			for (ActorWeaponListenerMap::iterator it=m_actorWeaponListener.begin(); it != m_actorWeaponListener.end(); ++it)
			{
				CryWatch("ActorWeaponListener: Actor=%s; Weapon=%s", pGameRules->GetEntityName(it->first), pGameRules->GetEntityName(it->second));
			}
		}
	}
#endif
}
开发者ID:eBunny,项目名称:EmberProject,代码行数:27,代码来源:MiscAnnouncer.cpp

示例5: RegisterVTOLWithPathFollower

void CVTOLVehicleManager::RegisterVTOLWithPathFollower(bool registerVTOL)
{
	if(!registerVTOL || !m_bRegisteredWithPathFollower)
	{
		CGameRules* pGameRules = g_pGame->GetGameRules();
		if(pGameRules)
		{
			CMPPathFollowingManager* pPathFollowingManager = pGameRules->GetMPPathFollowingManager();
			if(pPathFollowingManager)
			{
				if(registerVTOL)
				{
					if(m_classId == (uint16)-1)
					{
						g_pGame->GetIGameFramework()->GetNetworkSafeClassId(m_classId, s_VTOLClassName);
					}
					pPathFollowingManager->RegisterClassFollower(m_classId, this);
					m_bRegisteredWithPathFollower = true;
				}
				else
				{
					pPathFollowingManager->UnregisterClassFollower(m_classId);
					m_bRegisteredWithPathFollower = false;
				}
			}
		}	
	}
}
开发者ID:souxiaosou,项目名称:FireNET,代码行数:28,代码来源:VTOLVehicleManager.cpp

示例6: OnActionEvent

void CGameAchievements::OnActionEvent(const SActionEvent& event)
{
	// assuming that we don't want to detect anything in MP.
	if(event.m_event == eAE_inGame && !gEnv->bMultiplayer)
	{
		CGameRules* pGR = g_pGame->GetGameRules();
		if(pGR)
		{
#ifdef GAME_IS_CRYSIS2
			pGR->RegisterKillListener(this);
#endif
			
			m_HMGHitType = pGR->GetHitTypeId("HMG");
			m_gaussBulletHitType = pGR->GetHitTypeId("gaussBullet");
		}

		m_lastPlayerThrownObject = 0;
		m_lastPlayerKillBulletId = 0;
		m_lastPlayerKillGrenadeId = 0;
		m_killsWithOneGrenade = 0;
	}

	// NB: by the time the eAE_unloadlevel event is sent the game
	//	rules is already null: can't unregister.
}
开发者ID:Aytunes,项目名称:Tanks,代码行数:25,代码来源:GameAchievements.cpp

示例7: Reset

//---------------------------------------
void CAreaAnnouncer::Init()
{
	Reset();

	//Scan for areas
	IEntityClass* pTargetClass = gEnv->pEntitySystem->GetClassRegistry()->FindClass("AreaBox");
	CRY_ASSERT_MESSAGE(pTargetClass, "Unable to find Target class AreaBox");

	if(pTargetClass)
	{
		IEntityIt* it = gEnv->pEntitySystem->GetEntityIterator();
		while ( !it->IsEnd() )
		{
			IEntity* pEntity = it->Next();
			if(pEntity->GetClass() == pTargetClass)
			{
				//check entityName
				IEntityAreaProxy *pArea = (IEntityAreaProxy*)pEntity->GetProxy(ENTITY_PROXY_AREA);
				if (pArea)
				{
					LoadAnnouncementArea(pEntity, pEntity->GetName());
				}
			}
		}
		it->Release();
	}

	CGameRules *pGameRules = g_pGame->GetGameRules();
	pGameRules->RegisterRevivedListener(this);
}
开发者ID:Kufusonic,项目名称:Work-in-Progress-Sonic-Fangame,代码行数:31,代码来源:AreaAnnouncer.cpp

示例8: FindClientSoundmoodBestFit

CPlayer::EClientSoundmoods CLocalPlayerComponent::FindClientSoundmoodBestFit() const
{
	const CRecordingSystem* pRecordingSystem = g_pGame->GetRecordingSystem();
	if(pRecordingSystem && pRecordingSystem->IsPlayingBack())
	{
		return pRecordingSystem->IsInBulletTime() ? CPlayer::ESoundmood_KillcamSlow : CPlayer::ESoundmood_Killcam;
	}

	CGameRules* pGameRules = g_pGame->GetGameRules();
	const IGameRulesStateModule *pStateModule = pGameRules ? pGameRules->GetStateModule() : NULL;
	const IGameRulesStateModule::EGR_GameState gameState = pStateModule ? pStateModule->GetGameState() : IGameRulesStateModule::EGRS_InGame;
	if(gameState == IGameRulesStateModule::EGRS_PreGame)
	{
		return CPlayer::ESoundmood_PreGame;
	}
	else if(gameState == IGameRulesStateModule::EGRS_PostGame)
	{
		return CPlayer::ESoundmood_PostGame;
	}
	else if(m_rPlayer.GetSpectatorMode() != CActor::eASM_None)
	{
		return CPlayer::ESoundmood_Spectating;
	}
	else if(m_rPlayer.IsDead())
	{
		return CPlayer::ESoundmood_Dead;
	}
	else if(m_rPlayer.GetHealth() < g_pGameCVars->g_playerLowHealthThreshold)
	{
		return CPlayer::ESoundmood_LowHealth;
	}

	return CPlayer::ESoundmood_Alive;
}
开发者ID:danielasun,项目名称:dbho-GameSDK,代码行数:34,代码来源:LocalPlayerComponent.cpp

示例9: CryLog

bool CGameRulesSpawningBase::CanPlayerSpawnThisRound(const EntityId playerId) const
{
	bool allowed=true;

	IActor *pActor = g_pGame->GetIGameFramework()->GetIActorSystem()->GetActor(playerId);

	if (pActor->IsPlayer())
	{
		CGameRules *pGameRules = g_pGame->GetGameRules();
		IGameRulesPlayerStatsModule *playerStats = pGameRules ? pGameRules->GetPlayerStatsModule() : NULL;

		if (playerStats)
		{
			const SGameRulesPlayerStat *stats = playerStats->GetPlayerStats(playerId);
			if (stats)
			{
				if (stats->flags & SGameRulesPlayerStat::PLYSTATFL_CANTSPAWNTHISROUND)
				{	
					allowed=false;
				}
			}
		}
	}

	CryLog("CGameRulesSpawningBase::CanPlayerSpawnThisRound() player=%s allowed=%d", pActor->GetEntity()->GetName(), allowed);
	return allowed;
}
开发者ID:aronarts,项目名称:FireNET,代码行数:27,代码来源:GameRulesSpawningBase.cpp

示例10: SAFE_DELETE

//--------------------------------------------------------------------------------------------------
// Name: ~CGameEffectsSystem
// Desc: Destructor
//--------------------------------------------------------------------------------------------------
GameSDKCGameEffectsSystem::~GameSDKCGameEffectsSystem()
{
#if DEBUG_GAME_FX_SYSTEM
	if(gEnv->pInput)
	{
		gEnv->pInput->RemoveEventListener(this);
	}
#endif

#ifdef SOFTCODE_ENABLED
	if(gEnv->pSoftCodeMgr)
	{
		gEnv->pSoftCodeMgr->RemoveListener(GAME_FX_LIBRARY_NAME,this);
	}

	SAFE_DELETE(m_gameRenderNodeSoftCodeListener);
	SAFE_DELETE(m_gameRenderElementSoftCodeListener);
	m_softCodeTypeLibs.clear();
	m_gameRenderNodes.clear();
	m_gameRenderElements.clear();
#endif

	// Remove as game rules listener
	if(g_pGame)
	{
		CGameRules* pGameRules = g_pGame->GetGameRules();
		if(pGameRules)
		{
			pGameRules->RemoveGameRulesListener(this);
		}
	}
}//-------------------------------------------------------------------------------------------------
开发者ID:danielasun,项目名称:dbho-GameSDK,代码行数:36,代码来源:GameEffectsSystem.cpp

示例11: 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

示例12:

	~CFlowExplosionInfoNode()
	{
		// safety unregister
		CGameRules *pGR = g_pGame->GetGameRules();

		if(pGR)
			pGR->RemoveHitListener(this);
	}
开发者ID:super-nova,项目名称:NovaRepo,代码行数:8,代码来源:FlowHitInfoNode.cpp

示例13: RefreshTeamMaterial

//------------------------------------------------------------------------
void CTeamVisualizationManager::RefreshPlayerTeamMaterial( const EntityId playerId ) const
{
	if(IEntity* pEntity = gEnv->pEntitySystem->GetEntity(playerId))
	{
		CGameRules* pGameRules = g_pGame->GetGameRules();
		CGameRules::eThreatRating threatRating = pGameRules->GetThreatRating(g_pGame->GetClientActorId(), playerId);
		RefreshTeamMaterial( pEntity, true, threatRating==CGameRules::eFriendly );
	}
}
开发者ID:PiratesAhoy,项目名称:HeartsOfOak-Core,代码行数:10,代码来源:TeamVisualizationManager.cpp

示例14: CacheEquipmentPack

//====================================================================
//	Cache an equipment pack.
//
//	In:		Lua interfacing handle.
//	In:		The name of the equipment pack (case sensitive) (NULL
//			is invalid!)
//
//	Returns:	The standard Lua return code.
//
int CScriptBind_Game::CacheEquipmentPack(IFunctionHandler* pH, const char* equipmentPackName)
{
	CGameRules *gameRules = g_pGame->GetGameRules();
	if (gameRules != NULL)
	{
		gameRules->PreCacheEquipmentPack(equipmentPackName);
	}
	return pH->EndFunction();
}
开发者ID:Kufusonic,项目名称:Work-in-Progress-Sonic-Fangame,代码行数:18,代码来源:ScriptBind_Game.cpp

示例15: dir

//------------------------------------------------------------------------
void CProjectile::Explode(bool destroy, bool impact, const Vec3 &pos, const Vec3 &normal, const Vec3 &vel, EntityId targetId)
{
	const SExplosionParams* pExplosionParams = m_pAmmoParams->pExplosion;
	if (pExplosionParams)
	{
		Vec3 dir(0,0,1);
		if (impact && vel.len2()>0)
			dir = vel.normalized();
		else if (normal.len2()>0)
			dir = -normal;

		m_hitPoints = 0;

		// marcok: using collision pos sometimes causes explosions to have no effect. Anton advised to use entity pos
		Vec3 epos = pos.len2()>0 ? (pos - dir * 0.2f) : GetEntity()->GetWorldPos();

		CGameRules *pGameRules = g_pGame->GetGameRules();
		float minRadius = pExplosionParams->minRadius;
		float maxRadius = pExplosionParams->maxRadius;
		if (m_pAmmoParams->pFlashbang)
		{
			minRadius = m_pAmmoParams->pFlashbang->maxRadius;
			maxRadius = m_pAmmoParams->pFlashbang->maxRadius;
		}

		ExplosionInfo explosionInfo(m_ownerId, GetEntityId(), m_damage, epos, dir, minRadius, maxRadius, pExplosionParams->minPhysRadius, pExplosionParams->maxPhysRadius, 0.0f, pExplosionParams->pressure, pExplosionParams->holeSize, pGameRules->GetHitTypeId(pExplosionParams->type.c_str()));
		if(m_pAmmoParams->pFlashbang)
			explosionInfo.SetEffect(pExplosionParams->effectName, pExplosionParams->effectScale, pExplosionParams->maxblurdist, m_pAmmoParams->pFlashbang->blindAmount, m_pAmmoParams->pFlashbang->flashbangBaseTime);
		else
			explosionInfo.SetEffect(pExplosionParams->effectName, pExplosionParams->effectScale, pExplosionParams->maxblurdist);
		explosionInfo.SetEffectClass(m_pAmmoParams->pEntityClass->GetName());

		if (impact)
			explosionInfo.SetImpact(normal, vel, targetId);

		if (gEnv->bServer)
		{
			pGameRules->ServerExplosion(explosionInfo);

			// add battle dust as well
			CBattleDust* pBD = pGameRules->GetBattleDust();
			if(pBD)
				pBD->RecordEvent(eBDET_Explosion, pos, GetEntity()->GetClass());
		}
	}

	if(!gEnv->bMultiplayer)
	{
		//Single player (AI related code)is processed here, CGameRules::ClientExplosion process the effect
		if (m_pAmmoParams->pFlashbang)
			FlashbangEffect(m_pAmmoParams->pFlashbang);
	}

	if (destroy)
		Destroy();
}
开发者ID:mrwonko,项目名称:CrysisVR,代码行数:57,代码来源:Projectile.cpp


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