On orders, the mouse button is now considered part on issuing the order, not resolving it.
This commit is contained in:
@@ -62,13 +62,13 @@ namespace OpenRa.Game
|
||||
return traits.WithInterface<Traits.IRender>().SelectMany( x => x.Render( this ) );
|
||||
}
|
||||
|
||||
public Order Order( int2 xy )
|
||||
public Order Order( int2 xy, bool lmb )
|
||||
{
|
||||
if (Owner != Game.LocalPlayer)
|
||||
return null;
|
||||
|
||||
return traits.WithInterface<Traits.IOrder>()
|
||||
.Select( x => x.Order( this, xy ) )
|
||||
.Select( x => x.Order( this, xy, lmb ) )
|
||||
.FirstOrDefault( x => x != null );
|
||||
}
|
||||
|
||||
|
||||
@@ -23,8 +23,8 @@ namespace OpenRa.Game
|
||||
dragStart = dragEnd = xy;
|
||||
|
||||
if (orderGenerator != null)
|
||||
foreach (var order in orderGenerator.Order(xy.ToInt2()))
|
||||
order.Apply(true);
|
||||
foreach (var order in orderGenerator.Order(xy.ToInt2(), true))
|
||||
order.Apply();
|
||||
}
|
||||
|
||||
if (mi.Button == MouseButtons.Left && mi.Event == MouseInputEvent.Move)
|
||||
@@ -54,8 +54,8 @@ namespace OpenRa.Game
|
||||
|
||||
if( mi.Button == MouseButtons.Right && mi.Event == MouseInputEvent.Down )
|
||||
if( orderGenerator != null )
|
||||
foreach( var order in orderGenerator.Order( xy.ToInt2() ) )
|
||||
order.Apply( false );
|
||||
foreach( var order in orderGenerator.Order( xy.ToInt2(), false ) )
|
||||
order.Apply();
|
||||
}
|
||||
|
||||
public Pair<float2, float2>? SelectionBox
|
||||
|
||||
@@ -194,7 +194,7 @@ namespace OpenRa.Game
|
||||
var unit = new Actor(name, (1/24f * producer.CenterLocation).ToInt2(), player);
|
||||
var mobile = unit.traits.Get<Mobile>();
|
||||
mobile.facing = 128;
|
||||
mobile.SetNextAction( new Traits.Mobile.MoveTo( unit.Location + new int2( 0, 3 ) ) );
|
||||
mobile.QueueAction( new Traits.Mobile.MoveTo( unit.Location + new int2( 0, 3 ) ) );
|
||||
|
||||
world.AddFrameEndTask(_ => world.Add(unit));
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace OpenRa.Game
|
||||
{
|
||||
interface IOrderGenerator
|
||||
{
|
||||
IEnumerable<Order> Order( int2 xy );
|
||||
IEnumerable<Order> Order( int2 xy, bool lmb );
|
||||
void PrepareOverlay( int2 xy );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace OpenRa.Game
|
||||
{
|
||||
abstract class Order
|
||||
{
|
||||
public abstract void Apply( bool leftMButton );
|
||||
public abstract void Apply();
|
||||
}
|
||||
|
||||
class MoveOrder : Order
|
||||
@@ -26,10 +26,8 @@ namespace OpenRa.Game
|
||||
return suffixes[Unit.traits.Get<Traits.Mobile>().Voice];
|
||||
}
|
||||
|
||||
public override void Apply( bool leftMouseButton )
|
||||
public override void Apply()
|
||||
{
|
||||
if (leftMouseButton) return;
|
||||
|
||||
if (Game.LocalPlayer == Unit.Owner)
|
||||
Game.PlaySound("ackno.r00", false);
|
||||
var mobile = Unit.traits.Get<Traits.Mobile>();
|
||||
|
||||
@@ -17,7 +17,9 @@ namespace OpenRa.Game
|
||||
Name = name;
|
||||
}
|
||||
|
||||
public IEnumerable<Order> Order(int2 xy)
|
||||
public IEnumerable<Order> Order(int2 xy, bool lmb)
|
||||
{
|
||||
if( lmb )
|
||||
{
|
||||
// todo: check that space is free
|
||||
var bi = (UnitInfo.BuildingInfo)Rules.UnitInfo[ Name ];
|
||||
@@ -33,6 +35,15 @@ namespace OpenRa.Game
|
||||
|
||||
yield return new PlaceBuildingOrder( this, xy );
|
||||
}
|
||||
else // rmb
|
||||
{
|
||||
Game.world.AddFrameEndTask( _ =>
|
||||
{
|
||||
Game.controller.orderGenerator = null;
|
||||
Game.worldRenderer.uiOverlay.KillOverlay();
|
||||
} );
|
||||
}
|
||||
}
|
||||
|
||||
public void PrepareOverlay(int2 xy)
|
||||
{
|
||||
|
||||
@@ -16,9 +16,7 @@ namespace OpenRa.Game
|
||||
this.xy = xy;
|
||||
}
|
||||
|
||||
public override void Apply( bool leftMouseButton )
|
||||
{
|
||||
if( leftMouseButton )
|
||||
public override void Apply()
|
||||
{
|
||||
Game.world.AddFrameEndTask( _ =>
|
||||
{
|
||||
@@ -31,14 +29,5 @@ namespace OpenRa.Game
|
||||
Game.worldRenderer.uiOverlay.KillOverlay();
|
||||
} );
|
||||
}
|
||||
else
|
||||
{
|
||||
Game.world.AddFrameEndTask( _ =>
|
||||
{
|
||||
Game.controller.orderGenerator = null;
|
||||
Game.worldRenderer.uiOverlay.KillOverlay();
|
||||
} );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,8 +11,10 @@ namespace OpenRa.Game.Traits
|
||||
{
|
||||
}
|
||||
|
||||
public Order Order(Actor self, int2 xy)
|
||||
public Order Order(Actor self, int2 xy, bool lmb)
|
||||
{
|
||||
if( lmb ) return null;
|
||||
|
||||
// TODO: check that there's enough space at the destination.
|
||||
if( xy == self.Location )
|
||||
return new DeployMcvOrder( self, xy );
|
||||
@@ -32,9 +34,8 @@ namespace OpenRa.Game.Traits
|
||||
Location = location;
|
||||
}
|
||||
|
||||
public override void Apply( bool leftMouseButton )
|
||||
public override void Apply()
|
||||
{
|
||||
if( leftMouseButton ) return;
|
||||
var mobile = Unit.traits.Get<Mobile>();
|
||||
mobile.QueueAction( new Mobile.Turn( 96 ) );
|
||||
mobile.QueueAction( new DeployAction() );
|
||||
|
||||
@@ -24,14 +24,6 @@ namespace OpenRa.Game.Traits
|
||||
fromCell = toCell;
|
||||
}
|
||||
|
||||
public void SetNextAction( CurrentAction nextAction )
|
||||
{
|
||||
if( currentAction == null )
|
||||
currentAction = nextAction;
|
||||
else
|
||||
currentAction.NextAction = nextAction;
|
||||
}
|
||||
|
||||
public void QueueAction( CurrentAction nextAction )
|
||||
{
|
||||
if( currentAction == null )
|
||||
@@ -55,8 +47,10 @@ namespace OpenRa.Game.Traits
|
||||
fromCell = toCell;
|
||||
}
|
||||
|
||||
public Order Order(Actor self, int2 xy)
|
||||
public Order Order(Actor self, int2 xy, bool lmb)
|
||||
{
|
||||
if( lmb ) return null;
|
||||
|
||||
if (xy != toCell)
|
||||
return new MoveOrder(self, xy);
|
||||
|
||||
|
||||
@@ -9,5 +9,5 @@ namespace OpenRa.Game.Traits
|
||||
{
|
||||
interface ITick { void Tick(Actor self); }
|
||||
interface IRender { IEnumerable<Pair<Sprite, float2>> Render(Actor self); }
|
||||
interface IOrder { Order Order(Actor self, int2 xy); }
|
||||
interface IOrder { Order Order(Actor self, int2 xy, bool lmb); }
|
||||
}
|
||||
|
||||
@@ -14,11 +14,11 @@ namespace OpenRa.Game
|
||||
selection = selected.ToList();
|
||||
}
|
||||
|
||||
public IEnumerable<Order> Order( int2 xy )
|
||||
public IEnumerable<Order> Order( int2 xy, bool lmb )
|
||||
{
|
||||
foreach( var unit in selection )
|
||||
{
|
||||
var ret = unit.Order( xy );
|
||||
var ret = unit.Order( xy, lmb );
|
||||
if( ret != null )
|
||||
yield return ret;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user