Esempio n. 1
0
    public virtual void UpdateButton()
    {
        if (Selected)
        {
            Image.sprite = SelectedSprite;
        }
        else if (!Enabled)
        {
            Image.sprite = DisabledSprite;
        }
        else if (Pressed)
        {
            Image.sprite = PressedSprite;
        }
        else if (PointerInside)
        {
            Image.sprite = HighlightedSprite;
        }
        else
        {
            Image.sprite = NormalSprite;
        }

        OnUpdateEvent?.Invoke();
    }
Esempio n. 2
0
        public void Update(float deltaTime)
        {
            //pump message
            PumpMessage();

            SenderEvent(new UpdateEvent(DateTime.Now, deltaTime));
            SenderEvent(new RenderEvent(DateTime.Now, deltaTime));

            //process the event
            while (EventCount != 0)
            {
                switch (GetEvent(true))
                {
                case UpdateEvent update: OnUpdateEvent?.Invoke(this, update); break;

                case KeyBoardEvent keyBoard: OnKeyBoardEvent?.Invoke(this, keyBoard); break;

                case MouseClickEvent mouseClick: OnMouseClickEvent?.Invoke(this, mouseClick); break;

                case MouseWheelEvent mouseWheel: OnMouseWhellEvent?.Invoke(this, mouseWheel); break;

                case MouseMoveEvent mouseMove: OnMouseMoveEvent?.Invoke(this, mouseMove); break;

                case SizeChangeEvent sizeChange: OnSizeChangeEvent?.Invoke(this, sizeChange); break;
                }
            }
        }
Esempio n. 3
0
 private void Update()
 {
     if (OnUpdateEvent != null)
     {
         OnUpdateEvent.Invoke();
     }
 }
Esempio n. 4
0
        private bool HandleFrameworkUpdate(IntPtr framework)
        {
            try {
                Gui.Chat.UpdateQueue(this);
                Network.UpdateQueue(this);
            } catch (Exception ex) {
                Log.Error(ex, "Exception while handling Framework::Update hook.");
            }

            try {
                if (StatsEnabled && OnUpdateEvent != null)
                {
                    // Stat Tracking for Framework Updates
                    var invokeList = OnUpdateEvent.GetInvocationList();
                    var notUpdated = StatsHistory.Keys.ToList();
                    // Individually invoke OnUpdate handlers and time them.
                    foreach (var d in invokeList)
                    {
                        statsStopwatch.Restart();
                        d.Method.Invoke(d.Target, new object[] { this });
                        statsStopwatch.Stop();
                        var key = $"{d.Target}::{d.Method.Name}";
                        if (notUpdated.Contains(key))
                        {
                            notUpdated.Remove(key);
                        }
                        if (!StatsHistory.ContainsKey(key))
                        {
                            StatsHistory.Add(key, new List <double>());
                        }
                        StatsHistory[key].Add(statsStopwatch.Elapsed.TotalMilliseconds);
                        if (StatsHistory[key].Count > 1000)
                        {
                            StatsHistory[key].RemoveRange(0, StatsHistory[key].Count - 1000);
                        }
                    }

                    // Cleanup handlers that are no longer being called
                    foreach (var key in notUpdated)
                    {
                        if (StatsHistory[key].Count > 0)
                        {
                            StatsHistory[key].RemoveAt(0);
                        }
                        else
                        {
                            StatsHistory.Remove(key);
                        }
                    }
                }
                else
                {
                    OnUpdateEvent?.Invoke(this);
                }
            } catch (Exception ex) {
                Log.Error(ex, "Exception while dispatching Framework::Update event.");
            }

            return(this.updateHook.Original(framework));
        }
        /// <summary>
        /// Updates the world scale using the latest units.
        /// </summary>
        public void UpdateWorldScale()
        {
            float newScale = (Measurement == ScaleMeasurement.CustomUnits) ? CustomValue : (float)Measurement;

            if (newScale != _scale)
            {
                _scale = (Measurement == ScaleMeasurement.CustomUnits) ? CustomValue : (float)Measurement;

                float previousWorldScale = ContentParent.lossyScale.x;

                // Update the world scale on the main camera's parent.
                ContentParent.localScale = new Vector3(_scale, _scale, _scale);

                float newWorldScale = ContentParent.lossyScale.x;

                // Calculate the updated clip distances based on the world scale.
                // Assumes the original clip distances are in meters.
                Camera mainCamera = Camera.main;
                mainCamera.nearClipPlane = mainCamera.nearClipPlane / previousWorldScale * newWorldScale;
                mainCamera.farClipPlane  = mainCamera.farClipPlane / previousWorldScale * newWorldScale;

                #if PLATFORM_LUMIN
                // Notify the MLDevice the scale has changed.
                MLDevice.UpdateWorldScale();
                #endif
            }

            OnUpdateEvent?.Invoke(Scale, Units);
        }
