working game with bots; stop bots from trying to order husks around
This commit is contained in:
@@ -11,7 +11,8 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System;
|
||||
using OpenRA.FileFormats;
|
||||
using OpenRA.FileFormats;
|
||||
using OpenRA.Network;
|
||||
|
||||
namespace OpenRA.Traits
|
||||
{
|
||||
@@ -29,11 +30,20 @@ namespace OpenRA.Traits
|
||||
.Select(c => world.Map.SpawnPoints.ElementAt(c.SpawnPoint - 1)).ToList();
|
||||
var available = world.Map.SpawnPoints.Except(taken).ToList();
|
||||
|
||||
// Set spawn
|
||||
foreach (var client in Game.LobbyInfo.Clients)
|
||||
Start.Add(world.players[client.Index],(client.SpawnPoint == 0)
|
||||
? ChooseSpawnPoint(world, available, taken)
|
||||
: world.Map.SpawnPoints.ElementAt(client.SpawnPoint - 1));
|
||||
// Set spawn
|
||||
foreach (var slot in Game.LobbyInfo.Slots)
|
||||
{
|
||||
var client = Game.LobbyInfo.Clients.FirstOrDefault(c => c.Slot == slot.Index);
|
||||
var player = FindPlayerInSlot(world, slot);
|
||||
|
||||
if (player == null) continue;
|
||||
|
||||
var spid = (client == null || client.SpawnPoint == 0)
|
||||
? ChooseSpawnPoint(world, available, taken)
|
||||
: world.Map.SpawnPoints.ElementAt(client.SpawnPoint - 1);
|
||||
|
||||
Start.Add(player, spid);
|
||||
}
|
||||
|
||||
// Explore allied shroud
|
||||
foreach (var p in Start)
|
||||
@@ -44,6 +54,11 @@ namespace OpenRA.Traits
|
||||
// Set viewport
|
||||
if (world.LocalPlayer != null && Start.ContainsKey(world.LocalPlayer))
|
||||
Game.viewport.Center(Start[world.LocalPlayer]);
|
||||
}
|
||||
|
||||
static Player FindPlayerInSlot(World world, Session.Slot slot)
|
||||
{
|
||||
return world.players.Values.FirstOrDefault(p => p.PlayerRef.Name == slot.MapPlayer);
|
||||
}
|
||||
|
||||
static int2 ChooseSpawnPoint(World world, List<int2> available, List<int2> taken)
|
||||
|
||||
Reference in New Issue
Block a user