Beispiel #1
0
CMonoFlowNode::~CMonoFlowNode()
{
	IMonoClass *pFlowNodeClass = g_pScriptSystem->GetCryBraryAssembly()->GetClass("FlowNode", "CryEngine.Flowgraph");

	IMonoArray *pParams = CreateMonoArray(1);
	pParams->Insert(m_scriptId);

	pFlowNodeClass->InvokeArray(nullptr, "InternalRemove", pParams);
}
Beispiel #2
0
IMPLEMENT_RMI(CMonoActor, ClScriptRMI)
{
	IMonoClass *pActorClass = g_pScriptSystem->GetCryBraryAssembly()->GetClass("Entity");

	IMonoArray *pNetworkArgs = CreateMonoArray(3);
	pNetworkArgs->Insert(ToMonoString(params.methodName.c_str()));
	pNetworkArgs->Insert(params.pArgs);
	pNetworkArgs->Insert(params.targetId);

	pActorClass->InvokeArray(nullptr, "OnRemoteInvocation", pNetworkArgs);

	return true;
}
Beispiel #3
0
IMPLEMENT_RMI(CMonoEntityExtension, SvScriptRMI)
{
	IMonoClass *pEntityClass = g_pScriptSystem->GetCryBraryAssembly()->GetClass("Entity");

	IMonoArray *pNetworkArgs = CreateMonoArray(3);
	pNetworkArgs->Insert(ToMonoString(params.methodName.c_str()));
	pNetworkArgs->InsertMonoObject(params.args);
	pNetworkArgs->Insert(params.targetId);

	pEntityClass->InvokeArray(nullptr, "OnRemoteInvocation", pNetworkArgs);
	pNetworkArgs->Release();

	return true;
}
Beispiel #4
0
bool CScriptSystem::Reload()
{
	if((!m_bFirstReload && g_pMonoCVars->mono_realtimeScripting == 0) || m_bReloading)
		return false;

	m_bReloading = true;

	if(!m_bFirstReload)
	{
		for each(auto listener in m_listeners)
			listener->OnReloadStart();

		m_pScriptManager->CallMethod("Serialize");
	}

	IMonoDomain *pScriptDomain = CreateDomain("ScriptDomain", nullptr, true);

	IMonoAssembly *pCryBraryAssembly = pScriptDomain->LoadAssembly(PathUtils::GetBinaryPath(true) + "CryBrary.dll");

	IMonoArray *pCtorParams = CreateMonoArray(2);
	pCtorParams->InsertAny(m_bFirstReload);
	pCtorParams->InsertMonoString(ToMonoString(PathUtils::GetConfigPath()));

	IMonoObject *pScriptManager = *pCryBraryAssembly->GetClass("ScriptManager", "CryEngine.Initialization")->CreateInstance(pCtorParams);
	SAFE_RELEASE(pCtorParams);

	auto result = pScriptManager->CallMethod("Initialize", m_bFirstReload);
	if(result == nullptr)
		return false;

	IMonoObject *pResult = *result;
	auto reloadResult = pResult->Unbox<EScriptReloadResult>();
	SAFE_RELEASE(pResult);

	switch(reloadResult)
	{
	case EScriptReloadResult_Success:
		{
			// revert previous domain
			if(!m_bFirstReload)
				m_pScriptDomain->Release();

			m_pScriptDomain = pScriptDomain;
			m_pScriptManager = pScriptManager;
			m_pCryBraryAssembly = pCryBraryAssembly;

			if(!m_bFirstReload)
				m_pScriptManager->CallMethod("Deserialize");

			// Set Network.Editor etc.
			IMonoClass *pClass = m_pCryBraryAssembly->GetClass("Game");

			IMonoArray *pArgs = CreateMonoArray(2);
			pArgs->Insert(gEnv->IsEditor());
			pArgs->Insert(gEnv->IsDedicated());
			pClass->InvokeArray(NULL, "InitializeGameStatics", pArgs);
			SAFE_RELEASE(pArgs);

			m_pScriptManager->CallMethod("ProcessWaitingScripts", m_bFirstReload);

			for each(auto listener in m_listeners)
				listener->OnReloadComplete();

			if(!m_bFirstReload && gEnv->IsEditor())
				gEnv->pFlowSystem->ReloadAllNodeTypes();

			m_bReloading = false;
			m_bDetectedChanges = false;

			return true;
		}
		break;
	case EScriptReloadResult_Retry:
		{
			m_bReloading = false;
			return Reload();
		}
	case EScriptReloadResult_Revert:
		{
			pScriptDomain->Release();
			m_pScriptDomain->SetActive();

			m_bReloading = false;

			m_bDetectedChanges = false;
			return false;
		}
		break;
	case EScriptReloadResult_Abort:
		{
			gEnv->pSystem->Quit();

			m_bReloading = false;
		}
		break;
	}

	return false;
}