Esempio n. 6
0
 public CoreBehavior()
 {
     BehaviorManager.Get.AddBehavior(this);
     Start();
     onUpdateEvent     = Update;
     onLateUpdateEvent = LateUpdate;
     onDestroyEvent    = OnDestroy;
 }
Esempio n. 7
0
 protected virtual void OnUpdate(float value)
 {
     if (canvas != null)
     {
         canvas.alpha = value;
         OnUpdateEvent?.Invoke(value);
     }
 }
Esempio n. 8
0
 /// <summary>
 /// Atualiza a entidade.
 /// </summary>
 /// <param name="gameTime">Obtém o acesso aos tempos de jogo.</param>
 public void Update(GameTime gameTime)
 {
     if (IsEnabled)
     {
         OnUpdate(gameTime);
         Transform.Update(gameTime);
         OnUpdateEvent?.Invoke(this, gameTime);
     }
 }
        public void Update()
        {
            OnUpdateEvent?.Invoke();

            lock (executeOnUpdate)
            {
                while (executeOnUpdate.Count > 0)
                {
                    executeOnUpdate.Dequeue()?.Invoke();
                }
            }
        }
    public void Update()
    {
        if (!running)
        {
            return;
        }
        OnUpdateEvent?.Invoke();

        if (IsComplete())
        {
            running = false;
            OnCompleteEvent?.Invoke();
        }
    }
        public void Update(EventModel ev)
        {
            if (_events.ContainsKey(ev.ID))
            {
                var oldEV = _events[ev.ID].Copy();

                _events[ev.ID] = ev;

                OnUpdateEvent?.Invoke(oldEV, ev);
            }
            else
            {
                Add(ev);
            }
        }
Esempio n. 12
0
        public override void OnGetSamples(byte[] buffer, int count)
        {
            //Copy bytes, and overlap if needed
            for (int i = 0; i < buffer.Length; i += 1)
            {
                int index = (i + bufferPosition) % rewindBuffer.Length;
                rewindBuffer[index] = buffer[i];
            }
            if (buffer.Length + bufferPosition >= rewindBuffer.Length)
            {
                full = true;
            }
            bufferPosition = (buffer.Length + bufferPosition) % rewindBuffer.Length;

            //Send events
            OnUpdateEvent?.Invoke();
        }
Esempio n. 13
0
        private bool HandleFrameworkUpdate(IntPtr framework)
        {
            try {
                Gui.Chat.UpdateQueue(this);
                Network.UpdateQueue(this);
            } catch (Exception ex) {
                Log.Error(ex, "Exception while handling Framework::Update hook.");
            }

            try {
                OnUpdateEvent?.Invoke(this);
            } catch (Exception ex) {
                Log.Error(ex, "Exception while dispatching Framework::Update event.");
            }

            return(this.updateHook.Original(framework));
        }
Esempio n. 14
0
        //Thread issue with the queues. something else is dequeuing them some how.
        public void Update(float deltaTime)
        {
            if (Parent == null && UID != 0)
            {
                return;
            }
            OnUpdate(deltaTime);

            if (childrenChanged)
            {
                lock (childModification) {
                    while (toBeRemoved.Count > 0)
                    {
                        GameObject obj = toBeRemoved.Dequeue();
                        children.Remove(obj);
                        invokationQueue.Enqueue(obj.Destroyed);
                        invokationQueue.Enqueue(() => { OnChildRemoved?.Invoke(this, obj); });
                    }
                    while (toBeAdded.Count > 0)
                    {
                        GameObject obj = toBeAdded.Dequeue();
                        children.Add(obj);
                        invokationQueue.Enqueue(obj.Added);
                        invokationQueue.Enqueue(() => { OnChildAdded?.Invoke(this, obj); });
                    }
                    childrenChanged = false;
                }
            }

            lock (childModification)
                while (invokationQueue.Count > 0)
                {
                    invokationQueue.Dequeue()();
                }

            //This lock was (possibily) causing deadlocks so i removed it, ill keep it commented for now though.
            //lock (childModification) {
            foreach (var child in children)
            {
                child.Update(deltaTime);
            }
            OnUpdateEvent?.Invoke(this);
            //}
        }
