/// <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); }
// Use this for initialization void Start() { OnPuzzleCompletion+=CompletePuzzle; GameObject[] puzzleObjects = GameObject.FindGameObjectsWithTag("puzzle"); foreach(GameObject puzzle in puzzleObjects) { puzzle.GetComponent<ObjectController>().OnCompletion += CompletePuzzle; } }
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); }
// 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); }
//----------------------------------------------------------- /// <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 }
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; } }
//----------------------------------------------------------- /// <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); }
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); }
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; }
public void SetBattleStartEvent(OnEvent eventfunc) { onBattleStartEvent = eventfunc; }
private void TriggerIfStateEntryEvent(OnEvent @event) { _log.Append("{Yes} -> "); _currentState = @event.ToIfState; @event.ThenAction?.Invoke(); }
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); }
public override void ProcessEventData(EventType _, JToken data) { var msgId = data.Value <int>("message_id"); OnEvent?.Invoke(msgId); }
public EventListener(OnEvent callback) { m_callback = callback; }
public static void UnRegisterEvent <T>(T key, OnEvent fun) where T : IConvertible { Instance.UnRegister(key, fun); }
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); }
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; } }
private void AddDefLevel(string eventName, OnEvent onEventp) { Add(eventName, onEventp, 0); }
public void Invoke(EventAction a) => OnEvent?.Invoke(a);
public static void Subscribe <T>(OnEvent <T> eventCallback) { UnibusObject.Instance.Subscribe <T>(eventCallback); }
public void SetSelectServerEvent(OnEvent eventfunc) { onSelectServerEvent = eventfunc; }
public static void Unsubscribe <T>(object tag, OnEvent <T> eventCallback) { UnibusObject.Instance.Unsubscribe <T>(tag, eventCallback); }
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); }
public void stop() { m_stop = true; m_callback = null; }
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); }); }
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); }
public void CallEvent(List <DateTime> list) => OnEvent?.Invoke(list);
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);
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); }
public void OnPointerUp(PointerEventData eventData) { OnEvent?.Invoke(eventData); }
static public void Trigger(string checkboxEventName, bool value) { OnEvent?.Invoke(checkboxEventName, value); }
static public void Trigger(DebugLogItem item) { OnEvent?.Invoke(item); }
public void SetBattleEndEvent(OnEvent eventfunc) { onBattleEndEvent = eventfunc; }
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; }
public void SetMatchingEnterRoomEvent(OnEvent eventfunc) { onMatchingEnterRoomEvent = eventfunc; }
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); }
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); }
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); }
protected void RaiseEvent(RawInputEventArgs ev) => OnEvent?.Invoke(ev);
public void UnRegistEvent <T>(T msgEvent, OnEvent process) where T : IConvertible { UnRegisterEvent <T>(msgEvent, process); }