Пример #1
0
 /// <summary>
 /// Adds a String and OnEvent to the Susbribers Dictionary
 /// </summary>
 /// <param name="sPub"> As stated before. The awaited message from publisher</param>
 /// <param name="onEvent">OnEvent functions to be called when message is later resieved</param>
 public void Subsribe(string sPub, OnEvent onEvent)
 {
     if (Subscribers != null && Subscribers.ContainsKey(sPub.ToLower()))
         Subscribers[sPub.ToLower()] += onEvent;
     else
         Subscribers.Add(sPub.ToLower(), onEvent);
 }
Пример #2
0
 // Use this for initialization
 void Start()
 {
     OnPuzzleCompletion+=CompletePuzzle;
     GameObject[] puzzleObjects = GameObject.FindGameObjectsWithTag("puzzle");
     foreach(GameObject puzzle in puzzleObjects)
     {
         puzzle.GetComponent<ObjectController>().OnCompletion += CompletePuzzle;
     }
 }
Пример #3
0
 public void AddListener(EVENT_TYPE event_type,OnEvent listener)
 {
     List<OnEvent> ListenList = null;
     // if the event_type is exist
     if (Listeners.TryGetValue(event_type, out ListenList)) {
         ListenList.Add(listener);
         return;
     }
     //if the event_type is new
     ListenList = new List<OnEvent>();
     ListenList.Add(listener);
     Listeners.Add (event_type,ListenList);
 }
Пример #4
0
    // Use this for initialization
    public void AddListener(string eventType, OnEvent listener)
    {
        List<OnEvent> listenList = null;

        if (listeners.TryGetValue(eventType, out listenList))
        {
            listenList.Add(listener);
            return;
        }

        listenList = new List<OnEvent>();
        listenList.Add(listener);

        listeners.Add(eventType, listenList);
        //Debug.Log(eventType);
    }
Пример #5
0
    //-----------------------------------------------------------
    /// <summary>
    /// Function to add specified listener-object to array of listeners
    /// </summary>
    /// <param name="Event_Type">Event to Listen for</param>
    /// <param name="Listener">Object to listen for event</param>
    public void AddListener(EVENT_TYPE Event_Type, OnEvent Listener)
    {
        //List of listeners for this event
        OnEvent delegateListener;

        //New item to be added. Check for existing event type key. If one exists, add to list
        if (Listeners.TryGetValue(Event_Type, out delegateListener))
        {
            //List exists, so add new item
            delegateListener += Listener;
            return;
        }

        //Otherwise create new list as dictionary key
        delegateListener += Listener;
        Listeners.Add(Event_Type, delegateListener); //Add to internal listeners list
    }
Пример #6
0
    public void RemoveListener(EVENT_TYPE event_type,OnEvent listener)
    {
        List<OnEvent> ListenList = null;
        if (Listeners.TryGetValue(event_type, out ListenList)) {
            // this event is exists
            // then find if the listener is listening this event
            if(ListenList.Contains(listener)){
                ListenList.Remove(listener);
            }

            return;

        }else{
            // the event is not exist check the name again
            return;
        }
    }
Пример #7
0
    //-----------------------------------------------------------
    /// <summary>
    /// Function to add listener to array of listeners
    /// </summary>
    /// <param name="Event_Type">Event to Listen for</param>
    /// <param name="Listener">Object to listen for event</param>
    public void AddListener(EVENT_TYPE Event_Type, OnEvent
    Listener)
    {
        //List of listeners for this event
        List<OnEvent> ListenList = null;

        // Check existing event type key. If exists, add to

        if(Listeners.TryGetValue(Event_Type, out ListenList))
        {
            //List exists, so add new item
            ListenList.Add(Listener);
            return;
        }

        //Otherwise create new list as dictionary key
        ListenList = new List<OnEvent>();
        ListenList.Add(Listener);
        Listeners.Add(Event_Type, ListenList);
    }
Пример #8
0
        public static void AddListener(int eventIndex, OnEvent listener)
        {
            // Temp listeners list
            List<OnEvent> tempListenersList = null;

            // If there's already a list for this event type, copy it to the temp ListenList (the out parameter)
            if(Listeners.TryGetValue(eventIndex, out tempListenersList))
            {
                // add this listener to it
                tempListenersList.Add(listener);
                return;
            }

            //Otherwise, we'll need a new list and add this as the first listener.
            tempListenersList = new List<OnEvent>();
            tempListenersList.Add(listener);

            // Add the temp list back to the main one.
            Listeners.Add(eventIndex, tempListenersList);
        }
