Пример #1
0
//------------------------------------------------------------------------
void CEditorGame::OnBeforeLevelLoad()
{
	EnablePlayer(false);
	ConfigureNetContext(true);
	SetGameRules();
	m_pGame->GetIGameFramework()->GetILevelSystem()->OnLoadingStart(0);
}
Пример #2
0
//------------------------------------------------------------------------
void CEditorGame::OnBeforeLevelLoad()
{
	//This must be called before ILevelSystem::OnLoadingStart (good place to free resources in editor, before next level loads)
	g_pGame->OnBeforeEditorLevelLoad();

	EnablePlayer(false);
	ConfigureNetContext(true);
	const char *pGameRulesName = GetGameRulesName();
	m_pGame->GetIGameFramework()->GetIGameRulesSystem()->CreateGameRules(pGameRulesName);
	m_pGame->GetIGameFramework()->GetILevelSystem()->OnLoadingStart(0);
}
Пример #3
0
bool CEditorGame::Init(ISystem *pSystem,IGameToEditorInterface *pGameToEditorInterface)
{
	assert(pSystem);

	SSystemInitParams startupParams;
	startupParams.bEditor = true;
	startupParams.pSystem = pSystem;
	startupParams.bExecuteCommandLine=false;		// in editor we do it later - after other things are initialized

	m_pGameStartup = CreateGameStartup();

	m_pGame = m_pGameStartup->Init(startupParams);

	if (!m_pGame)
	{
		return false;
	}

	IGameFramework* pGameFramework = m_pGame->GetIGameFramework();
	if ( pGameFramework != NULL )
	{
		pGameFramework->InitEditor( pGameToEditorInterface );
	}

	InitUIEnums(pGameToEditorInterface);

	gEnv->bServer = true;
	gEnv->bMultiplayer = false;

#if !defined(XENON) && !defined(PS3) && !defined(GRINGO)
	gEnv->SetIsClient(true);
#endif

	m_bUsingMultiplayerGameRules = false;

	s_pEditorGameMode = REGISTER_INT( "net_gamemode", 0, 0, "Should editor connect a new client?");
	s_pEditorGameMode->SetOnChangeCallback(&OnChangeEditorMode);

	SetGameMode(false);

	REGISTER_COMMAND( "net_reseteditorclient", ResetClient, 0, "Resets player and gamerules!" );

	ConfigureNetContext(true);
		
	return true;
}
//------------------------------------------------------------------------
bool CEditorGame::SetGameMode(bool bGameMode)
{
	m_bGameMode = bGameMode;
	bool on = bGameMode;

	if (s_pEditorGameMode->GetIVal() == 0)
	{
		on = m_bPlayer;
	}

	bool ok = ConfigureNetContext( on );

	if (ok)
	{
		if(gEnv->IsEditor())
		{
			m_pGame->EditorResetGame(bGameMode);
		}

		IGameFramework *pGameFramework = m_pGame->GetIGameFramework();
		pGameFramework->OnEditorSetGameMode(bGameMode);
		CActor *pActor = static_cast<CActor *>(m_pGame->GetIGameFramework()->GetClientActor());

		if (pActor)
		{
			if (bGameMode)
			{
				// Revive actor in its current location (it will be moved to the editor viewpoint location later)
				const Vec3 pos = pActor->GetEntity()->GetWorldPos();
				const Quat rot = pActor->GetEntity()->GetWorldRotation();
				const int teamId = g_pGame->GetGameRules()->GetTeam(pActor->GetEntityId());
				pActor->NetReviveAt(pos, rot, teamId);
			}
			else
			{
				pActor->Reset(true);
			}
		}
	}
	else
	{
		GameWarning("Failed configuring net context");
	}

	return ok;
}
Пример #5
0
bool CEditorGame::Init(ISystem *pSystem,IGameToEditorInterface *pGameToEditorInterface)
{
	assert(pSystem);

	SSystemInitParams startupParams;
    FillSystemInitParams(startupParams, pSystem);

	m_pGameStartup = CreateGameStartup();

	m_pGame = m_pGameStartup->Init(startupParams);

	if (!m_pGame)
	{
		return false;
	}

	InitUIEnums(pGameToEditorInterface);

	m_pGame->GetIGameFramework()->InitEditor(pGameToEditorInterface);

	m_pEquipmentSystemInterface = new CEquipmentSystemInterface(this, pGameToEditorInterface);

	gEnv->bServer = true;
	gEnv->bMultiplayer = false;

#if !defined(CONSOLE)
	gEnv->SetIsClient(true);
#endif

	m_bUsingMultiplayerGameRules = (g_pGameCVars->g_multiplayerDefault != 0);

	if (IConsole* pConsole = gEnv->pConsole)
		s_pEditorGameMode = REGISTER_INT_CB("net_gamemode", 0, VF_NULL, "Should editor connect a new client?", &OnChangeEditorMode);

	SetGameMode(false);

	REGISTER_COMMAND( "net_reseteditorclient", ResetClient, VF_NULL, "Resets player and gamerules!" );

	ConfigureNetContext(true);

	g_pGame->OnEditorGameInitComplete();
		
	return true;
}