completing alzeih's patch
This commit is contained in:
@@ -23,27 +23,30 @@ namespace OpenRA.Widgets
|
|||||||
lastMap = (other as MapPreviewWidget).lastMap;
|
lastMap = (other as MapPreviewWidget).lastMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Session.Client ClientForSpawnpoint(int i)
|
||||||
|
{
|
||||||
|
return Game.LobbyInfo.Clients.FirstOrDefault(c => c.SpawnPoint == i + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
const int closeEnough = 50;
|
||||||
|
|
||||||
public override bool HandleInput(MouseInput mi)
|
public override bool HandleInput(MouseInput mi)
|
||||||
{
|
{
|
||||||
|
if (mi.Event == MouseInputEvent.Down && mi.Button == MouseButton.Left)
|
||||||
|
{
|
||||||
|
var container = new Rectangle(DrawPosition().X, DrawPosition().Y, Parent.Bounds.Width, Parent.Bounds.Height);
|
||||||
|
|
||||||
var points = Game.chrome.currentMap.Waypoints
|
var points = Game.chrome.currentMap.Waypoints
|
||||||
.Select((sp, i) => Pair.New(sp, Game.LobbyInfo.Clients.FirstOrDefault(
|
.Select((sp, i) => Pair.New(Game.chrome.currentMap.ConvertToPreview(sp.Value, container), i))
|
||||||
c => c.SpawnPoint == i + 1)))
|
.Where(a => ClientForSpawnpoint(a.Second) == null && (a.First - mi.Location).LengthSquared < closeEnough)
|
||||||
.ToList();
|
.ToArray();
|
||||||
|
|
||||||
var container = new Rectangle(DrawPosition().X, DrawPosition().Y, Parent.Bounds.Width, Parent.Bounds.Height );
|
if (points.Length > 0)
|
||||||
|
Game.IssueOrder(Order.Chat("/spawn {0}".F(points[0].Second + 1)));
|
||||||
|
|
||||||
foreach(var p in points)
|
return points.Length > 0;
|
||||||
{
|
|
||||||
var pos = Game.chrome.currentMap.ConvertToPreview(p.First.Value, container);
|
|
||||||
|
|
||||||
//todo: check within bounds
|
|
||||||
if (mi.Location.Equals(pos) && p.Second == null)
|
|
||||||
{
|
|
||||||
Game.LobbyInfo.Clients[Game.LocalClient.Index].SpawnPoint =
|
|
||||||
Game.chrome.currentMap.Waypoints.Keys.ToList().IndexOf(p.First.Value) + 1;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,7 +93,7 @@ namespace OpenRA.Widgets
|
|||||||
|
|
||||||
foreach (var p in points)
|
foreach (var p in points)
|
||||||
{
|
{
|
||||||
var pos = map.ConvertToPreview(p.First.Value, container);
|
var pos = map.ConvertToPreview(p.First.Value, container) - new int2(8, 8);
|
||||||
|
|
||||||
if (p.Second == null)
|
if (p.Second == null)
|
||||||
Game.chrome.renderer.RgbaSpriteRenderer.DrawSprite(
|
Game.chrome.renderer.RgbaSpriteRenderer.DrawSprite(
|
||||||
|
|||||||
Reference in New Issue
Block a user