big cleanup of Controller mess
This commit is contained in:
@@ -11,30 +11,37 @@ namespace OpenRa.Game.Orders
|
||||
{
|
||||
public IEnumerable<Order> Order(int2 xy, MouseInput mi)
|
||||
{
|
||||
if (!mi.IsFake && mi.Button == MouseButton.Right)
|
||||
{
|
||||
if (mi.Button == MouseButton.Right)
|
||||
Game.controller.CancelInputMode();
|
||||
yield break;
|
||||
}
|
||||
|
||||
var loc = mi.Location + Game.viewport.Location;
|
||||
var underCursor = Game.FindUnits(loc, loc)
|
||||
.Where(a => a.Owner == Game.LocalPlayer
|
||||
&& a.traits.Contains<Building>()
|
||||
&& a.Info.Selectable).FirstOrDefault();
|
||||
return OrderInner(xy, mi);
|
||||
}
|
||||
|
||||
var building = underCursor != null ? underCursor.Info as BuildingInfo : null;
|
||||
|
||||
if (building == null || building.Unsellable)
|
||||
IEnumerable<Order> OrderInner(int2 xy, MouseInput mi)
|
||||
{
|
||||
if (mi.Button == MouseButton.Left)
|
||||
{
|
||||
yield return new Order("NoSell", Game.LocalPlayer.PlayerActor, null, int2.Zero, null);
|
||||
yield break;
|
||||
}
|
||||
var loc = mi.Location + Game.viewport.Location;
|
||||
var underCursor = Game.FindUnits(loc, loc)
|
||||
.Where(a => a.Owner == Game.LocalPlayer
|
||||
&& a.traits.Contains<Building>()
|
||||
&& a.Info.Selectable).FirstOrDefault();
|
||||
|
||||
yield return new Order("Sell", underCursor, null, int2.Zero, null);
|
||||
var building = underCursor != null ? underCursor.Info as BuildingInfo : null;
|
||||
|
||||
if (building != null && !building.Unsellable)
|
||||
yield return new Order("Sell", underCursor, null, int2.Zero, null);
|
||||
}
|
||||
}
|
||||
|
||||
public void Tick() {}
|
||||
public void Render() {}
|
||||
|
||||
public Cursor GetCursor(int2 xy, MouseInput mi)
|
||||
{
|
||||
mi.Button = MouseButton.Left;
|
||||
return OrderInner(xy, mi).Any()
|
||||
? Cursor.Sell : Cursor.SellBlocked;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user