Esempio n. 15
0
        internal void Enter()
        {
            var stepStatus = GetStatus();

            if (stepStatus != Status.None && stepStatus != Status.InProgress)
            {
                throw new ApplicationException($"Cannot enter a completed step. Step status: {stepStatus}");
            }

            foreach (var a in Actions.Where(x => x.Status == Status.None))
            {
                //maybe in the future this should use similar start status to above
                a.OnExitEvent   += ActionExit;
                a.OnUpdateEvent += ActionUpdate;
                a.Enter();
            }

            OnUpdateEvent?.Invoke(this, EventArgs.Empty);
        }
Esempio n. 16
0
        private void buttonUpdate_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Update this event?", "Security", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                var userId     = currentUser.Keys.FirstOrDefault();
                var userName   = currentUser.Values.FirstOrDefault();
                var eventId    = Convert.ToInt32(dataGridViewEvent.CurrentRow.Cells[0].Value.ToString());
                var invitation = Convert.ToInt32(dataGridViewEvent.CurrentRow.Cells[6].Value.ToString());

                if (!string.IsNullOrEmpty(textBoxCreatorName.Text) &&
                    userName == textBoxCreatorName.Text)
                {
                    var userModel = new UserModel()
                    {
                        Id   = userId,
                        Name = userName,
                    };

                    var eventModel = new EventModel()
                    {
                        Id          = eventId,
                        UserId      = userId,
                        Description = textBoxDescription.Text,
                        Date        = GetDateTime(dateTimePickerDate.Value, Convert.ToInt32(comboBoxHour.SelectedItem)),
                        Location    = textBoxLocation.Text,
                        IsExclusive = checkBoxExclusive.Checked,
                        Invitation  = invitation,
                        Guests      = invitationGuests.Keys.ToList(),
                    };

                    OnUpdateEvent?.Invoke(eventModel, userModel);
                }
                else
                {
                    MessageBox.Show("Invalid Parameters!");
                }
            }
        }
 public override void OnGetSamples(byte[] buffer, int count)
 {
     output.Write(buffer);
     bytesWritten += buffer.Length;
     OnUpdateEvent?.Invoke();
 }
Esempio n. 18
0
 /// <summary>
 /// Update is called once per frame
 /// </summary>
 void Update()
 {
     BeforeUpdateSpeed();
     OnUpdateEvent?.Invoke();
     AfterUpdate();
 }
Esempio n. 19
0
 public void Update()
 {
     OnUpdateEvent?.Invoke();
 }
 private void Update()
 {
     OnUpdateEvent?.Invoke();
     OnUpdateAction?.Invoke();
 }
Esempio n. 21
0
 public Task Update(ConfirmRef confirmRef)
 {
     return(OnUpdateEvent?.Invoke(confirmRef));
 }
Esempio n. 22
0
 public override void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     OnUpdateEvent?.Invoke();
 }
Esempio n. 23
0
 public Task Update(ModalRef modalRef)
 {
     return(OnUpdateEvent?.Invoke(modalRef));
 }
Esempio n. 24
0
 protected override void OnUpdate()
 {
     OnUpdateEvent?.Invoke(Node);
 }
Esempio n. 25
0
 private void ActionUpdate(object sender, EventArgs e)
 {
     OnUpdateEvent?.Invoke(this, EventArgs.Empty);
 }
Esempio n. 26
0
 protected virtual void OnUpdateHandlerEvent(AppVersionEventArgs e)
 {
     OnUpdateEvent?.Invoke(this, e);
 }
Esempio n. 27
0
 private void Update()
 {
     OnUpdateEvent?.Invoke();
 }
Esempio n. 28
0
 /// <summary>
 /// Update a drawer
 /// </summary>
 /// <param name="drawerRef"></param>
 /// <returns></returns>
 public async Task UpdateAsync(DrawerRef drawerRef)
 {
     await(OnUpdateEvent?.Invoke(drawerRef) ?? Task.CompletedTask);
 }
Esempio n. 29
0
 public void ResetBuffer()
 {
     Init();
     bufferPosition = 0;
     OnUpdateEvent?.Invoke();
 }
Esempio n. 30
0
 protected void OnUpdate(float time, float deltaTime)
 {
     OnUpdateEvent?.Invoke(time, deltaTime);
 }