Пример #9
0
 public bool RemoveEvent(string eventType, OnEvent x = null)
 {
     if (x==null)
         listeners.Remove(eventType);
     else
     {
         foreach (KeyValuePair<string, List<OnEvent>> item in listeners)
         {
             for (int i = item.Value.Count - 1; i >= 0; i--)
             {
                 if (item.Value[i].Equals(x))
                 {
                     item.Value.RemoveAt(i);
                     Debug.Log("Remove");
                 }
             }
         }
     }
     if (listeners.ContainsKey(eventType))
         return false;
     return true;
 }
Пример #10
0
 public void SetBattleStartEvent(OnEvent eventfunc)
 {
     onBattleStartEvent = eventfunc;
 }
Пример #11
0
 private void TriggerIfStateEntryEvent(OnEvent @event)
 {
     _log.Append("{Yes} -> ");
     _currentState = @event.ToIfState;
     @event.ThenAction?.Invoke();
 }
Пример #12
0
 public void UnRegistEvent(int msgEvent, OnEvent process)
 {
     mEventSystem.UnRegister(msgEvent, process);
 }
 // prevent warning about unused events
 public void UseEvents()
 {
     OnEventDel?.Invoke(1, 2);
     OnEventInt?.Invoke(1);
     OnEvent?.Invoke(null, null);
 }
Пример #14
0
        public override void ProcessEventData(EventType _, JToken data)
        {
            var msgId = data.Value <int>("message_id");

            OnEvent?.Invoke(msgId);
        }
Пример #15
0
 public EventListener(OnEvent callback)
 {
     m_callback = callback;
 }
Пример #16
0
 public static void UnRegisterEvent <T>(T key, OnEvent fun) where T : IConvertible
 {
     Instance.UnRegister(key, fun);
 }
Пример #17
0
 public static bool RegisterEvent <T>(T key, OnEvent fun) where T : IConvertible
 {
     return(Instance.Register(key, fun));
 }
 static public void Trigger(int channel, float level)
 {
     OnEvent?.Invoke(channel, level);
 }
Пример #19
0
        public void Add(string eventName, OnEvent onEventp, int level)
        {
            OnEvent onEvent;

            eventsDic.TryGetValue(eventName, out onEvent);

            List <ListenerSorter> list;

            sortDic.TryGetValue(eventName, out list);

            if (onEvent != null && list == null)
            {
                Debug.LogError("eventName " + eventName + " is not all target in sortDic!!!!");
                return;
            }

            if (onEvent == null)
            {
                if (eventsDic.ContainsKey(eventName))
                {
                    eventsDic.Remove(eventName);
                }
                eventsDic.Add(eventName, onEventp);
            }
            else
            {
                eventsDic[eventName] += onEventp;
            }

            ListenerSorter listenerSorter = new ListenerSorter(level, onEventp);

            if (list == null)
            {
                list = new List <ListenerSorter>();
                sortDic.Add(eventName, list);
            }

            for (int i = list.Count - 1; i >= 0; i--)
            {
                if (listenerSorter.Equals(list[i]))
                {
                    Debug.LogWarning("Added Again >>>>>>>>>>>>>" + eventName);
                    return;
                }
            }

            list.Add(listenerSorter);
            list.Sort(listenerSorterComparer);

            System.Delegate[] invocationList = eventsDic[eventName].GetInvocationList();

            for (int i = invocationList.Length - 1; i >= 0; i--)
            {
                eventsDic[eventName] -= (OnEvent)invocationList[i];
            }

            for (int i = 0; i < list.Count; i++)
            {
                eventsDic[eventName] += (OnEvent)list[i].deleg;
            }
        }
Пример #20
0
 private void AddDefLevel(string eventName, OnEvent onEventp)
 {
     Add(eventName, onEventp, 0);
 }
Пример #21
0
 public void Invoke(EventAction a) => OnEvent?.Invoke(a);
Пример #22
0
 public static void Subscribe <T>(OnEvent <T> eventCallback)
 {
     UnibusObject.Instance.Subscribe <T>(eventCallback);
 }
Пример #23
0
 public void SetSelectServerEvent(OnEvent eventfunc)
 {
     onSelectServerEvent = eventfunc;
 }
