Ejemplo n.º 1
0
        public void AppliesToRemove()
        {
            var behavior = new EventBehavior();

            Assert.True(behavior.AppliesTo(new MethodInvocation(
                                               new EventfulMock(),
                                               typeof(EventfulMock).GetEvent(nameof(EventfulMock.Empty)).GetRemoveMethod(),
                                               new EventHandler((s, a) => { }))));
        }
Ejemplo n.º 2
0
    private void Start()
    {
        parent         = transform.parent.GetComponent <EventBehavior>();
        companyManager = GameObject.FindObjectOfType <CompanyManager>();

        tempMessage  = Random.Range(0, 3);
        msgText      = gameObject.transform.GetChild(4).GetComponent <Text>();
        goldText     = gameObject.transform.GetChild(3).GetComponent <Text>();
        goldFishCoin = gameObject.transform.GetChild(3).GetChild(0).GetComponent <Image>();

        numberOfCompanies = companyManager.CompanyList.Length;
        var tempRandom = Random.Range(0, numberOfCompanies);

        companyName = GameObject.FindGameObjectWithTag("Company Manager").GetComponent <CompanyManager>().CompanyList[tempRandom].name;
        var tempWant = Random.Range(0, 2);

        style = GameObject.FindGameObjectWithTag("Company Manager").GetComponent <CompanyManager>().CompanyList[tempRandom].itWants[tempWant].ToString();   //0 1 style randomizer   /why zac why
    }
Ejemplo n.º 3
0
        /// <summary>
        /// Invokes the event.
        /// </summary>
        /// <param name="setting">The setting.</param>
        /// <param name="behavior">The behavior.</param>
        /// <param name="client">The client.</param>
        private void InvokeEvent(EventDefinition setting, EventBehavior behavior, SimpleClientEntity client)
        {
            var message = behavior.TextMessage.ToMessage(new MessageContext
            {
                ClientDatabaseId = client.ClientDatabaseId,
                ClientNickname   = client.Nickname,
                EventName        = setting.Name
            });

            switch (behavior.Behavior)
            {
            case BehaviorType.Poke:
                QueryRunner.PokeClient(client.ClientId, message);
                break;

            case BehaviorType.Message:
                QueryRunner.SendTextMessage(MessageTarget.Client, client.ClientId, message);
                break;

            case BehaviorType.WebRequest:
                SendWebRequest(message);
                break;
            }
        }
