private static void AddButtonGroup(AtmosManager atmosManager) { EditorGUILayout.BeginHorizontal(); GUI.enabled = Application.isPlaying && atmosManager.Mode != AtmosMode.Manual; if (!atmosManager.Running) { if (GUILayout.Button("Start")) { atmosManager.StartSimulation(); } } else if (GUILayout.Button("Stop")) { atmosManager.StopSimulation(); } GUI.enabled = Application.isPlaying && !atmosManager.Running; if (GUILayout.Button("Step")) { AtmosThread.RunStep(); } GUI.enabled = true; EditorGUILayout.EndHorizontal(); }
void OnRoundEnd() { roundStartedServer = false; AtmosThread.ClearAllNodes(); inGameNewPipes.Clear(); inGamePipes.Clear(); }
private void Update() { if (Mode == AtmosMode.GameLoop && Running) { try { AtmosThread.RunStep(); } catch (Exception e) { Logger.LogError($"Exception in Atmos Thread! Will no longer mix gases!\n{e.StackTrace}", Category.Atmos); throw; } } if (roundStartedServer) { if (tickRate == 0) { tickRate = tickRateComplete / Steps; } tickCount += Time.deltaTime; if (tickCount > tickRate) { DoTick(); tickCount = 0f; currentTick = ++currentTick % Steps; } } }
public override void OnInspectorGUI() { AtmosManager atmosManager = (AtmosManager)target; GUIContent speedContent = new GUIContent("Speed", "frequency of Atmos simulation updates (Millieseconds between each update)"); GUIContent SubOperations = new GUIContent("SubOperations", "The number of operations done in each update ( meant for sub millisecond adjustment )"); GUIContent numThreadsContent = new GUIContent("Threads", "not currently implemented, thread count is always locked at one regardless of this setting"); atmosManager.Mode = (AtmosMode)EditorGUILayout.EnumPopup("Mode", atmosManager.Mode); atmosManager.Speed = EditorGUILayout.Slider(speedContent, atmosManager.Speed, 0, 5000); GUI.enabled = atmosManager.Mode == AtmosMode.Threaded; atmosManager.NumberThreads = EditorGUILayout.IntSlider(numThreadsContent, atmosManager.NumberThreads, 1, 1); GUI.enabled = true; AddButtonGroup(atmosManager); EditorGUILayout.LabelField("Update List Count", AtmosThread.GetUpdateListCount().ToString()); EditorUtility.SetDirty(atmosManager); }
private void Update() { if (Mode == AtmosMode.GameLoop && Running) { AtmosThread.RunStep(); } }
public void StartSimulation() { Running = true; if (Mode == AtmosMode.Threaded) { AtmosThread.Start(); } }
public override void DrawGizmo(MetaDataLayer source, Vector3Int position) { MetaDataNode node = source.Get(position, false); if (AtmosThread.IsInUpdateList(node)) { GizmoUtils.DrawCube(position, Color.blue, true); } }
public override void OnInspectorGUI() { AtmosManager atmosManager = (AtmosManager)target; atmosManager.Speed = EditorGUILayout.Slider("Speed", atmosManager.Speed, 0.01f, 1f); atmosManager.NumberThreads = EditorGUILayout.IntSlider("Threads", atmosManager.NumberThreads, 1, 1); EditorGUILayout.LabelField("Update List Count", AtmosThread.GetUpdateListCount().ToString()); EditorUtility.SetDirty(atmosManager); }
public void StopSimulation() { if (!CustomNetworkManager.Instance._isServer) { return; } Running = false; AtmosThread.Stop(); }
private void Update() { if (Mode == AtmosMode.GameLoop && Running) { try { AtmosThread.RunStep(); } catch (Exception e) { Logger.LogError($"Exception in Atmos Thread! Will no longer mix gases!\n{e.StackTrace}", Category.Atmos); throw; } } }
public void StartSimulation() { if (!CustomNetworkManager.Instance._isServer) { return; } Running = true; if (Mode == AtmosMode.Threaded) { AtmosThread.SetSpeed((int)Speed); AtmosThread.Start(); } }
public override void UpdateAt(Vector3Int localPosition) { AtmosThread.Enqueue(metaDataLayer.Get(localPosition)); }
public static void Update(MetaDataNode node) { AtmosThread.Enqueue(node); }
public static void SetInternalSpeed() { AtmosThread.SetSpeed((int)Instance.Speed); }
void OnRoundEnd() { roundStartedServer = false; AtmosThread.ClearAllNodes(); }
public void StopSimulation() { Running = false; AtmosThread.Stop(); }
private void OnValidate() { AtmosThread.SetSpeed(Speed); // TODO set number of threads }