Beispiel #1
0
        public void SimulateFrame()
        {
            // TODO: Not sure about creating hundreds of objects per second.
            // Doesn't seem to cause high memory usage, but further investigation is needed.
            PreUpdate.Raise(this, new UpdateEventArgs(_monitor.FrameRate, _monitor.LastFrameTime, UpdateTimeStep));

            _unprocessedTime += _monitor.LastFrameTime;
            _updates          = 0;

            while (_unprocessedTime >= UpdateTimeStep && _updates < MaxSkippedFrames)
            {
                OnUpdate.Raise(this, new UpdateEventArgs(_monitor.FrameRate, _monitor.LastFrameTime, UpdateTimeStep));

                _simulationEngine.Simulate();

                _unprocessedTime -= UpdateTimeStep;
                _updates++;
            }

            PostUpdate.Raise(this, new UpdateEventArgs(_monitor.FrameRate, _monitor.LastFrameTime, UpdateTimeStep));

            if (EnableRender)
            {
                _renderer.Frame();
                _renderer.Render();
            }
        }
Beispiel #2
0
        /// <inheritdoc />
        public void Update(TimeSpan total, TimeSpan elapsed, bool isRunningSlowly)
        {
            PreUpdate?.Invoke(this, new UpdateEventArgs(total, elapsed, isRunningSlowly));

            InternalUpdate(total, elapsed, isRunningSlowly);

            PostUpdate?.Invoke(this, new UpdateEventArgs(total, elapsed, isRunningSlowly));
        }
Beispiel #3
0
            /// <summary>
            /// Invokes the Xna PreUpdate event.
            /// </summary>
            /// <param name="gameTime"></param>
            public static void InvokePreUpdate(GameTime gameTime)
            {
                var args = new XnaUpdateEventArgs
                {
                    GameTime = gameTime
                };

                PreUpdate.Invoke(args);
            }
Beispiel #4
0
        private void OnTick(object sender, EventArgs args)
        {
            preUpdateSubject.OnNext(Unit.Default);
            PreUpdate?.Invoke(this, EventArgs.Empty);

            scheduler.Run();
            Coroutine.Run();

            updateSubject.OnNext(Unit.Default);
            Update?.Invoke(this, EventArgs.Empty);
        }
        public async Task ShowEdit(TItem item)
        {
            Item = item;
            await PreUpdate.InvokeAsync(item);

            _mode           = "Update";
            _isModalVisible = true;
            TitleDialog     = StringLocalizer["EditTitle"];
            IconDialog      = "fas fa-edit";
            DialogAction    = StringLocalizer["Edit"];
            StateHasChanged();
        }
Beispiel #6
0
        /// <summary>
        /// 更新组件
        /// </summary>
        public void UpdateComponentUnit(int time, Action <Action <int> > method = default)
        {
            CountTime += time;//与主线程的帧率时间保持一致,避更新新过快

            IShipDockComponent item;

            while (CountTime > FrameTimeInScene)
            {
                PreUpdate?.Invoke(mUpdateByTicks, false);

                int compIndex = 0;
                int max       = mUpdateByTicks.Count;
                for (int i = 0; i < max; i++)
                {
                    item = default;

                    RefComponentByIndex(i, ref compIndex, ref mUpdateByTicks, ref item);
                    if (item != default)
                    {
                        if (item.IsSceneUpdate)
                        {
                            continue;
                        }

                        if (item.IsSystemChanged)
                        {
                            if (!mDeletdComponents.Contains(item.ID))
                            {
                                if (method == default)
                                {
                                    item.UpdateComponent(time);
                                }
                                else
                                {
                                    method.Invoke(item.UpdateComponent);
                                }
                            }
                            item.SystemChecked();
                        }
                    }
                }
                FinalUpdate(time);
                CountTime -= FrameTimeInScene;
            }
        }
Beispiel #7
0
 public virtual void Update(float deltaTime)
 {
     PreUpdate?.Invoke(deltaTime);
     if (!enabled)
     {
         return;
     }
     if (IsMouseOver || (!RequireMouseOn && selectedWidgets.Contains(this) && PlayerInput.PrimaryMouseButtonHeld()))
     {
         Hovered?.Invoke();
         System.Diagnostics.Debug.WriteLine("hovered");
         if (RequireMouseOn || PlayerInput.PrimaryMouseButtonDown())
         {
             if ((multiselect && !selectedWidgets.Contains(this)) || selectedWidgets.None())
             {
                 selectedWidgets.Add(this);
                 Selected?.Invoke();
             }
         }
     }
     else if (selectedWidgets.Contains(this))
     {
         System.Diagnostics.Debug.WriteLine("selectedWidgets.Contains(this) -> remove");
         selectedWidgets.Remove(this);
         Deselected?.Invoke();
     }
     if (IsSelected)
     {
         if (PlayerInput.PrimaryMouseButtonDown())
         {
             MouseDown?.Invoke();
         }
         if (PlayerInput.PrimaryMouseButtonHeld())
         {
             MouseHeld?.Invoke(deltaTime);
         }
         if (PlayerInput.PrimaryMouseButtonClicked())
         {
             MouseUp?.Invoke();
         }
     }
     PostUpdate?.Invoke(deltaTime);
 }
