internal static ControlOverview Open(bool onload = false) { BlockHandlerController.InitializeBuildingBlockIDs(); foreach (ControlOverview x in ACM.Instance.gameObject.GetComponents <ControlOverview>()) { Destroy(x); } var instance = ACM.Instance.gameObject.AddComponent <ControlOverview>(); instance.enabled = false; instance.windowRect.x = Screen.width - 280 - 400; instance.windowRect.y = 200; instance.RefreshOverview(); if (onload) { if (instance.AxisList.TrueForAll(name => { var axis = AxisManager.Get(name); return(axis != null && (axis.Status == AxisStatus.OK || axis.Status == AxisStatus.NotRunning)); })) { Destroy(instance); return(null); } } instance.enabled = true; return(instance); }
/// <summary> /// Mod functionality. /// Calls Python functions. /// </summary> private void Update() { // Initialize block handlers if (Game.IsSimulating && !BlockHandlerController.Initialised) { BlockHandlerController.InitializeBlockHandlers(); } // Initialize block identifiers if (!Game.IsSimulating && rebuildIDs) { rebuildIDs = false; BlockHandlerController.InitializeBuildingBlockIDs(); } // Execute code on first call if (Game.IsSimulating && PythonEnvironment.Loaded && enableScript && (scriptFile != null || scriptCode != null)) { LoadScript(); scriptFile = null; scriptCode = null; } // Toggle watchlist visibility if (PythonEnvironment.Loaded && Keybindings.Get("Watchlist").Pressed()) { Watchlist.Instance.Visible = !Watchlist.Instance.Visible; } // Toggle options visibility if (PythonEnvironment.Loaded && Keybindings.Get("Script Options").Pressed()) { ScriptOptions.Instance.Visible = !ScriptOptions.Instance.Visible; } if (!Game.IsSimulating) { // Show block identifiers if (PythonEnvironment.Loaded && Keybindings.Get("Show Block ID").IsDown()) { ShowBlockIdentifiers(); } } if (!Game.IsSimulating) { return; } // Call script update. try { if (!runtime_error) { PythonEnvironment.ScripterEnvironment?.CallUpdate(); } } catch (Exception e) { runtime_error = true; if (e.InnerException != null) { e = e.InnerException; } ScriptOptions.Instance.ErrorMessage = "Runtime error.\nSee console (Ctrl+K) for more info."; Debug.Log("<b><color=#FF0000>Python error: " + e.Message + "</color></b>\n" + PythonEnvironment.FormatException(e)); } }