Пример #24
0
 public static void Unsubscribe <T>(object tag, OnEvent <T> eventCallback)
 {
     UnibusObject.Instance.Unsubscribe <T>(tag, eventCallback);
 }
Пример #25
0
 static public void Trigger(AnimationCurve pitchCurve, float duration, float remapMin, float remapMax, bool relativePitch = false,
                            float feedbacksIntensity = 1.0f, int channel = 0, bool resetShakerValuesAfterShake = true, bool resetTargetValuesAfterShake = true, bool forwardDirection = true)
 {
     OnEvent?.Invoke(pitchCurve, duration, remapMin, remapMax, relativePitch,
                     feedbacksIntensity, channel, resetShakerValuesAfterShake, resetTargetValuesAfterShake, forwardDirection);
 }
Пример #26
0
 public void stop()
 {
     m_stop     = true;
     m_callback = null;
 }
Пример #27
0
        private void Init(WindowProperties properties)
        {
            ProfilerTimer.Profile(() =>
            {
                Logger.Info("Initializing a window for Windows...");

                //Initialize glfw if it hasn't already
                if (windowCount == 0)
                {
                    bool success = Glfw.Init();
                    Debug.Assert(success, "GLFW failed to init!");

                    Glfw.SetErrorCallback(ErrorHandler);
                }

#if DEBUG
                if (RenderingAPI.GetRenderingAPI() == RenderingAPIType.OpenGL)
                {
                    Glfw.WindowHint(Hint.OpenglDebugContext, true);
                }
#endif

                //Set the properties and create the window
                windowProperties = properties;
                {
                    ProfilerTimer.Profile("GLFW Create Window", () =>
                    {
                        window = new NativeWindow(properties.Width, properties.Height, properties.Title);
                        windowCount++;
                    });
                }

                //Create context
                context = RenderingAPI.GetRenderingAPI() switch
                {
                    RenderingAPIType.OpenGL => new OpenGLContext(window),
                    _ => throw new ArgumentOutOfRangeException()
                };

                //Init the context
                context.Init();

                SetVSync(properties.VSync);

                //Setup input
                Input.KeyInputImpl = new WindowsInput(window);

                //GLFW callbacks
                window.Closed += (sender, args) => OnEvent?.Invoke(new WindowCloseEvent());

                window.SizeChanged += delegate(object sender, SizeChangeEventArgs args)
                {
                    windowProperties.Width  = args.Size.Width;
                    windowProperties.Height = args.Size.Height;

                    OnEvent?.Invoke(new WindowResizedEvent(args.Size.Width, args.Size.Height));
                };

                window.KeyAction += delegate(object sender, KeyEventArgs args)
                {
                    switch (args.State)
                    {
                    case InputState.Release:
                        OnEvent?.Invoke(new KeyReleasedEvent((KeyCode)args.Key));
                        break;

                    case InputState.Press:
                        OnEvent?.Invoke(new KeyPressedEvent((KeyCode)args.Key));
                        break;

                    case InputState.Repeat:
                        OnEvent?.Invoke(new KeyPressedEvent((KeyCode)args.Key, 1));
                        break;

                    default:
                        throw new ArgumentOutOfRangeException(nameof(args.State), args.State, null);
                    }
                };

                window.MouseButton += delegate(object sender, MouseButtonEventArgs args)
                {
                    switch (args.Action)
                    {
                    case InputState.Press:
                        OnEvent?.Invoke(new MouseButtonPressedEvent((int)args.Button));
                        break;

                    case InputState.Release:
                        OnEvent?.Invoke(new MouseButtonReleasedEvent((int)args.Button));
                        break;
                    }
                };

                window.MouseScroll += (sender, args) =>
                                      OnEvent?.Invoke(new MouseScrollEvent((float)args.X, (float)args.Y));

                window.MouseMoved += (sender, args) => OnEvent?.Invoke(new MouseMovedEvent((float)args.X, (float)args.Y));

                Logger.Debug("Created a window for Windows ({@Width}x{@Height}, {@VSync})", properties.Width, properties.Height, properties.VSync);
            });
        }
