Пример #1
0
 public void Remove(IList <IObserver> observers)
 {
     foreach (var observer in observers)
     {
         Observers.Remove(observer);
     }
 }
Пример #2
0
Файл: Bank.cs Проект: mkryuk/DP
 public void Detach(IObserver observer)
 {
     if (Observers.Contains(observer))
     {
         Observers.Remove(observer);
     }
 }
Пример #3
0
 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);
     }));
 }
Пример #5
0
 public void RemoveObserver(Observer obs)
 {
     if (Observers.Contains(obs))
     {
         Observers.Remove(obs);
     }
 }
Пример #6
0
 public void Dispose()
 {
     if (Observers.Contains(this.Observer))
     {
         Observers.Remove(this.Observer);
     }
 }
Пример #7
0
 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);
     }
 }
Пример #10
0
        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));
            }
        }
Пример #11
0
 public void Dispose()
 {
     if (Observer != null && Observers.Contains(Observer))
     {
         Observer.OnCompleted();
         Observers.Remove(Observer);
     }
 }
Пример #12
0
 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);
 }
Пример #13
0
 public void Dispose()
 {
     if (Observer is not null)
     {
         Observers.Remove(Observer);
         Observer = null;
     }
 }
Пример #14
0
 public void AddSpectator(PlayerInfo info)
 {
     if (Observers.ContainsKey(info.UserId))
     {
         Observers.Remove(info.UserId);
     }
     Observers.Add(info.UserId, info);
 }
Пример #15
0
 public void Dispose()
 {
     if (Observer != null && Observers.Contains(Observer))
     {
         Observers.Remove(Observer);
         _observer = null;
     }
     _observers = null;
 }
Пример #16
0
        public void Unregister(IObserver observer)
        {
            if (observer == null)
            {
                throw new ArgumentNullException(nameof(observer));
            }

            Observers.Remove(observer);
        }
Пример #17
0
        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();
            }
        }
Пример #18
0
        public void RemoveObserver <V>(V observer) where V : IObserveComponent <T>
        {
            if (!isInitialized)
            {
                Debug.LogAssertion(NotYetObservingMessage);
            }

            DispatchOnFinishObserve(observer);

            Observers.Remove(observer);
        }
Пример #19
0
        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();
        }
Пример #20
0
 /// <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);
 }
Пример #21
0
        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();
                }
            }));
        }
Пример #22
0
        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();
                }
            }
        }
Пример #23
0
 public void removeObserver(Observer o)
 {
     Observers.Remove(o);
 }
Пример #24
0
 public void Unsubscribe(ProductObserver Observer)
 {
     Observers.Remove(Observer);
 }
Пример #25
0
        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();
            }
        }
Пример #26
0
 public void RemoveObserver(IFixUnitSettingsView aView)
 {
     Observers.Remove(aView);
 }
 public void RemoveObserver(ILibraryPathSettingsView aView)
 {
     Observers.Remove(aView);
 }
Пример #28
0
        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));
            }
        }
Пример #29
0
 public void RemoveObserver(IObserver o)
 {
     Observers.Remove(o);
 }
Пример #30
0
 public void Detach(IObserver observer) => Observers.Remove(observer);