/// <summary> /// Unregisters the specific event /// </summary> /// <param name="pe">The event to unregister</param> public static void Unregister(OnPlayerDisconnect 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 new OnPlayerDisconnect event</returns> public static OnPlayerDisconnect Register(OnCall callback, Player target) { Logger.Log("OnPlayerDisconnect registered to the method " + callback.Method.Name, LogType.Debug); //We add it to the list here OnPlayerDisconnect pe = _eventQueue.Find(match => match.Player == null || match.Player.Username == target.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 OnPlayerDisconnect(callback, target); _eventQueue.Add(pe); } return pe; }
void OnDisconnect(OnPlayerDisconnect args) { if (mPlayersListBox.InvokeRequired) { mPlayersListBox.Invoke((MethodInvoker)delegate { OnDisconnect(args); }); return; } mPlayersListBox.Items.Remove(args.Player.Username); }