/// <summary> /// Unregisters the specific event /// </summary> /// <param name="pe">The event to unregister</param> public static void Unregister(OnPlayerCommand pe) { pe.Unregister(); }
/// <summary> /// Used to register a method to be executed when the event is fired. /// </summary> /// <param name="callback">The method to call</param> /// <param name="target">The player to watch for. (null for any players)</param> /// <returns>The OnPlayerCommand event</returns> public static OnPlayerCommand Register(OnCall callback, Player target) { Logger.Log("OnPlayerCommand registered to the method " + callback.Method.Name, LogType.Debug); //We add it to the list here OnPlayerCommand pe = _eventQueue.Find(match => (match.Player == null ? target == null : target != null && target.Username == match.Player.Username)); if (pe != null) //It already exists, so we just add it to the queue. pe._queue += callback; else { //Doesn't exist yet. Make a new one. pe = new OnPlayerCommand(callback, target); _eventQueue.Add(pe); } return pe; }