Example #1
0
		private void RefreshFromP2PServer()
		{
			int playerCount = 0;
			playerCount = 0;
			for (int i = this._grid.transform.childCount - 1; i >= 0; i--)
			{
				UnityEngine.Object.Destroy(this._grid.GetChild(i).gameObject);
			}
			IEnumerable<BoltConnection> clients = BoltNetwork.clients;
			IEnumerable<CSteamID> allMembers = CoopLobby.Instance.AllMembers;
			ulong[] first = (from c in clients
			select c.RemoteEndPoint.SteamId.Id).ToArray<ulong>();
			ulong[] second = (from m in allMembers
			select m.m_SteamID).ToArray<ulong>();
			IEnumerable<ulong> source = first.Union(second);
			source.ForEach(delegate(ulong x)
			{
				CSteamID steamIDFriend = new CSteamID(x);
				string friendPersonaName = SteamFriends.GetFriendPersonaName(steamIDFriend);
				BoltEntity entityFromSteamID = MpPlayerList.GetEntityFromSteamID(x);
				this.AddPlayerRow(friendPersonaName, x, entityFromSteamID, CoopLobby.Instance.Info.IsOwner && CoopLobby.Instance.Info.OwnerSteamId.m_SteamID != x);
				playerCount++;
			});
			int memberLimit = CoopLobby.Instance.Info.MemberLimit;
			this.UpdatePlayerCountText(playerCount + "/" + memberLimit);
		}
Example #2
0
		public static void UpdateKnownPlayers()
		{
			if (MpPlayerList._knownPlayers == null)
			{
				MpPlayerList._knownPlayers = new Dictionary<BoltConnection, MpPlayerList.KnownPlayerData>();
			}
			else
			{
				MpPlayerList._knownPlayers.Clear();
			}
			foreach (BoltConnection boltConnection in BoltNetwork.clients)
			{
				ulong id = boltConnection.RemoteEndPoint.SteamId.Id;
				CSteamID csteamID = new CSteamID(id);
				string friendPersonaName = SteamFriends.GetFriendPersonaName(csteamID);
				BoltEntity entityFromSteamID = MpPlayerList.GetEntityFromSteamID(id);
				MpPlayerList._knownPlayers.Add(boltConnection, new MpPlayerList.KnownPlayerData
				{
					Connection = boltConnection,
					SteamId = id,
					CSteamId = csteamID,
					Name = friendPersonaName,
					BoltEntity = entityFromSteamID
				});
			}
		}
Example #3
0
		public void Ban(ulong steamid)
		{
			if (CoopPeerStarter.Dedicated && CoopSteamClientStarter.IsAdmin)
			{
				CoopAdminCommand.Send("ban", steamid.ToString());
			}
			else
			{
				BoltConnection connection;
				BoltEntity playerEntity;
				MpPlayerList.GetConnectionAndEntity(steamid, out connection, out playerEntity);
				CoopKick.BanPlayer(connection, playerEntity);
				base.Invoke("Refresh", 0.1f);
			}
		}
Example #4
0
 public void BanByName(string name)
 {
     if (CoopPeerStarter.Dedicated && CoopSteamClientStarter.IsAdmin)
     {
         CoopAdminCommand.Send("ban", name);
     }
     else
     {
         BoltEntity entityFromName = MpPlayerList.GetEntityFromName(name, null);
         if (entityFromName)
         {
             CoopKick.BanPlayer(entityFromName);
             base.Invoke("Refresh", 0.1f);
         }
     }
 }
Example #5
0
 public void Ban(ulong steamid)
 {
     if (CoopPeerStarter.Dedicated && CoopSteamClientStarter.IsAdmin)
     {
         CoopAdminCommand.Send("ban", steamid.ToString());
     }
     else
     {
         BoltEntity entityFromSteamID = MpPlayerList.GetEntityFromSteamID(steamid);
         if (entityFromSteamID)
         {
             CoopKick.BanPlayer(entityFromSteamID);
             base.Invoke("Refresh", 0.1f);
         }
     }
 }
