IOrderGenerator can produce multiple orders (or none)
This commit is contained in:
@@ -59,10 +59,8 @@ namespace OpenRa.Game
|
|||||||
|
|
||||||
if( mi.Button == MouseButtons.Right && mi.Event == MouseInputEvent.Down )
|
if( mi.Button == MouseButtons.Right && mi.Event == MouseInputEvent.Down )
|
||||||
if( orderGenerator != null )
|
if( orderGenerator != null )
|
||||||
{
|
foreach( var order in orderGenerator.Order( game, new int2( (int)xy.X, (int)xy.Y ) ) )
|
||||||
var order = orderGenerator.Order(game, new int2((int)xy.X, (int)xy.Y));
|
order.Apply( game );
|
||||||
if (order != null) order.Apply(game);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Unit FindUnit(float2 a, float2 b)
|
public Unit FindUnit(float2 a, float2 b)
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ namespace OpenRa.Game
|
|||||||
{
|
{
|
||||||
interface IOrderGenerator
|
interface IOrderGenerator
|
||||||
{
|
{
|
||||||
Order Order( Game game, int2 xy );
|
IEnumerable<Order> Order( Game game, int2 xy );
|
||||||
void PrepareOverlay( Game game, int2 xy );
|
void PrepareOverlay( Game game, int2 xy );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -184,10 +184,10 @@ namespace OpenRa.Game
|
|||||||
Name = name;
|
Name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Order Order( Game game, int2 xy )
|
public IEnumerable<Order> Order( Game game, int2 xy )
|
||||||
{
|
{
|
||||||
// todo: check that space is free
|
// todo: check that space is free
|
||||||
return new PlaceBuildingOrder( this, xy );
|
yield return new PlaceBuildingOrder( this, xy );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PrepareOverlay(Game game, int2 xy)
|
public void PrepareOverlay(Game game, int2 xy)
|
||||||
|
|||||||
@@ -97,17 +97,17 @@ namespace OpenRa.Game
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Order Order( Game game, int2 xy )
|
public IEnumerable<Order> Order( Game game, int2 xy )
|
||||||
{
|
{
|
||||||
if( ( fromCell == toCell || moveFraction == 0 ) && fromCell == xy )
|
if( ( fromCell == toCell || moveFraction == 0 ) && fromCell == xy )
|
||||||
{
|
{
|
||||||
if( SupportsMission( SupportedMissions.Deploy ) )
|
if( SupportsMission( SupportedMissions.Deploy ) )
|
||||||
return new DeployMcvOrder( this );
|
yield return new DeployMcvOrder( this );
|
||||||
if( SupportsMission( SupportedMissions.Harvest ) )
|
if( SupportsMission( SupportedMissions.Harvest ) )
|
||||||
return new HarvestOrder( this );
|
yield return new HarvestOrder( this );
|
||||||
}
|
}
|
||||||
|
else
|
||||||
return new MoveOrder( this, xy );
|
yield return new MoveOrder( this, xy );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PrepareOverlay(Game game, int2 xy) { }
|
public void PrepareOverlay(Game game, int2 xy) { }
|
||||||
|
|||||||
Reference in New Issue
Block a user