Ejemplo n.º 4
0
        public void DispatchEvent(EventBase evt, IPanel panel)
        {
            EventBehavior captureBehavior = EventBehavior.None;

            IEventHandler capturingElement = panel?.GetCapturingElement(PointerId.mousePointerId);

            if (capturingElement == null)
            {
                return;
            }

            // Release mouse capture if capture element is not in a panel.
            VisualElement captureVE = capturingElement as VisualElement;

            if (evt.eventTypeId != MouseCaptureOutEvent.TypeId() && captureVE != null && captureVE.panel == null)
            {
                captureVE.ReleaseMouse();
                return;
            }

            if (panel != null && captureVE != null && captureVE.panel.contextType != panel.contextType)
            {
                return;
            }

            IMouseEvent mouseEvent = evt as IMouseEvent;

            if (mouseEvent != null && (evt.target == null || evt.target == capturingElement))
            {
                // Exclusive processing by capturing element.
                captureBehavior  = EventBehavior.IsCapturable;
                captureBehavior |= EventBehavior.IsSentExclusivelyToCapturingElement;
            }
            else if (evt.imguiEvent != null && evt.target == null)
            {
                // Non exclusive processing by capturing element.
                captureBehavior = EventBehavior.IsCapturable;
            }

            if (evt.eventTypeId == MouseEnterWindowEvent.TypeId() ||
                evt.eventTypeId == MouseLeaveWindowEvent.TypeId() ||
                evt.eventTypeId == WheelEvent.TypeId())
            {
                captureBehavior = EventBehavior.None;
            }

            if ((captureBehavior & EventBehavior.IsCapturable) == EventBehavior.IsCapturable)
            {
                BaseVisualElementPanel basePanel = panel as BaseVisualElementPanel;

                if (mouseEvent != null && basePanel != null)
                {
                    bool shouldRecomputeTopElementUnderMouse = (mouseEvent as IMouseEventInternal)?.recomputeTopElementUnderMouse ?? true;

                    if (shouldRecomputeTopElementUnderMouse)
                    {
                        basePanel.RecomputeTopElementUnderPointer(mouseEvent.mousePosition, evt);
                    }
                }

                evt.dispatch      = true;
                evt.target        = capturingElement;
                evt.currentTarget = capturingElement;
                (capturingElement as CallbackEventHandler)?.HandleEventAtTargetPhase(evt);
                // Do further processing with a target computed the usual way.
                // However, if IsSentExclusivelyToCapturingElement, the only thing remaining to do is ExecuteDefaultAction,
                // which should be done with mouseCapture as the target.
                if ((captureBehavior & EventBehavior.IsSentExclusivelyToCapturingElement) != EventBehavior.IsSentExclusivelyToCapturingElement)
                {
                    evt.target = null;
                }

                evt.currentTarget    = null;
                evt.propagationPhase = PropagationPhase.None;
                evt.dispatch         = false;

                // Do not call HandleEvent again for this element.
                evt.skipElements.Add(capturingElement);

                evt.stopDispatch = (captureBehavior & EventBehavior.IsSentExclusivelyToCapturingElement) == EventBehavior.IsSentExclusivelyToCapturingElement;

                if (evt.target is IMGUIContainer)
                {
                    evt.propagateToIMGUI = true;
                    evt.skipElements.Add(evt.target);
                }
                else
                {
                    evt.propagateToIMGUI = false;
                }
            }
        }
        public void DispatchEvent(EventBase evt, IPanel panel)
        {
            EventBehavior captureBehavior = EventBehavior.None;

            if (MouseCaptureController.mouseCapture == null)
            {
                return;
            }

            // Release mouse capture if capture element is not in a panel.
            VisualElement captureVE = MouseCaptureController.mouseCapture as VisualElement;

            if (evt.eventTypeId != MouseCaptureOutEvent.TypeId() && captureVE != null && captureVE.panel == null)
            {
                MouseCaptureController.ReleaseMouse();
                return;
            }

            if (panel != null && captureVE != null && captureVE.panel.contextType != panel.contextType)
            {
                return;
            }

            IMouseEvent mouseEvent = evt as IMouseEvent;

            if (mouseEvent != null && (evt.target == null || evt.target == MouseCaptureController.mouseCapture))
            {
                // Exclusive processing by capturing element.
                captureBehavior  = EventBehavior.IsCapturable;
                captureBehavior |= EventBehavior.IsSentExclusivelyToCapturingElement;
            }
            else if (evt.imguiEvent != null && evt.target == null)
            {
                // Non exclusive processing by capturing element.
                captureBehavior = EventBehavior.IsCapturable;
            }

            if (evt.eventTypeId == MouseEnterWindowEvent.TypeId() ||
                evt.eventTypeId == MouseLeaveWindowEvent.TypeId() ||
                evt.eventTypeId == WheelEvent.TypeId())
            {
                captureBehavior = EventBehavior.None;
            }

            if ((captureBehavior & EventBehavior.IsCapturable) == EventBehavior.IsCapturable)
            {
                BaseVisualElementPanel basePanel = panel as BaseVisualElementPanel;

                if (mouseEvent != null && basePanel != null)
                {
                    bool shouldRecomputeTopElementUnderMouse = true;
                    if ((IMouseEventInternal)mouseEvent != null)
                    {
                        shouldRecomputeTopElementUnderMouse =
                            ((IMouseEventInternal)mouseEvent).recomputeTopElementUnderMouse;
                    }
                    VisualElement elementUnderMouse = shouldRecomputeTopElementUnderMouse ?
                                                      basePanel.Pick(mouseEvent.mousePosition) :
                                                      basePanel.topElementUnderMouse;

                    basePanel.SetElementUnderMouse(elementUnderMouse, evt);
                }

                IEventHandler originalCaptureElement = MouseCaptureController.mouseCapture;

                evt.dispatch         = true;
                evt.target           = MouseCaptureController.mouseCapture;
                evt.currentTarget    = MouseCaptureController.mouseCapture;
                evt.propagationPhase = PropagationPhase.AtTarget;
                MouseCaptureController.mouseCapture.HandleEvent(evt);

                // Do further processing with a target computed the usual way.
                // However, if mouseEventWasCaptured, the only thing remaining to do is ExecuteDefaultAction,
                // which should be done with mouseCapture as the target.
                if ((captureBehavior & EventBehavior.IsSentExclusivelyToCapturingElement) != EventBehavior.IsSentExclusivelyToCapturingElement)
                {
                    evt.target = null;
                }

                evt.currentTarget    = null;
                evt.propagationPhase = PropagationPhase.None;
                evt.dispatch         = false;

                // Do not call HandleEvent again for this element.
                evt.skipElements.Add(originalCaptureElement);

                evt.stopDispatch     = (captureBehavior & EventBehavior.IsSentExclusivelyToCapturingElement) == EventBehavior.IsSentExclusivelyToCapturingElement;
                evt.propagateToIMGUI = false;
            }
        }
        public void DispatchEvent(EventBase evt, IPanel panel)
        {
            EventBehavior captureBehavior = EventBehavior.None;

            IEventHandler capturingElement = panel?.GetCapturingElement(PointerId.mousePointerId);

            if (capturingElement == null)
            {
                return;
            }

            // Release mouse capture if capture element is not in a panel.
            VisualElement captureVE = capturingElement as VisualElement;

            if (evt.eventTypeId != MouseCaptureOutEvent.TypeId() && captureVE != null && captureVE.panel == null)
            {
                captureVE.ReleaseMouse();
                return;
            }

            // Case 1342115: mouse position is in local panel coordinates; sending event to a target from a different
            // panel will lead to a wrong position, so we don't allow it. Note that in general the mouse-down-move-up
            // sequence still works properly because the OS captures the mouse on the starting EditorWindow.
            if (panel != null && captureVE != null && captureVE.panel != panel)
            {
                return;
            }

            IMouseEvent mouseEvent = evt as IMouseEvent;

            if (mouseEvent != null && (evt.target == null || evt.target == capturingElement))
            {
                // Exclusive processing by capturing element.
                captureBehavior  = EventBehavior.IsCapturable;
                captureBehavior |= EventBehavior.IsSentExclusivelyToCapturingElement;
            }
            else if (evt.imguiEvent != null && evt.target == null)
            {
                // Non exclusive processing by capturing element.
                captureBehavior = EventBehavior.IsCapturable;
            }

            if (evt.eventTypeId == MouseEnterWindowEvent.TypeId() ||
                evt.eventTypeId == MouseLeaveWindowEvent.TypeId() ||
                evt.eventTypeId == WheelEvent.TypeId())
            {
                captureBehavior = EventBehavior.None;
            }

            if ((captureBehavior & EventBehavior.IsCapturable) == EventBehavior.IsCapturable)
            {
                BaseVisualElementPanel basePanel = panel as BaseVisualElementPanel;

                if (mouseEvent != null && basePanel != null)
                {
                    bool shouldRecomputeTopElementUnderMouse = (mouseEvent as IMouseEventInternal)?.recomputeTopElementUnderMouse ?? true;

                    if (shouldRecomputeTopElementUnderMouse)
                    {
                        basePanel.RecomputeTopElementUnderPointer(PointerId.mousePointerId, mouseEvent.mousePosition, evt);
                    }
                }

                evt.dispatch = true;
                evt.target   = capturingElement;
                var skipDisabledElements = evt.skipDisabledElements;
                evt.skipDisabledElements = false;
                (capturingElement as CallbackEventHandler)?.HandleEventAtTargetPhase(evt);
                // Do further processing with a target computed the usual way.
                // However, if IsSentExclusivelyToCapturingElement, the only thing remaining to do is ExecuteDefaultAction,
                // which should be done with mouseCapture as the target.
                if ((captureBehavior & EventBehavior.IsSentExclusivelyToCapturingElement) != EventBehavior.IsSentExclusivelyToCapturingElement)
                {
                    evt.target = null;
                    evt.skipDisabledElements = skipDisabledElements;
                }

                evt.currentTarget    = null;
                evt.propagationPhase = PropagationPhase.None;
                evt.dispatch         = false;

                // Do not call HandleEvent again for this element.
                evt.skipElements.Add(capturingElement);

                evt.stopDispatch = (captureBehavior & EventBehavior.IsSentExclusivelyToCapturingElement) == EventBehavior.IsSentExclusivelyToCapturingElement;

                if (evt.target is IMGUIContainer)
                {
                    evt.propagateToIMGUI = true;
                    evt.skipElements.Add(evt.target);
                }
                else
                {
                    evt.propagateToIMGUI = false;
                }
            }
        }
Ejemplo n.º 7
0
    //private Job job;

    void Start()
    {
        eventB = transform.parent.parent.GetComponent <EventBehavior>();
        //job = transform.parent.parent.GetComponent<Job>();
    }
Ejemplo n.º 8
0
 public void StopListenTo(EventBehavior target, object eventId, Handler handler)
 {
     target.Off(eventId, handler);
 }
Ejemplo n.º 9
0
 public void ListenTo(EventBehavior target, object eventId, Handler handler)
 {
     target.On(eventId, handler);
     On(Channel.GameObject.Destroy, _ => { StopListenTo(target, eventId, handler); });
 }
Ejemplo n.º 10
0
 public void RegisterTrafficListeners(EventBehavior listener)
 {
     _eventBehaviorListeners.Add(listener);
 }