missing pieces of selling

This commit is contained in:
Chris Forbes
2010-01-02 12:57:02 +13:00
parent 43a8604ce9
commit 5f78d3a3d0
4 changed files with 15 additions and 6 deletions

View File

@@ -183,6 +183,7 @@ namespace OpenRa.Game
case "Harvest": return Cursor.Attack; // TODO: special harvest cursor?
case "PlaceBuilding": return Cursor.Default;
case "Sell": return Cursor.Sell;
case "NoSell": return Cursor.SellBlocked;
default:
return null;
}

View File

@@ -27,5 +27,6 @@ namespace OpenRa.Game
public static Cursor Capture { get { return new Cursor("capture"); } }
public static Cursor Heal { get { return new Cursor("heal"); } }
public static Cursor Sell { get { return new Cursor("sell"); } }
public static Cursor SellBlocked { get { return new Cursor("sell-blocked"); } }
}
}

View File

@@ -11,18 +11,25 @@ namespace OpenRa.Game.Orders
{
public IEnumerable<Order> Order(int2 xy, MouseInput mi)
{
if (!mi.IsFake && 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();
if (underCursor == null)
yield break;
var building = underCursor != null ? underCursor.Info as BuildingInfo : null;
var building = underCursor.traits.Get<Building>();
if (building.unitInfo.Unsellable)
if (building == null || building.Unsellable)
{
yield return new Order("NoSell", Game.LocalPlayer.PlayerActor, null, int2.Zero, null);
yield break;
}
yield return new Order("Sell", underCursor, null, int2.Zero, null);
}