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


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

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


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

示例1: SetRichPresence

bool CRichPresence::SetRichPresence(ERichPresenceState state)
{
	// don't set rich presence if we don't have a controller yet
	if(!g_pGame->HasExclusiveControllerIndex())
	{
		CryLog("[Rich Presence] not setting rich presence, no player set");
		return true;
	}

	CrySessionID sessionID = CrySessionInvalidID;

	if((m_currentState == state) && GameNetworkUtils::CompareCrySessionId(sessionID, m_currentSessionID))
	{
		if(state != eRPS_InGame || !gEnv->bMultiplayer)
		{
			CryLog("[Rich Presence] not setting rich presence state %d multiplayer %d", state, gEnv->bMultiplayer);
			return true;
		}
	}

	// we are already setting rich presence, so wait until that task has finished
	if (m_taskID != CryLobbyInvalidTaskID)
	{
		CryLog("  already setting rich presence, setting desired state to %d", state);
		m_desiredState = state;
		return false;
	}

	ICryLobby *pLobby = gEnv->pNetwork->GetLobby();
	ICryLobbyService *pLobbyService = pLobby ? pLobby->GetLobbyService(eCLS_Online) : NULL;
	ICryLobbyUI *pLobbyUI = pLobbyService ? pLobbyService->GetLobbyUI() : NULL;
	ECryLobbyError error = eCLE_Success;

	m_pendingSessionID = sessionID;

	if(pLobbyUI)
	{
		uint32 userIndex = g_pGame->GetExclusiveControllerDeviceIndex();
		
		CryLog("[Rich Presence] SetRichPresence %d userIndex %d", state, userIndex);

		switch(state)
		{
			case eRPS_Idle:
			{
				SCryLobbyUserData data;

				data.m_id = RICHPRESENCE_ID;
				data.m_type = eCLUDT_Int32;
				data.m_int32 = RICHPRESENCE_IDLE;
				
				error = pLobbyUI->SetRichPresence(userIndex, &data, 1, &m_taskID, CRichPresence::SetRichPresenceCallback, this);
				break;
			}

			case eRPS_FrontEnd:
			{
				SCryLobbyUserData data;

				data.m_id = RICHPRESENCE_ID;
				data.m_type = eCLUDT_Int32;
				data.m_int32 = RICHPRESENCE_FRONTEND;

				error = pLobbyUI->SetRichPresence(userIndex, &data, 1, &m_taskID, CRichPresence::SetRichPresenceCallback, this);
				break;
			}

			case eRPS_Lobby:
			{
				SCryLobbyUserData data;

				data.m_id = RICHPRESENCE_ID;
				data.m_type = eCLUDT_Int32;
				data.m_int32 = RICHPRESENCE_LOBBY;

				error = pLobbyUI->SetRichPresence(userIndex, &data, 1, &m_taskID, CRichPresence::SetRichPresenceCallback, this);
				break;
			}

			case eRPS_InGame:
			{
				if(gEnv->bMultiplayer)
				{
					CGameRules *pGameRules = g_pGame->GetGameRules();
					IGameFramework *pGameFramework = g_pGame->GetIGameFramework();
					const char *levelName = pGameFramework ? pGameFramework->GetLevelName() : NULL;
					const char *gameRulesName = pGameRules ? pGameRules->GetEntity()->GetClass()->GetName() : NULL;
					int32 gameMode = 0;
					int32 map = 0;

					if(levelName)
					{
						levelName = PathUtil::GetFileName(levelName);
						TRichPresenceMap::const_iterator iter = m_richPresence.find(levelName);
						map = (iter == m_richPresence.end()) ? 0 : iter->second;
					}

					if(gameRulesName)
					{
						TRichPresenceMap::const_iterator iter = m_richPresence.find(gameRulesName);
//.........这里部分代码省略.........
开发者ID:aronarts,项目名称:FireNET,代码行数:101,代码来源:RichPresence.cpp

示例2: WriteResults

void CAutoTester::WriteResults(TBitfield flags, const string * additionalTestSuiteName, const XmlNodeRef * additionalTestCase)
{
	const int& autotest_enabled = g_pGameCVars->autotest_enabled;
	if (!autotest_enabled)
	{
		return;
	}

	//If result generation is skipped, exit early
	if (autotest_enabled == 2)
	{
		if (m_quitWhenDone)
		{
			gEnv->pConsole->ExecuteString("quit");
		}

		return;
	}

	// test workaround
	//DesignerWarning(0, "test warning");
	// test workaround

	const char * mapName;
	string gameRulesName;
	const char * serverText = "";
	const char * dedicatedText = gEnv->IsDedicated() ? "_Dedicated" : "";

	CGameRules * rules = g_pGame ? g_pGame->GetGameRules() : NULL;
	if (rules)
	{
		gameRulesName = rules->GetEntity()->GetClass()->GetName();
		serverText = gEnv->bServer ? "_Server" : "_Client";
	}
	else
	{
		gameRulesName = "FrontEnd";
	}

	 if (g_pGame && g_pGame->GetIGameFramework()->GetILevelSystem()->GetCurrentLevel())
	 {
		 mapName = g_pGame->GetIGameFramework()->GetILevelSystem()->GetCurrentLevel()->GetLevelInfo()->GetName();
	 }
	 else
	 {
		 mapName = "NoMapLoaded";
	 }

#ifndef _RELEASE
	 CryLogAlways ("CAutoTester::WriteResults(%s): map is '%s', game mode is '%s'", AutoEnum_GetStringFromBitfield(flags, s_writeResultsFlagNames, WriteResultsFlagList_numBits).c_str(), mapName, gameRulesName.c_str());
#endif
















	XmlNodeRef testSuites = GetISystem()->CreateXmlNode("testSuites");
	testSuites->setTag("testsuites");

	for (TTestSuites::const_iterator it=m_testSuites.begin(); it!=m_testSuites.end(); ++it)
	{
		const STestSuite &testSuiteStruct = it->second;
		int numTests = testSuiteStruct.m_testCases.size();
		int numFails = testSuiteStruct.m_numTestCasesFailed;

		XmlNodeRef testSuite = GetISystem()->CreateXmlNode("AutoTest");
		testSuite->setTag("testsuite");
		testSuite->setAttr("name", it->first);
		testSuite->setAttr("LevelName", mapName);
		testSuite->setAttr("GameRulesName", gameRulesName);

		if (additionalTestSuiteName && it->first == *additionalTestSuiteName)
		{
			CryLog ("Writing additional test case to existing '%s' suite", additionalTestSuiteName->c_str());
			++ numFails; // Assumption here that any additional test data provided is a failure... [TF]
			++ numTests;
			testSuite->addChild(*additionalTestCase);
			additionalTestSuiteName = NULL;
		}

		testSuite->setAttr("tests", numTests);
		testSuite->setAttr("failures", numFails);
		testSuite->setAttr("errors", 0);
		testSuite->setAttr("time", 0);

		for (size_t i = 0; i < testSuiteStruct.m_testCases.size(); i++)
		{
			testSuite->addChild(testSuiteStruct.m_testCases[i]);
		}
//.........这里部分代码省略.........
开发者ID:Adi0927,项目名称:alecmercer-origins,代码行数:101,代码来源:AutoTester.cpp


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