added SellOrderGenerator
This commit is contained in:
@@ -99,6 +99,7 @@
|
|||||||
<Compile Include="Orders\NetworkOrderSource.cs" />
|
<Compile Include="Orders\NetworkOrderSource.cs" />
|
||||||
<Compile Include="Orders\OrderIO.cs" />
|
<Compile Include="Orders\OrderIO.cs" />
|
||||||
<Compile Include="Orders\OrderManager.cs" />
|
<Compile Include="Orders\OrderManager.cs" />
|
||||||
|
<Compile Include="Orders\SellOrderGenerator.cs" />
|
||||||
<Compile Include="Ore.cs" />
|
<Compile Include="Ore.cs" />
|
||||||
<Compile Include="PathSearch.cs" />
|
<Compile Include="PathSearch.cs" />
|
||||||
<Compile Include="ProductionItem.cs" />
|
<Compile Include="ProductionItem.cs" />
|
||||||
|
|||||||
37
OpenRa.Game/Orders/SellOrderGenerator.cs
Normal file
37
OpenRa.Game/Orders/SellOrderGenerator.cs
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using OpenRa.Game.GameRules;
|
||||||
|
using OpenRa.Game.Traits;
|
||||||
|
|
||||||
|
namespace OpenRa.Game.Orders
|
||||||
|
{
|
||||||
|
class SellOrderGenerator : IOrderGenerator
|
||||||
|
{
|
||||||
|
public IEnumerable<Order> Order(int2 xy, MouseInput mi)
|
||||||
|
{
|
||||||
|
var loc = mi.Location + Game.viewport.Location;
|
||||||
|
var underCursor = Game.FindUnits(loc, loc)
|
||||||
|
.Where( a => a.traits.Contains<Building>() ).FirstOrDefault();
|
||||||
|
|
||||||
|
if (underCursor != null && !underCursor.Info.Selectable)
|
||||||
|
underCursor = null;
|
||||||
|
|
||||||
|
if (underCursor == null)
|
||||||
|
yield break;
|
||||||
|
|
||||||
|
var building = underCursor.traits.Get<Building>();
|
||||||
|
if (building.unitInfo.Unsellable)
|
||||||
|
yield break;
|
||||||
|
|
||||||
|
if (underCursor.Owner != Game.LocalPlayer)
|
||||||
|
yield break;
|
||||||
|
|
||||||
|
yield return new Order("Sell", underCursor, null, int2.Zero, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Tick() {}
|
||||||
|
public void Render() {}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user