void CScriptbind_Input::OnHardwareMouseEvent(int iX,int iY,EHARDWAREMOUSEEVENT eHardwareMouseEvent, int wheelDelta) { IMonoArray *pParams = CreateMonoArray(4); pParams->Insert(iX); pParams->Insert(iY); pParams->Insert(eHardwareMouseEvent); pParams->Insert(wheelDelta); IMonoClass *pInputClass = g_pScriptSystem->GetCryBraryAssembly()->GetClass("Input", "CryEngine"); pInputClass->GetMethod("OnMouseEvent", 4)->InvokeArray(NULL, pParams); SAFE_RELEASE(pParams); }
bool CScriptbind_Input::OnInputEvent(const SInputEvent &event) { IMonoArray *pParams = CreateMonoArray(2); pParams->Insert(event.keyName.c_str()); pParams->Insert(event.value); IMonoClass *pInputClass = g_pScriptSystem->GetCryBraryAssembly()->GetClass("Input", "CryEngine"); pInputClass->GetMethod("OnKeyEvent", 2)->InvokeArray(NULL, pParams); SAFE_RELEASE(pParams); return false; }
bool CScriptbind_Input::OnActionTriggered(EntityId entityId, const ActionId& actionId, int activationMode, float value) { IMonoArray *pParams = CreateMonoArray(3); pParams->Insert(actionId.c_str()); pParams->Insert(activationMode); pParams->Insert(value); IMonoClass *pInputClass = g_pScriptSystem->GetCryBraryAssembly()->GetClass("Input", "CryEngine"); pInputClass->GetMethod("OnActionTriggered", 3)->InvokeArray(NULL, pParams); SAFE_RELEASE(pParams); return false; }
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() + "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; CacheManagedResources(); 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->GetMethod("InitializeGameStatics", 2)->InvokeArray(nullptr, 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; }