public void ClientJoined(OpenRA.Server.Server server, Connection conn)
		{
			if (server.LobbyInfo.ClientWithIndex(conn.PlayerIndex).IsAdmin)
				return;

			var defaults = new Session.Global();
			FieldLoader.Load(defaults, Game.ModData.Manifest.LobbyDefaults);

			if (server.LobbyInfo.GlobalSettings.FragileAlliances != defaults.FragileAlliances)
				server.SendOrderTo(conn, "Message", "Diplomacy Changes: {0}".F(server.LobbyInfo.GlobalSettings.FragileAlliances));

			if (server.LobbyInfo.GlobalSettings.AllowCheats != defaults.AllowCheats)
				server.SendOrderTo(conn, "Message", "Allow Cheats: {0}".F(server.LobbyInfo.GlobalSettings.AllowCheats));

			if (server.LobbyInfo.GlobalSettings.Shroud != defaults.Shroud)
				server.SendOrderTo(conn, "Message", "Explored map: {0}".F(!server.LobbyInfo.GlobalSettings.Shroud));

			if (server.LobbyInfo.GlobalSettings.Fog != defaults.Fog)
				server.SendOrderTo(conn, "Message", "Fog of war: {0}".F(server.LobbyInfo.GlobalSettings.Fog));

			if (server.LobbyInfo.GlobalSettings.Crates != defaults.Crates)
				server.SendOrderTo(conn, "Message", "Crates Appear: {0}".F(server.LobbyInfo.GlobalSettings.Crates));

			if (server.LobbyInfo.GlobalSettings.Creeps != defaults.Creeps)
				server.SendOrderTo(conn, "Message", "Creeps Spawn: {0}".F(server.LobbyInfo.GlobalSettings.Creeps));

			if (server.LobbyInfo.GlobalSettings.AllyBuildRadius != defaults.AllyBuildRadius)
				server.SendOrderTo(conn, "Message", "Build off Ally ConYards: {0}".F(server.LobbyInfo.GlobalSettings.AllyBuildRadius));

			if (server.LobbyInfo.GlobalSettings.StartingUnitsClass != defaults.StartingUnitsClass)
			{
				var startUnitsInfo = server.Map.Rules.Actors["world"].TraitInfos<MPStartUnitsInfo>();
				var selectedClass = startUnitsInfo.Where(u => u.Class == server.LobbyInfo.GlobalSettings.StartingUnitsClass).Select(u => u.ClassName).FirstOrDefault();
				var className = selectedClass != null ? selectedClass : server.LobbyInfo.GlobalSettings.StartingUnitsClass;
				server.SendOrderTo(conn, "Message", "Starting Units: {0}".F(className));
			}

			if (server.LobbyInfo.GlobalSettings.StartingCash != defaults.StartingCash)
				server.SendOrderTo(conn, "Message", "Starting Cash: ${0}".F(server.LobbyInfo.GlobalSettings.StartingCash));

			if (server.LobbyInfo.GlobalSettings.TechLevel != defaults.TechLevel)
				server.SendOrderTo(conn, "Message", "Tech Level: {0}".F(server.LobbyInfo.GlobalSettings.TechLevel));

			if (server.LobbyInfo.GlobalSettings.ShortGame != defaults.ShortGame)
				server.SendOrderTo(conn, "Message", "Short Game: {0}".F(server.LobbyInfo.GlobalSettings.ShortGame));
		}
        public void ClientJoined(OpenRA.Server.Server server, Connection conn)
        {
            if (server.LobbyInfo.ClientWithIndex(conn.PlayerIndex).IsAdmin)
                return;

            var defaults = new Session.Global();
            LobbyCommands.LoadMapSettings(server, defaults, server.Map.Rules);

            var options = server.Map.Rules.Actors["player"].TraitInfos<ILobbyOptions>()
                .Concat(server.Map.Rules.Actors["world"].TraitInfos<ILobbyOptions>())
                .SelectMany(t => t.LobbyOptions(server.Map.Rules))
                .ToDictionary(o => o.Id, o => o);

            foreach (var kv in server.LobbyInfo.GlobalSettings.LobbyOptions)
            {
                Session.LobbyOptionState def;
                LobbyOption option;
                if (!defaults.LobbyOptions.TryGetValue(kv.Key, out def) || kv.Value.Value != def.Value)
                    if (options.TryGetValue(kv.Key, out option))
                        server.SendOrderTo(conn, "Message", option.Name + ": " + kv.Value.Value);
            }
        }
 public void InitPalette( OpenRA.Graphics.WorldRenderer wr )
 {
     wr.AddPalette( info.Name, new Palette( FileSystem.Open( world.TileSet.Palette ), info.ShadowIndex ) );
 }
示例#4
0
        // Gets the player information for the specified runtime player instance.
        public Player GetPlayer(OpenRA.Player runtimePlayer)
        {
            Player player;

            playersByRuntime.TryGetValue(runtimePlayer, out player);

            return player;
        }
示例#5
0
        // Adds the player information at start-up.
        public void AddPlayer(OpenRA.Player runtimePlayer, Session lobbyInfo)
        {
            if (runtimePlayer == null)
                throw new ArgumentNullException("runtimePlayer");

            if (lobbyInfo == null)
                throw new ArgumentNullException("lobbyInfo");

            // We don't care about spectators and map players
            if (runtimePlayer.NonCombatant || !runtimePlayer.Playable)
                return;

            // Find the lobby client that created the runtime player
            var client = lobbyInfo.ClientWithIndex(runtimePlayer.ClientIndex);
            if (client == null)
                return;

            var player = new Player
            {
                ClientIndex = runtimePlayer.ClientIndex,
                Name = runtimePlayer.PlayerName,
                IsHuman = !runtimePlayer.IsBot,
                IsBot = runtimePlayer.IsBot,
                FactionName = runtimePlayer.Faction.Name,
                FactionId = runtimePlayer.Faction.InternalName,
                Color = runtimePlayer.Color,
                Team = client.Team,
                SpawnPoint = runtimePlayer.SpawnPoint,
                IsRandomFaction = runtimePlayer.Faction.InternalName != client.Race,
                IsRandomSpawnPoint = runtimePlayer.SpawnPoint != client.SpawnPoint
            };

            playersByRuntime.Add(runtimePlayer, player);
            Players.Add(player);
        }
 public void InitPalette(OpenRA.Graphics.WorldRenderer wr)
 {
     string Filename = world.TileSet.PlayerPalette == null ? world.TileSet.Palette : world.TileSet.PlayerPalette;
     wr.AddPalette(info.Name, new Palette(FileSystem.Open(Filename), info.ShadowIndex));
 }