Beispiel #8
0
        /// <inheritdoc />
        public void Update(TimeSpan total, TimeSpan elapsed, bool isRunningSlowly)
        {
            PreUpdate?.Invoke(this, new UpdateEventArgs(total, elapsed, isRunningSlowly));

            Mouse.Update(total, elapsed, isRunningSlowly);

            foreach (Dialog dialog in Dialogs)
            {
                dialog.Update(total, elapsed, isRunningSlowly);
            }

            foreach (Window window in Windows)
            {
                window.Update(total, elapsed, isRunningSlowly);
            }

            Dialog.IsShownInCurrentLoopIteration = false;

            PostUpdate?.Invoke(this, new UpdateEventArgs(total, elapsed, isRunningSlowly));
        }
Beispiel #9
0
 public virtual void Update(float deltaTime)
 {
     PreUpdate?.Invoke(deltaTime);
     if (!enabled)
     {
         return;
     }
     if (IsMouseOver || (!RequireMouseOn && selectedWidgets.Contains(this) && PlayerInput.LeftButtonHeld()))
     {
         Hovered?.Invoke();
         if (RequireMouseOn || PlayerInput.LeftButtonDown())
         {
             if ((multiselect && !selectedWidgets.Contains(this)) || selectedWidgets.None())
             {
                 selectedWidgets.Add(this);
                 Selected?.Invoke();
             }
         }
     }
     else if (selectedWidgets.Contains(this))
     {
         selectedWidgets.Remove(this);
         Deselected?.Invoke();
     }
     if (IsSelected)
     {
         if (PlayerInput.LeftButtonDown())
         {
             MouseDown?.Invoke();
         }
         if (PlayerInput.LeftButtonHeld())
         {
             MouseHeld?.Invoke(deltaTime);
         }
         if (PlayerInput.LeftButtonClicked())
         {
             MouseUp?.Invoke();
         }
     }
     PostUpdate?.Invoke(deltaTime);
 }
Beispiel #10
0
        /// <inheritdoc />
        public void Update(TimeSpan total, TimeSpan elapsed, bool isRunningSlowly)
        {
            if (!IsVisible)
            {
                return;
            }

            PreUpdate?.Invoke(this, new UpdateEventArgs(total, elapsed, isRunningSlowly));

            if (!IsLoaded)
            {
                Load();
            }

            this.location.X = destination.X;
            this.location.Y = destination.Y;

            if (Intersects(Mouse.X, Mouse.Y))
            {
                if (!isMouseIntersectingPrevious)
                {
                    MouseEnter?.Invoke(this, EventArgs.Empty);
                }

                this.isMouseIntersectingPrevious = true;
            }
            else
            {
                if (isMouseIntersectingPrevious)
                {
                    MouseLeave?.Invoke(this, EventArgs.Empty);
                }

                this.isMouseIntersectingPrevious = false;
            }

            InternalUpdate(total, elapsed, isRunningSlowly);

            PostUpdate?.Invoke(this, new UpdateEventArgs(total, elapsed, isRunningSlowly));
        }
Beispiel #11
0
        /// <inheritdoc />
        public void Update(TimeSpan total, TimeSpan elapsed, bool isRunningSlowly)
        {
            if (!IsWithinGameWindow(core.Location.X, core.Location.Y))
            {
                return;
            }

            lastLocation = core.Location;

            PreUpdate?.Invoke(this, new UpdateEventArgs(total, elapsed, isRunningSlowly));

            if (Left == MouseButtonState.Released && leftPrevious == MouseButtonState.Pressed)
            {
                ButtonUp?.Invoke(this, new MouseButtonClickEventArgs(X, Y, MouseButton.Left));
            }
            else if (Middle == MouseButtonState.Released && middlePrevious == MouseButtonState.Pressed)
            {
                ButtonUp?.Invoke(this, new MouseButtonClickEventArgs(X, Y, MouseButton.Middle));
            }
            else if (Right == MouseButtonState.Released && rightPrevious == MouseButtonState.Pressed)
            {
                ButtonUp?.Invoke(this, new MouseButtonClickEventArgs(X, Y, MouseButton.Right));
            }
            else if (X1 == MouseButtonState.Released && x1Previous == MouseButtonState.Pressed)
            {
                ButtonUp?.Invoke(this, new MouseButtonClickEventArgs(X, Y, MouseButton.X1));
            }
            else if (X2 == MouseButtonState.Released && x2Previous == MouseButtonState.Pressed)
            {
                ButtonUp?.Invoke(this, new MouseButtonClickEventArgs(X, Y, MouseButton.X2));
            }

            leftPrevious   = Left;
            middlePrevious = Middle;
            rightPrevious  = Right;
            x1Previous     = X1;
            x2Previous     = X2;

            PostUpdate?.Invoke(this, new UpdateEventArgs(total, elapsed, isRunningSlowly));
        }