Пример #28
0
 static public void Trigger(AnimationCurve volumeCurve, float duration, float remapMin, float remapMax, bool relativeVolume = false,
                            float feedbacksIntensity = 1.0f, int channel = 0, bool resetShakerValuesAfterShake = true, bool resetTargetValuesAfterShake = true, bool forwardDirection = true, TimescaleModes timescaleMode = TimescaleModes.Scaled)
 {
     OnEvent?.Invoke(volumeCurve, duration, remapMin, remapMax, relativeVolume,
                     feedbacksIntensity, channel, resetShakerValuesAfterShake, resetTargetValuesAfterShake, forwardDirection, timescaleMode);
 }
Пример #29
0
 public void CallEvent(List <DateTime> list) => OnEvent?.Invoke(list);
Пример #30
0
 public void RegisterEvent <T>(T msgId, OnEvent process) where T : IConvertible
 {
     mEventSystem.Register(msgId, process);
 }
        public ValueTask OnEventAsync(string json)
        {
            OnEvent?.Invoke(EVENT_ARGS, json);

            return(default);
Пример #32
0
 static public void Trigger(AnimationCurve distance, float duration, float remapMin, float remapMax, bool relativeDistance = false,
                            float attenuation = 1.0f, int channel = 0, bool resetShakerValuesAfterShake = true, bool resetTargetValuesAfterShake = true, bool forwardDirection = true, TimescaleModes timescaleMode = TimescaleModes.Scaled)
 {
     OnEvent?.Invoke(distance, duration, remapMin, remapMax, relativeDistance, attenuation, channel, resetShakerValuesAfterShake, resetTargetValuesAfterShake, forwardDirection, timescaleMode);
 }
Пример #33
0
 public void OnPointerUp(PointerEventData eventData)
 {
     OnEvent?.Invoke(eventData);
 }
Пример #34
0
 static public void Trigger(string checkboxEventName, bool value)
 {
     OnEvent?.Invoke(checkboxEventName, value);
 }
Пример #35
0
 static public void Trigger(DebugLogItem item)
 {
     OnEvent?.Invoke(item);
 }
Пример #36
0
 public void SetBattleEndEvent(OnEvent eventfunc)
 {
     onBattleEndEvent = eventfunc;
 }
Пример #37
0
    public void RemoveListener(EVENT_TYPE Event_Type, OnEvent Listener)
    {
        if (Listeners.ContainsKey(Event_Type))
        {
            Listeners[Event_Type] -= Listener;
        }

        Debug.Log("Just doesn't have this " + Listener + "yet");
        return;
    }
Пример #38
0
 public void SetMatchingEnterRoomEvent(OnEvent eventfunc)
 {
     onMatchingEnterRoomEvent = eventfunc;
 }
Пример #39
0
 public void RemoveSubscription(string sPub, OnEvent onEvent)
 {
     if(Subscribers.ContainsKey(sPub) && Subscribers[sPub] != null)
     Subscribers[sPub] -= onEvent;
 }
 static public void Trigger(int channel, bool forceMaxPriority, int newPriority, bool forceTransition, CinemachineBlendDefinition blendDefinition, bool resetValuesAfterTransition)
 {
     OnEvent?.Invoke(channel, forceMaxPriority, newPriority, forceTransition, blendDefinition, resetValuesAfterTransition);
 }
Пример #41
0
 public static void Unsubscribe <T>(OnEvent <T> eventCallback)
 {
     UnibusObject.Instance.Unsubscribe <T>(UnibusObject.DefaultTag, eventCallback);
 }
 static public void Trigger(AnimationCurve intensity, float duration, float amplitude, bool relativeIntensity = false, float attenuation = 1.0f, int channel = 0)
 {
     OnEvent?.Invoke(intensity, duration, amplitude, relativeIntensity, attenuation, channel);
 }
Пример #43
0
 static public void Trigger(AnimationCurve intensity, float duration, float remapMin, float remapMax, bool relativeIntensity = false,
                            float attenuation = 1.0f, int channel = 0, bool resetShakerValuesAfterShake = true, bool resetTargetValuesAfterShake = true)
 {
     OnEvent?.Invoke(intensity, duration, remapMin, remapMax, relativeIntensity, attenuation, channel, resetShakerValuesAfterShake, resetTargetValuesAfterShake);
 }
Пример #44
0
 protected void RaiseEvent(RawInputEventArgs ev) => OnEvent?.Invoke(ev);
Пример #45
0
 public void UnRegistEvent <T>(T msgEvent, OnEvent process) where T : IConvertible
 {
     UnRegisterEvent <T>(msgEvent, process);
 }