コード例 #1
0
    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();
    }
コード例 #2
0
 void OnRoundEnd()
 {
     roundStartedServer = false;
     AtmosThread.ClearAllNodes();
     inGameNewPipes.Clear();
     inGamePipes.Clear();
 }
コード例 #3
0
    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;
            }
        }
    }
コード例 #4
0
    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);
    }
コード例 #5
0
 private void Update()
 {
     if (Mode == AtmosMode.GameLoop && Running)
     {
         AtmosThread.RunStep();
     }
 }
コード例 #6
0
    public void StartSimulation()
    {
        Running = true;

        if (Mode == AtmosMode.Threaded)
        {
            AtmosThread.Start();
        }
    }
コード例 #7
0
        public override void DrawGizmo(MetaDataLayer source, Vector3Int position)
        {
            MetaDataNode node = source.Get(position, false);

            if (AtmosThread.IsInUpdateList(node))
            {
                GizmoUtils.DrawCube(position, Color.blue, true);
            }
        }
コード例 #8
0
    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);
    }
コード例 #9
0
    public void StopSimulation()
    {
        if (!CustomNetworkManager.Instance._isServer)
        {
            return;
        }

        Running = false;

        AtmosThread.Stop();
    }
コード例 #10
0
 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;
         }
     }
 }
コード例 #11
0
    public void StartSimulation()
    {
        if (!CustomNetworkManager.Instance._isServer)
        {
            return;
        }

        Running = true;

        if (Mode == AtmosMode.Threaded)
        {
            AtmosThread.SetSpeed((int)Speed);
            AtmosThread.Start();
        }
    }
コード例 #12
0
ファイル: AtmosSystem.cs プロジェクト: tsujin/unitystation
 public override void UpdateAt(Vector3Int localPosition)
 {
     AtmosThread.Enqueue(metaDataLayer.Get(localPosition));
 }
コード例 #13
0
 public static void Update(MetaDataNode node)
 {
     AtmosThread.Enqueue(node);
 }
コード例 #14
0
 public static void SetInternalSpeed()
 {
     AtmosThread.SetSpeed((int)Instance.Speed);
 }
コード例 #15
0
 void OnRoundEnd()
 {
     roundStartedServer = false;
     AtmosThread.ClearAllNodes();
 }
コード例 #16
0
    public void StopSimulation()
    {
        Running = false;

        AtmosThread.Stop();
    }
コード例 #17
0
    private void OnValidate()
    {
        AtmosThread.SetSpeed(Speed);

        // TODO set number of threads
    }