Beispiel #1
0
        public void StopListening(GraphStack stack)
        {
            var data = stack.GetElementData <Data>(this);

            if (!data.isListening)
            {
                return;
            }

            var hook = new EventHook(EventHooks.Update, stack.machine);

            EventBus.Unregister(hook, data.update);
            data.update      = null;
            data.isListening = false;
        }
        public void StartListening(GraphStack stack)
        {
            var data = stack.GetElementData <Data>(this);

            if (data.UpdateAction != null)
            {
                return;
            }

            var reference = stack.ToReference();

            data.UpdateAction = args => OnUpdate(reference);

            var hook = new EventHook(EventHooks.Update, stack.machine);

            EventBus.Register(hook, data.UpdateAction);
        }
Beispiel #3
0
        public void StartListening(GraphStack stack)
        {
            var data = stack.GetElementData <Data>(this);

            if (data.isListening)
            {
                return;
            }

            var reference = stack.ToReference();
            var hook      = new EventHook(EventHooks.Update, stack.machine);
            Action <EmptyEventArgs> update = args => TriggerUpdate(reference);

            EventBus.Register(hook, update);
            data.update      = update;
            data.isListening = true;
        }
        public void StopListening(GraphStack stack)
        {
            var data = stack.GetElementData <Data>(this);

            if (data.UpdateAction == null)
            {
                return;
            }

            var hook = new EventHook(EventHooks.Update, stack.machine);

            EventBus.Unregister(hook, data.UpdateAction);

            if (data.IsOpened)
            {
                data.Close();
            }
            data.UpdateAction = null;
        }
        public virtual void StartListening(GraphStack stack)
        {
            var data = stack.GetElementData <Data>(this);

            if (data.isListening)
            {
                return;
            }

            if (register)
            {
                var            reference = stack.ToReference();
                var            hook      = GetHook(reference);
                Action <TArgs> handler   = args => Trigger(reference, args);
                EventBus.Register(hook, handler);

                data.hook    = hook;
                data.handler = handler;
            }

            data.isListening = true;
        }
Beispiel #6
0
        private void UpdateTarget(GraphStack stack)
        {
            var data = stack.GetElementData <Data>(this);

            var wasListening = data.isListening;

            var newTarget = Flow.FetchValue <GameObject>(target, stack.ToReference());

            if (newTarget != data.target)
            {
                if (wasListening)
                {
                    StopListening(stack);
                }

                data.target = newTarget;

                if (wasListening)
                {
                    StartListening(stack, false);
                }
            }
        }
        public virtual void StopListening(GraphStack stack)
        {
            var data = stack.GetElementData <Data>(this);

            if (!data.isListening)
            {
                return;
            }

            // The coroutine's flow will dispose at the next frame, letting us
            // keep the current flow for clean up operations if needed
            foreach (var activeCoroutine in data.activeCoroutines)
            {
                activeCoroutine.StopCoroutine(false);
            }

            if (register)
            {
                EventBus.Unregister(data.hook, data.handler);
                data.handler = null;
            }

            data.isListening = false;
        }
Beispiel #8
0
        protected void StartListening(GraphStack stack, bool updateTarget)
        {
            if (updateTarget)
            {
                UpdateTarget(stack);
            }

            var data = stack.GetElementData <Data>(this);

            if (data.target == null)
            {
                return;
            }

            if (UnityThread.allowsAPI)
            {
                if (MessageListenerType != null) // can be null. CustomEvent doesn't need a message listener
                {
                    MessageListener.AddTo(MessageListenerType, data.target);
                }
            }

            base.StartListening(stack);
        }
Beispiel #9
0
        public override void StartListening(GraphStack stack)
        {
            base.StartListening(stack);

            var data = stack.GetElementData <Data>(this);
        }