Example #6
0
 public void KickByName(string name)
 {
     if (CoopPeerStarter.Dedicated && CoopSteamClientStarter.IsAdmin)
     {
         CoopAdminCommand.Send("kick", name);
     }
     else
     {
         BoltEntity entityFromName = MpPlayerList.GetEntityFromName(name, null);
         if (entityFromName)
         {
             CoopKick.KickPlayer(entityFromName, -1, "HOST_KICKED_YOU");
             base.Invoke("Refresh", 0.1f);
         }
     }
 }
Example #7
0
 public void Kick(ulong steamid)
 {
     if (CoopPeerStarter.Dedicated && CoopSteamClientStarter.IsAdmin)
     {
         CoopAdminCommand.Send("kick", steamid.ToString());
     }
     else
     {
         BoltEntity entityFromSteamID = MpPlayerList.GetEntityFromSteamID(steamid);
         if (entityFromSteamID)
         {
             CoopKick.KickPlayer(entityFromSteamID, -1, "HOST_KICKED_YOU");
             base.Invoke("Refresh", 0.1f);
         }
     }
 }
Example #8
0
        public void Refresh()
        {
            int playerCount = 0;
            int num         = 0;

            if (SteamClientDSConfig.isDedicatedClient)
            {
                if (SteamClientDSConfig.Server != null)
                {
                    for (int i = this._grid.transform.childCount - 1; i >= 0; i--)
                    {
                        UnityEngine.Object.Destroy(this._grid.GetChild(i).gameObject);
                    }
                    SteamClientDSConfig.playerCount = 0;
                    num = SteamClientDSConfig.Server.m_nMaxPlayers;
                    IPlayerState state = LocalPlayer.Entity.GetState <IPlayerState>();
                    this.AddDSPlayerToList(state.name);
                    GameObject[] array = GameObject.FindGameObjectsWithTag("PlayerNet");
                    if (array.Length > 0)
                    {
                        foreach (GameObject gameObject in array)
                        {
                            BoltEntity component = gameObject.GetComponent <BoltEntity>();
                            if (component != null)
                            {
                                IPlayerState state2 = component.GetState <IPlayerState>();
                                if (state2 != null)
                                {
                                    SteamClientDSConfig.playerCount++;
                                    this.AddPlayerRow(state2.name, null, CoopSteamClientStarter.IsAdmin && state2.name != LocalPlayer.State.name);
                                }
                            }
                        }
                    }
                }
                else
                {
                    Debug.LogError("There is no server information stored on this client.");
                }
            }
            else
            {
                playerCount = 0;
                for (int k = this._grid.transform.childCount - 1; k >= 0; k--)
                {
                    UnityEngine.Object.Destroy(this._grid.GetChild(k).gameObject);
                }
                IEnumerable <ulong> source = (from c in BoltNetwork.clients
                                              select c.RemoteEndPoint.SteamId.Id).Union(from m in CoopLobby.Instance.AllMembers
                                                                                        select m.m_SteamID);
                source.ForEach(delegate(ulong x)
                {
                    CSteamID steamIDFriend       = new CSteamID(x);
                    string friendPersonaName     = SteamFriends.GetFriendPersonaName(steamIDFriend);
                    BoltEntity entityFromSteamID = MpPlayerList.GetEntityFromSteamID(x);
                    this.AddPlayerRow(friendPersonaName, x, entityFromSteamID, CoopLobby.Instance.Info.IsOwner && CoopLobby.Instance.Info.OwnerSteamId.m_SteamID != x);
                    playerCount++;
                });
                num = CoopLobby.Instance.Info.MemberLimit;
            }
            this._grid.repositionNow = true;
            if (SteamClientDSConfig.isDedicatedClient)
            {
                this._playerCount.text = SteamClientDSConfig.playerCount + "/" + SteamClientDSConfig.Server.m_nMaxPlayers;
            }
            else
            {
                this._playerCount.text = playerCount + "/" + num;
            }
        }
Example #9
0
		public static void GetConnectionAndEntity(ulong steamid, out BoltConnection foundConnection, out BoltEntity foundEntity)
		{
			foundConnection = MpPlayerList.GetConnectionFromSteamID(steamid);
			foundEntity = MpPlayerList.GetEntityFromSteamID(steamid);
		}