Beispiel #1
0
        /// <summary>
        /// Performs a single update cycle.
        /// </summary>
        /// <param name="forceFixedStep">If true use a timestep thats equal to <see cref="Time.MillisecondsPerFrame"/> for the update</param>
        public static void Update(bool forceFixedStep)
        {
            isUpdating = true;
            Profile.TimeUpdate.BeginMeasure();

            Time.FrameTick(forceFixedStep, true);
            Profile.FrameTick();
            VisualLogs.UpdateLogEntries();
            pluginManager.InvokeBeforeUpdate();
            UpdateUserInput();
            Scene.Current.Update();
            sound.Update();
            pluginManager.InvokeAfterUpdate();
            VisualLogs.PrepareRenderLogEntries();

            // Perform a cleanup step to catch all DisposeLater calls from this update
            RunCleanup();

            // Perform any previously scheduled Scene switch
            Scene.PerformScheduledSwitch();

            Profile.TimeUpdate.EndMeasure();
            isUpdating = false;

            if (terminateScheduled)
            {
                Terminate();
            }
        }
Beispiel #2
0
        internal static void EditorUpdate(IEnumerable <GameObject> updateObjects, bool simulateGame, bool forceFixedStep)
        {
            isUpdating = true;
            Profile.TimeUpdate.BeginMeasure();

            Time.FrameTick(forceFixedStep, simulateGame);
            Profile.FrameTick();

            if (simulateGame)
            {
                VisualLogs.UpdateLogEntries();
                pluginManager.InvokeBeforeUpdate();

                UpdateUserInput();
                Scene.Current.Update();

                List <ICmpUpdatable> updatables = new List <ICmpUpdatable>();
                foreach (GameObject obj in updateObjects)
                {
                    if (obj.Scene == Scene.Current)
                    {
                        continue;
                    }

                    updatables.Clear();
                    obj.GetComponents(updatables);
                    for (int i = 0; i < updatables.Count; i++)
                    {
                        if (!(updatables[i] as Component).Active)
                        {
                            continue;
                        }
                        updatables[i].OnUpdate();
                    }
                }

                pluginManager.InvokeAfterUpdate();
            }
            else
            {
                Scene.Current.EditorUpdate();

                List <ICmpUpdatable> updatables = new List <ICmpUpdatable>();
                foreach (GameObject obj in updateObjects)
                {
                    updatables.Clear();
                    obj.GetComponents(updatables);
                    for (int i = 0; i < updatables.Count; i++)
                    {
                        if (!(updatables[i] as Component).Active)
                        {
                            continue;
                        }
                        updatables[i].OnUpdate();
                    }
                }
            }

            sound.Update();
            VisualLogs.PrepareRenderLogEntries();

            // Perform a cleanup step to catch all DisposeLater calls from this update
            RunCleanup();

            if (simulateGame)
            {
                // Perform any previously scheduled Scene switch
                Scene.PerformScheduledSwitch();
            }

            Profile.TimeUpdate.EndMeasure();
            isUpdating = false;

            if (terminateScheduled)
            {
                Terminate();
            }
        }