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