Beispiel #12
0
 void OnPreUpdate()
 {
     PreUpdate?.Invoke();
 }
        private void Update()
        {
            PreUpdate?.Invoke(this, null);
            UpdatedEvents.Clear();

            //Blackout. TODO: Cleanup this a bit. Maybe push blank effect frame to keyboard incase it has existing stuff displayed
            if ((Global.Configuration.time_based_dimming_enabled &&
                 Utils.Time.IsCurrentTimeBetween(Global.Configuration.time_based_dimming_start_hour, Global.Configuration.time_based_dimming_start_minute, Global.Configuration.time_based_dimming_end_hour, Global.Configuration.time_based_dimming_end_minute)))
            {
                StopUnUpdatedEvents();
                return;
            }

            string raw_process_name = Path.GetFileName(processMonitor.ProcessPath);

            UpdateProcess();
            EffectsEngine.EffectFrame newFrame = new EffectsEngine.EffectFrame();



            //TODO: Move these IdleEffects to an event
            //this.UpdateIdleEffects(newFrame);

            ILightEvent profile = GetCurrentProfile(out bool preview);

            timerInterval = profile?.Config?.UpdateInterval ?? defaultTimerInterval;

            // If the current foreground process is excluded from Aurora, disable the lighting manager
            if ((profile is Desktop.Desktop && !profile.IsEnabled) || Global.Configuration.excluded_programs.Contains(raw_process_name))
            {
                StopUnUpdatedEvents();
                Global.dev_manager.Shutdown();
                Global.effengine.PushFrame(newFrame);
                return;
            }
            else
            {
                Global.dev_manager.InitializeOnce();
            }

            if (Global.Configuration.OverlaysInPreview || !preview)
            {
                foreach (var underlay in Underlays)
                {
                    ILightEvent @event = Events[underlay];
                    if (@event.IsEnabled && (@event.Config.ProcessNames == null || ProcessUtils.AnyProcessExists(@event.Config.ProcessNames)))
                    {
                        UpdateEvent(@event, newFrame);
                    }
                }
            }

            //Need to do another check in case Desktop is disabled or the selected preview is disabled
            if (profile.IsEnabled)
            {
                UpdateEvent(profile, newFrame);
            }

            if (Global.Configuration.OverlaysInPreview || !preview)
            {
                // Update any overlays registered in the Overlays array. This includes applications with type set to Overlay and things such as skype overlay
                foreach (var overlay in Overlays)
                {
                    ILightEvent @event = Events[overlay];
                    if (@event.IsEnabled && (@event.Config.ProcessNames == null || ProcessUtils.AnyProcessExists(@event.Config.ProcessNames)))
                    {
                        UpdateEvent(@event, newFrame);
                    }
                }

                // Update any overlays that are timer-based (e.g. the volume overlay that appears for a few seconds at a time)
                TimedListObject[] overlay_events = overlays.ToArray();
                foreach (TimedListObject evnt in overlay_events)
                {
                    if ((evnt.item as LightEvent).IsEnabled)
                    {
                        UpdateEvent((evnt.item as LightEvent), newFrame);
                    }
                }

                // Update any applications that have overlay layers if that application is open
                var events = GetOverlayActiveProfiles().ToList();

                //Add the Light event that we're previewing to be rendered as an overlay
                if (preview && Global.Configuration.OverlaysInPreview && !events.Contains(profile))
                {
                    events.Add(profile);
                }

                foreach (var @event in events)
                {
                    @event.UpdateOverlayLights(newFrame);
                }

                UpdateIdleEffects(newFrame);
            }

            Global.effengine.PushFrame(newFrame);

            StopUnUpdatedEvents();
            PostUpdate?.Invoke(this, null);
        }
