Fix Map.GetSpawnPoints to return CPos.
This commit is contained in:
@@ -228,12 +228,12 @@ namespace OpenRA
|
|||||||
Uid = ComputeHash();
|
Uid = ComputeHash();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int2[] GetSpawnPoints()
|
public CPos[] GetSpawnPoints()
|
||||||
{
|
{
|
||||||
return Actors.Value.Values
|
return Actors.Value.Values
|
||||||
.Where(a => a.Type == "mpspawn")
|
.Where(a => a.Type == "mpspawn")
|
||||||
.Select(a => a.InitDict.Get<LocationInit>().value)
|
.Select(a => (CPos)a.InitDict.Get<LocationInit>().value)
|
||||||
.ToArray();
|
.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Save(string toPath)
|
public void Save(string toPath)
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ namespace OpenRA.Widgets
|
|||||||
public class MapPreviewWidget : Widget
|
public class MapPreviewWidget : Widget
|
||||||
{
|
{
|
||||||
public Func<Map> Map = () => null;
|
public Func<Map> Map = () => null;
|
||||||
public Func<Dictionary<int2, Session.Client>> SpawnClients = () => new Dictionary<int2, Session.Client>();
|
public Func<Dictionary<CPos, Session.Client>> SpawnClients = () => new Dictionary<CPos, Session.Client>();
|
||||||
public Action<MouseInput> OnMouseDown = _ => {};
|
public Action<MouseInput> OnMouseDown = _ => {};
|
||||||
public bool IgnoreMouseInput = false;
|
public bool IgnoreMouseInput = false;
|
||||||
public bool ShowSpawnPoints = true;
|
public bool ShowSpawnPoints = true;
|
||||||
@@ -75,7 +75,7 @@ namespace OpenRA.Widgets
|
|||||||
tooltipContainer.Value.RemoveTooltip();
|
tooltipContainer.Value.RemoveTooltip();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int2 ConvertToPreview(int2 point)
|
public int2 ConvertToPreview(CPos point)
|
||||||
{
|
{
|
||||||
var map = Map();
|
var map = Map();
|
||||||
return new int2(MapRect.X + (int)(PreviewScale*(point.X - map.Bounds.Left)) , MapRect.Y + (int)(PreviewScale*(point.Y - map.Bounds.Top)));
|
return new int2(MapRect.X + (int)(PreviewScale*(point.X - map.Bounds.Left)) , MapRect.Y + (int)(PreviewScale*(point.Y - map.Bounds.Top)));
|
||||||
|
|||||||
@@ -28,9 +28,10 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
public void WorldLoaded(World world, WorldRenderer wr)
|
public void WorldLoaded(World world, WorldRenderer wr)
|
||||||
{
|
{
|
||||||
|
var spawns = world.Map.GetSpawnPoints();
|
||||||
var taken = world.LobbyInfo.Clients.Where(c => c.SpawnPoint != 0 && c.Slot != null)
|
var taken = world.LobbyInfo.Clients.Where(c => c.SpawnPoint != 0 && c.Slot != null)
|
||||||
.Select(c => (CPos) world.Map.GetSpawnPoints()[c.SpawnPoint-1]).ToList();
|
.Select(c => spawns[c.SpawnPoint-1]).ToList();
|
||||||
var available = world.Map.GetSpawnPoints().Select(c => (CPos)c).Except(taken).ToList();
|
var available = spawns.Except(taken).ToList();
|
||||||
|
|
||||||
// Set spawn
|
// Set spawn
|
||||||
foreach (var kv in world.LobbyInfo.Slots)
|
foreach (var kv in world.LobbyInfo.Slots)
|
||||||
@@ -41,7 +42,7 @@ namespace OpenRA.Mods.RA
|
|||||||
var client = world.LobbyInfo.ClientInSlot(kv.Key);
|
var client = world.LobbyInfo.ClientInSlot(kv.Key);
|
||||||
var spid = (client == null || client.SpawnPoint == 0)
|
var spid = (client == null || client.SpawnPoint == 0)
|
||||||
? ChooseSpawnPoint(world, available, taken)
|
? ChooseSpawnPoint(world, available, taken)
|
||||||
: (CPos)world.Map.GetSpawnPoints()[client.SpawnPoint-1];
|
: world.Map.GetSpawnPoints()[client.SpawnPoint-1];
|
||||||
|
|
||||||
Start.Add(player, spid);
|
Start.Add(player, spid);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
color.AttachPanel(colorChooser, onExit);
|
color.AttachPanel(colorChooser, onExit);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Dictionary<int2, Session.Client> GetSpawnClients(OrderManager orderManager, Map map)
|
public static Dictionary<CPos, Session.Client> GetSpawnClients(OrderManager orderManager, Map map)
|
||||||
{
|
{
|
||||||
var spawns = map.GetSpawnPoints();
|
var spawns = map.GetSpawnPoints();
|
||||||
return orderManager.LobbyInfo.Clients
|
return orderManager.LobbyInfo.Clients
|
||||||
|
|||||||
Reference in New Issue
Block a user