public void Remove(IList <IObserver> observers) { foreach (var observer in observers) { Observers.Remove(observer); } }
public void Detach(IObserver observer) { if (Observers.Contains(observer)) { Observers.Remove(observer); } }
public void Dispose() { if ((Observers != null) && Observers.Contains(Observer)) { Observers.Remove(Observer); } }
public IDisposable Subscribe(IObserver <Position> observer) { Observers.Add(observer); return(new ActionDisposable(() => { Observers.Remove(observer); })); }
public void RemoveObserver(Observer obs) { if (Observers.Contains(obs)) { Observers.Remove(obs); } }
public void Dispose() { if (Observers.Contains(this.Observer)) { Observers.Remove(this.Observer); } }
public void RemovePlayer(Player player) { if (player.Equals(HostPlayer) && State == GameState.Lobby) { _server.Stop(); } else if (player.Type == (int)PlayerType.Observer) { Observers.Remove(player); if (State == GameState.Lobby) { GameServerPacket nwatch = new GameServerPacket(StocMessage.HsWatchChange); nwatch.Write((short)Observers.Count); SendToAll(nwatch); } player.Disconnect(); } else if (State == GameState.Lobby) { Players[player.Type] = null; IsReady[player.Type] = false; GameServerPacket change = new GameServerPacket(StocMessage.HsPlayerChange); change.Write((byte)((player.Type << 4) + (int)PlayerChange.Leave)); SendToAll(change); player.Disconnect(); } else { Surrender(player, 4, true); } }
public void Dispose() { if (!(Observer == null)) { Observers.Remove(Observer); } }
public void RemoveSpectator(PlayerInfo info) { if (Observers.ContainsKey(info.UserId)) { Observers.Remove(info.UserId); } }
public void RemovePlayer(Player player) { if (player.Equals(HostPlayer) && State == GameState.Lobby) { bool found = false; foreach (Player p in Players) { if (p != null && !p.Equals(player)) { HostPlayer = p; found = true; break; } } if (found) { IsReady[HostPlayer.Type] = false; HostPlayer.SendTypeChange(); } else { _server.Stop(); return; } } if (player.IsRecorder) { player.Disconnect(); } if (player.Type == (int)PlayerType.Observer) { Observers.Remove(player); if (State == GameState.Lobby) { BinaryWriter nwatch = GamePacketFactory.Create(StocMessage.HsWatchChange); nwatch.Write((short)Observers.Count); SendToAll(nwatch); } player.Disconnect(); } else if (State == GameState.Lobby) { Players[player.Type] = null; IsReady[player.Type] = false; BinaryWriter change = GamePacketFactory.Create(StocMessage.HsPlayerChange); change.Write((byte)((player.Type << 4) + (int)PlayerChange.Leave)); SendToAll(change); player.Disconnect(); } else { Surrender(player, 4, true); } if (OnPlayerLeave != null) { OnPlayerLeave(this, new PlayerEventArgs(player)); } }
public void Dispose() { if (Observer != null && Observers.Contains(Observer)) { Observer.OnCompleted(); Observers.Remove(Observer); } }
internal DuelResults DelObserver(Player player) { player.Character.Spells.ClearBuffByEffect(SkillStates.DuelInterface).Wait(); Observers.Remove(player); Observers.Select(x => x.Session).SendAsync(new SDuelRoomBroadcastLeave(player.Character.Name)).Wait(); player.Character.WarpTo(17).Wait(); return(DuelResults.NoError); }
public void Dispose() { if (Observer is not null) { Observers.Remove(Observer); Observer = null; } }
public void AddSpectator(PlayerInfo info) { if (Observers.ContainsKey(info.UserId)) { Observers.Remove(info.UserId); } Observers.Add(info.UserId, info); }
public void Dispose() { if (Observer != null && Observers.Contains(Observer)) { Observers.Remove(Observer); _observer = null; } _observers = null; }
public void Unregister(IObserver observer) { if (observer == null) { throw new ArgumentNullException(nameof(observer)); } Observers.Remove(observer); }
public void MoveToDuelist(Player player) { if (State != GameState.Lobby) { return; } int pos = GetAvailablePlayerPos(); if (pos == -1) { return; } if (player.Type != (int)PlayerType.Observer) { if (!IsTag || IsReady[player.Type]) { return; } pos = (player.Type + 1) % 4; while (Players[pos] != null) { pos = (pos + 1) % 4; } GameServerPacket change = new GameServerPacket(StocMessage.HsPlayerChange); change.Write((byte)((player.Type << 4) + pos)); SendToAll(change); Players[player.Type] = null; Players[pos] = player; player.Type = pos; player.SendTypeChange(); } else { Observers.Remove(player); Players[pos] = player; player.Type = pos; GameServerPacket enter = new GameServerPacket(StocMessage.HsPlayerEnter); enter.Write(player.Name, 20); enter.Write((byte)pos); //padding enter.Write((byte)0); SendToAll(enter); GameServerPacket nwatch = new GameServerPacket(StocMessage.HsWatchChange); nwatch.Write((short)Observers.Count); SendToAll(nwatch); player.SendTypeChange(); } }
public void RemoveObserver <V>(V observer) where V : IObserveComponent <T> { if (!isInitialized) { Debug.LogAssertion(NotYetObservingMessage); } DispatchOnFinishObserve(observer); Observers.Remove(observer); }
public void CloseObserver(ObserverDefinition definition) { ObserverHandle handle = Observers.FirstOrDefault(observerForm => Equals(observerForm.Observer.Definition, definition)); if (handle == null) { Log.Warn("Observer with {@definition} not found, cannot close", definition); return; } handle.Dispose(); Observers.Remove(handle); RefreshObserverRequests(); }
/// <summary> /// Removes a player from the passive Observers list /// </summary> /// <param name="character">the character to add</param> public virtual void RemoveObserver(ServerCharacterInfo character) { //Task t = new Task((state) => { lock (m_Game.AllObserversSyncRoot) { if (Observers.Remove(character.ID)) { Log.LogMsg("Removed observer [#" + character.ToString() + "] from game [" + Name + "] [" + GameID.ToString() + "]."); AllObservers = (List <ICharacterInfo>)Observers.Values.ToList <ICharacterInfo>(); OnObserverRemoved(character); } } }//, "Remove Observer " + character.ToString(), TaskCreationOptions.LongRunning); //m_NetQ.AddTask(t); }
public virtual IDisposable Subscribe(IObserver <T> observer) { if (observer == null) { throw new ArgumentNullException("observer"); } Observers.Add(observer); if (Observers.Count == 1) { OnObservationStarted(); } return(Disposable.Create(() => { Observers.Remove(observer); if (Observers.Count == 0) { OnObservationStopped(); } })); }
private void Unsubscribe(IObserver <T> observer) { if (!Observers.Contains(observer)) { return; } Observers.Remove(observer); observer.OnCompleted(); if (Observers.Count == 0) { if (_internalSubscription != null) { _internalSubscription.Dispose(); } if (_subscribeSubscription != null) { _subscribeSubscription.Dispose(); } } }
public void removeObserver(Observer o) { Observers.Remove(o); }
public void Unsubscribe(ProductObserver Observer) { Observers.Remove(Observer); }
protected virtual void GotGameData(GameDTO game) { Data = game; if (ChatLobby == null) { ChatLobby = new GroupChat(RiotChat.GetCustomRoom(game.RoomName, game.Id, game.RoomPassword), game.RoomPassword); } var participants = game.TeamOne.Concat(game.TeamTwo); var left = new List <CustomLobbyMember>(AllMembers); foreach (var thing in participants) { var player = thing as PlayerParticipant; var bot = thing as BotParticipant; int team; if (game.TeamOne.Contains(thing)) { team = 0; } else { team = 1; } CustomLobbyMember now; if (player != null) { now = new CustomLobbyMember(player, team, this); } else if (bot != null) { now = new CustomLobbyMember(bot, team, this); } else { throw new Exception("Unknown participant " + thing); } CustomLobbyMember old = AllMembers.SingleOrDefault(m => m.SummonerID == now.SummonerID); if (old != null) { TeamOne.Remove(old); TeamTwo.Remove(old); Observers.Remove(old); bool diff = old.Team != now.Team; old.Update(now); if (team == 0) { TeamOne.Add(old); } else { TeamTwo.Add(old); } if (diff) { OnMemberChangeTeam(old); } left.Remove(old); } else { if (team == 0) { TeamOne.Add(now); } else { TeamTwo.Add(now); } OnMemberJoined(now); } } foreach (var thing in game.Observers) { var now = new CustomLobbyMember(thing, this); CustomLobbyMember old = AllMembers.SingleOrDefault(m => m.SummonerID == thing.SummonerId); if (old != null) { TeamOne.Remove(old); TeamTwo.Remove(old); Observers.Remove(old); bool diff = old.Team != now.Team; old.Update(now); Observers.Add(old); if (diff) { OnMemberChangeTeam(old); } left.Remove(old); } else { Observers.Add(now); OnMemberJoined(now); } } foreach (var member in left) { TeamOne.Remove(member); TeamTwo.Remove(member); OnMemberLeft(member); } if (game.GameState.Contains("CHAMP_SELECT")) { var champSelect = GameLobby.EnterChampSelect(game); OnGameStart(champSelect); } OnUpdate(game); if (!loaded) { OnLoaded(); } }
public void RemoveObserver(IFixUnitSettingsView aView) { Observers.Remove(aView); }
public void RemoveObserver(ILibraryPathSettingsView aView) { Observers.Remove(aView); }
public void MoveToDuelist(Player player) { if (State != GameState.Lobby) { return; } int pos = GetAvailablePlayerPos(); if (pos == -1) { return; } int oldType = player.Type; if (player.Type != (int)PlayerType.Observer) { if (!IsTag || IsReady[player.Type]) { return; } pos = (player.Type + 1) % 4; while (Players[pos] != null) { pos = (pos + 1) % 4; } BinaryWriter change = GamePacketFactory.Create(StocMessage.HsPlayerChange); change.Write((byte)((player.Type << 4) + pos)); SendToAll(change); Players[player.Type] = null; Players[pos] = player; player.Type = pos; player.SendTypeChange(); } else { Observers.Remove(player); Players[pos] = player; player.Type = pos; BinaryWriter enter = GamePacketFactory.Create(StocMessage.HsPlayerEnter); enter.WriteUnicode(player.Name, 20); enter.Write((byte)pos); //padding enter.Write((byte)0); SendToAll(enter); BinaryWriter nwatch = GamePacketFactory.Create(StocMessage.HsWatchChange); nwatch.Write((short)Observers.Count); SendToAll(nwatch); player.SendTypeChange(); } if (OnPlayerMove != null) { OnPlayerMove(this, new PlayerMoveEventArgs(player, oldType)); } }
public void RemoveObserver(IObserver o) { Observers.Remove(o); }
public void Detach(IObserver observer) => Observers.Remove(observer);