Beispiel #14
0
        private void Update()
        {
            PreUpdate?.Invoke(this, null);
            UpdatedEvents.Clear();

            //Blackout. TODO: Cleanup this a bit. Maybe push blank effect frame to keyboard incase it has existing stuff displayed
            if ((Global.Configuration.time_based_dimming_enabled &&
                 Utils.Time.IsCurrentTimeBetween(Global.Configuration.time_based_dimming_start_hour, Global.Configuration.time_based_dimming_start_minute, Global.Configuration.time_based_dimming_end_hour, Global.Configuration.time_based_dimming_end_minute)))
            {
                StopUnUpdatedEvents();
                return;
            }

            string raw_process_name = Path.GetFileName(processMonitor.ProcessPath);

            UpdateProcess();
            EffectsEngine.EffectFrame newFrame = new EffectsEngine.EffectFrame();



            //TODO: Move these IdleEffects to an event
            //this.UpdateIdleEffects(newFrame);

            ILightEvent profile = GetCurrentProfile(out bool preview);

            timerInterval = profile?.Config?.UpdateInterval ?? defaultTimerInterval;

            // If the current foreground process is excluded from Aurora, disable the lighting manager
            if ((profile is Desktop.Desktop && !profile.IsEnabled) || Global.Configuration.excluded_programs.Contains(raw_process_name))
            {
                StopUnUpdatedEvents();
                Global.dev_manager.Shutdown();
                Global.effengine.PushFrame(newFrame);
                return;
            }
            else
            {
                Global.dev_manager.InitializeOnce();
            }

            //Need to do another check in case Desktop is disabled or the selected preview is disabled
            if (profile.IsEnabled)
            {
                UpdateEvent(profile, newFrame);
            }

            // Overlay layers
            if (!preview || Global.Configuration.OverlaysInPreview)
            {
                foreach (var @event in GetOverlayActiveProfiles())
                {
                    @event.UpdateOverlayLights(newFrame);
                }

                //Add the Light event that we're previewing to be rendered as an overlay (assuming it's not already active)
                if (preview && Global.Configuration.OverlaysInPreview && !GetOverlayActiveProfiles().Contains(profile))
                {
                    profile.UpdateOverlayLights(newFrame);
                }

                UpdateIdleEffects(newFrame);
            }


            Global.effengine.PushFrame(newFrame);

            StopUnUpdatedEvents();
            PostUpdate?.Invoke(this, null);
        }
Beispiel #15
0
        private void Update()
        {
            PreUpdate?.Invoke(this, null);

            //Blackout. TODO: Cleanup this a bit. Maybe push blank effect frame to keyboard incase it has existing stuff displayed
            if ((Global.Configuration.time_based_dimming_enabled &&
                 Utils.Time.IsCurrentTimeBetween(Global.Configuration.time_based_dimming_start_hour, Global.Configuration.time_based_dimming_start_minute, Global.Configuration.time_based_dimming_end_hour, Global.Configuration.time_based_dimming_end_minute)))
            {
                return;
            }

            string raw_process_name = Path.GetFileName(processMonitor.ProcessPath);

            UpdateProcess();
            EffectsEngine.EffectFrame newFrame = new EffectsEngine.EffectFrame();



            //TODO: Move these IdleEffects to an event
            //this.UpdateIdleEffects(newFrame);

            ILightEvent profile = GetCurrentProfile(out bool preview);

            timerInterval = profile?.Config?.UpdateInterval ?? defaultTimerInterval;

            if ((profile is Desktop.Desktop && !profile.IsEnabled) || Global.Configuration.excluded_programs.Contains(raw_process_name))
            {
                Global.dev_manager.Shutdown();
                Global.effengine.PushFrame(newFrame);
                return;
            }
            else
            {
                Global.dev_manager.InitializeOnce();
            }


            if (Global.Configuration.OverlaysInPreview || !preview)
            {
                foreach (var underlay in Underlays)
                {
                    ILightEvent @event = Events[underlay];
                    if (@event.IsEnabled && (@event.Config.ProcessNames == null || ProcessUtils.AnyProcessExists(@event.Config.ProcessNames)))
                    {
                        @event.UpdateLights(newFrame);
                    }
                }
            }

            //Need to do another check in case Desktop is disabled or the selected preview is disabled
            if (profile.IsEnabled)
            {
                profile.UpdateLights(newFrame);
            }

            if (Global.Configuration.OverlaysInPreview || !preview)
            {
                foreach (var overlay in Overlays)
                {
                    ILightEvent @event = Events[overlay];
                    if (@event.IsEnabled && (@event.Config.ProcessNames == null || ProcessUtils.AnyProcessExists(@event.Config.ProcessNames)))
                    {
                        @event.UpdateLights(newFrame);
                    }
                }

                //Add overlays
                TimedListObject[] overlay_events = overlays.ToArray();
                foreach (TimedListObject evnt in overlay_events)
                {
                    if ((evnt.item as LightEvent).IsEnabled)
                    {
                        (evnt.item as LightEvent).UpdateLights(newFrame);
                    }
                }

                UpdateIdleEffects(newFrame);
            }

            Global.effengine.PushFrame(newFrame);

            PostUpdate?.Invoke(this, null);
        }
Beispiel #16
0
 internal void _PreUpdate() => PreUpdate?.Invoke(this);