diff --git a/OpenRA.Game/Orders/UnitOrderGenerator.cs b/OpenRA.Game/Orders/UnitOrderGenerator.cs index 7972c5c2a5..55bf5cb032 100644 --- a/OpenRA.Game/Orders/UnitOrderGenerator.cs +++ b/OpenRA.Game/Orders/UnitOrderGenerator.cs @@ -98,7 +98,9 @@ namespace OpenRA.Orders } public string GetCursor( World world, int2 xy, MouseInput mi ) - { + { + bool useSelect = false; + var custom = world.WorldActor.TraitOrDefault(); if (custom != null) { @@ -108,20 +110,21 @@ namespace OpenRA.Orders var underCursor = world.FindUnitsAtMouse(mi.Location) .Where(a => a.HasTrait()) .OrderByDescending(a => a.Info.Traits.Contains() ? a.Info.Traits.Get().Priority : int.MinValue) - .FirstOrDefault(); - - if( mi.Modifiers.HasModifier( Modifiers.Shift ) || !world.Selection.Actors.Any() ) - if( underCursor != null ) - return "select"; - + .FirstOrDefault(); + + + if (mi.Modifiers.HasModifier(Modifiers.Shift) || !world.Selection.Actors.Any()) + if (underCursor != null) + useSelect = true; + var orders = world.Selection.Actors .Select(a => OrderForUnit(a, xy, mi, underCursor)) .Where(o => o != null) .ToArray(); - if( orders.Length == 0 ) return "default"; + if( orders.Length == 0 ) return (useSelect) ? "select" : "default"; - return orders[ 0 ].cursor ?? "default"; + return orders[0].cursor ?? ((useSelect) ? "select" : "default"); } static UnitOrderResult OrderForUnit( Actor self, int2 xy, MouseInput mi, Actor underCursor ) @@ -154,9 +157,9 @@ namespace OpenRA.Orders string cursor = null; if( underCursor != null ) - if( o.Order.CanTargetUnit( self, underCursor, mi.Modifiers.HasModifier( Modifiers.Ctrl ), mi.Modifiers.HasModifier( Modifiers.Alt ), ref cursor ) ) + if (o.Order.CanTargetUnit(self, underCursor, mi.Modifiers.HasModifier(Modifiers.Ctrl), mi.Modifiers.HasModifier(Modifiers.Alt), mi.Modifiers.HasModifier(Modifiers.Shift), ref cursor)) return new UnitOrderResult( self, o.Order, o.Trait, cursor, Target.FromActor( underCursor ) ); - if( o.Order.CanTargetLocation( self, xy, actorsAt, mi.Modifiers.HasModifier( Modifiers.Ctrl ), mi.Modifiers.HasModifier( Modifiers.Alt ), ref cursor ) ) + if (o.Order.CanTargetLocation(self, xy, actorsAt, mi.Modifiers.HasModifier(Modifiers.Ctrl), mi.Modifiers.HasModifier(Modifiers.Alt), mi.Modifiers.HasModifier(Modifiers.Shift), ref cursor)) return new UnitOrderResult( self, o.Order, o.Trait, cursor, Target.FromCell( xy ) ); } } diff --git a/OpenRA.Game/Traits/TraitsInterfaces.cs b/OpenRA.Game/Traits/TraitsInterfaces.cs index 38592c90e9..b04843ef2d 100755 --- a/OpenRA.Game/Traits/TraitsInterfaces.cs +++ b/OpenRA.Game/Traits/TraitsInterfaces.cs @@ -45,9 +45,10 @@ namespace OpenRA.Traits { string OrderID { get; } int OrderPriority { get; } - bool CanTargetUnit( Actor self, Actor target, bool forceAttack, bool forceMove, ref string cursor ); - bool CanTargetLocation( Actor self, int2 location, List actorsAtLocation, bool forceAttack, bool forceMove, ref string cursor ); - } + bool CanTargetUnit( Actor self, Actor target, bool forceAttack, bool forceMove, bool forceQueue, ref string cursor ); + bool CanTargetLocation(Actor self, int2 location, List actorsAtLocation, bool forceAttack, bool forceQueue, bool forceMove, ref string cursor); + bool IsQueued { get; } + } public interface IResolveOrder { void ResolveOrder(Actor self, Order order); } public interface IValidateOrder { bool OrderValidation(OrderManager orderManager, World world, int clientId, Order order); } diff --git a/OpenRA.Mods.RA/Air/Plane.cs b/OpenRA.Mods.RA/Air/Plane.cs index 525947a942..4a6c9f6492 100755 --- a/OpenRA.Mods.RA/Air/Plane.cs +++ b/OpenRA.Mods.RA/Air/Plane.cs @@ -142,15 +142,17 @@ namespace OpenRA.Mods.RA.Air public string OrderID { get { return "Move"; } } public int OrderPriority { get { return 4; } } - public bool CanTargetUnit( Actor self, Actor target, bool forceAttack, bool forceMove, ref string cursor ) + public bool CanTargetUnit(Actor self, Actor target, bool forceAttack, bool forceMove, bool forceQueued, ref string cursor) { return false; } - public bool CanTargetLocation( Actor self, int2 location, List actorsAtLocation, bool forceAttack, bool forceMove, ref string cursor ) + public bool CanTargetLocation(Actor self, int2 location, List actorsAtLocation, bool forceAttack, bool forceMove, bool forceQueued, ref string cursor) { + IsQueued = forceQueued; cursor = "move"; return true; } + public bool IsQueued { get; protected set; } } } diff --git a/OpenRA.Mods.RA/AttackBase.cs b/OpenRA.Mods.RA/AttackBase.cs index eb4cdc990f..1e8e069dcf 100644 --- a/OpenRA.Mods.RA/AttackBase.cs +++ b/OpenRA.Mods.RA/AttackBase.cs @@ -261,8 +261,10 @@ namespace OpenRA.Mods.RA public string OrderID { get; private set; } public int OrderPriority { get; private set; } - public bool CanTargetUnit( Actor self, Actor target, bool forceAttack, bool forceMove, ref string cursor ) + public bool CanTargetUnit(Actor self, Actor target, bool forceAttack, bool forceMove, bool forceQueued, ref string cursor) { + IsQueued = forceQueued; + cursor = isHeal ? "heal" : "attack"; if( self == target ) return false; if( !self.Trait().HasAnyValidWeapons( Target.FromActor( target ) ) ) return false; @@ -276,8 +278,10 @@ namespace OpenRA.Mods.RA return playerRelationship == Stance.Enemy || forceAttack; } - public bool CanTargetLocation( Actor self, int2 location, List actorsAtLocation, bool forceAttack, bool forceMove, ref string cursor ) + public bool CanTargetLocation(Actor self, int2 location, List actorsAtLocation, bool forceAttack, bool forceMove, bool forceQueued, ref string cursor) { + IsQueued = forceQueued; + cursor = isHeal ? "heal" : "attack"; if( isHeal ) return false; if( !self.Trait().HasAnyValidWeapons( Target.FromCell( location ) ) ) return false; @@ -288,6 +292,8 @@ namespace OpenRA.Mods.RA return false; } + + public bool IsQueued { get; protected set; } } } } diff --git a/OpenRA.Mods.RA/EngineerRepair.cs b/OpenRA.Mods.RA/EngineerRepair.cs index c6b5e74069..7555f6ff26 100644 --- a/OpenRA.Mods.RA/EngineerRepair.cs +++ b/OpenRA.Mods.RA/EngineerRepair.cs @@ -70,9 +70,11 @@ namespace OpenRA.Mods.RA { } - public override bool CanTargetUnit( Actor self, Actor target, bool forceAttack, bool forceMove, ref string cursor ) + public override bool CanTargetUnit(Actor self, Actor target, bool forceAttack, bool forceMove, bool forceQueued, ref string cursor) { - if( !base.CanTargetUnit( self, target, forceAttack, forceMove, ref cursor ) ) return false; + if( !base.CanTargetUnit( self, target, forceAttack, forceMove, forceQueued, ref cursor ) ) return false; + + IsQueued = forceQueued; if( target.GetDamageState() == DamageState.Undamaged ) cursor = "goldwrench-blocked"; diff --git a/OpenRA.Mods.RA/Harvester.cs b/OpenRA.Mods.RA/Harvester.cs index c32022d023..ab8acb7567 100644 --- a/OpenRA.Mods.RA/Harvester.cs +++ b/OpenRA.Mods.RA/Harvester.cs @@ -218,15 +218,15 @@ namespace OpenRA.Mods.RA public string OrderID { get { return "Harvest";}} public int OrderPriority { get { return 10; } } - public bool CanTargetUnit( Actor self, Actor target, bool forceAttack, bool forceMove, ref string cursor ) + public bool CanTargetUnit(Actor self, Actor target, bool forceAttack, bool forceMove, bool forceQueued, ref string cursor) { return false; } - public bool CanTargetLocation( Actor self, int2 location, List actorsAtLocation, bool forceAttack, bool forceMove, ref string cursor ) + public bool CanTargetLocation(Actor self, int2 location, List actorsAtLocation, bool forceAttack, bool forceMove, bool forceQueued, ref string cursor) { - // Don't leak info about resources under the shroud - if( !self.World.LocalPlayer.Shroud.IsExplored( location ) ) return false; + // Don't leak info about resources under the shroud + if (!self.World.LocalPlayer.Shroud.IsExplored(location)) return false; var res = self.World.WorldActor.Trait().GetResource( location ); var info = self.Info.Traits.Get(); @@ -234,8 +234,11 @@ namespace OpenRA.Mods.RA if( res == null ) return false; if( !info.Resources.Contains( res.info.Name ) ) return false; cursor = "attackmove"; + IsQueued = forceQueued; + return true; } + public bool IsQueued { get; protected set; } } } } diff --git a/OpenRA.Mods.RA/Minelayer.cs b/OpenRA.Mods.RA/Minelayer.cs index 66a35a9ebc..f2bc2d51c7 100644 --- a/OpenRA.Mods.RA/Minelayer.cs +++ b/OpenRA.Mods.RA/Minelayer.cs @@ -152,16 +152,19 @@ namespace OpenRA.Mods.RA public string OrderID { get { return "BeginMinefield"; } } public int OrderPriority { get { return 5; } } - public bool CanTargetUnit( Actor self, Actor target, bool forceAttack, bool forceMove, ref string cursor ) + public bool CanTargetUnit(Actor self, Actor target, bool forceAttack, bool forceMove, bool forceQueued, ref string cursor) { return false; } - public bool CanTargetLocation( Actor self, int2 location, List actorsAtLocation, bool forceAttack, bool forceMove, ref string cursor ) + public bool CanTargetLocation(Actor self, int2 location, List actorsAtLocation, bool forceAttack, bool forceMove, bool forceQueued, ref string cursor) { cursor = "ability"; + IsQueued = forceQueued; + return ( actorsAtLocation.Count == 0 && forceAttack ); } + public bool IsQueued { get; protected set; } } } } diff --git a/OpenRA.Mods.RA/Move/Mobile.cs b/OpenRA.Mods.RA/Move/Mobile.cs index 610a1fbff8..3a2ab98a23 100755 --- a/OpenRA.Mods.RA/Move/Mobile.cs +++ b/OpenRA.Mods.RA/Move/Mobile.cs @@ -360,14 +360,16 @@ namespace OpenRA.Mods.RA.Move public string OrderID { get { return "Move"; } } public int OrderPriority { get { return 4; } } - - public bool CanTargetUnit( Actor self, Actor target, bool forceAttack, bool forceMove, ref string cursor ) + public bool IsQueued { get; protected set; } + public bool CanTargetUnit(Actor self, Actor target, bool forceAttack, bool forceMove, bool forceQueued, ref string cursor) { return false; } - public bool CanTargetLocation( Actor self, int2 location, List actorsAtLocation, bool forceAttack, bool forceMove, ref string cursor ) + public bool CanTargetLocation(Actor self, int2 location, List actorsAtLocation, bool forceAttack, bool forceMove, bool forceQueued, ref string cursor) { + IsQueued = forceQueued; + cursor = "move"; if( self.World.LocalPlayer.Shroud.IsVisible( location ) && !self.Trait().CanEnterCell( location ) ) cursor = "move-blocked"; diff --git a/OpenRA.Mods.RA/Orders/DeployOrderTargeter.cs b/OpenRA.Mods.RA/Orders/DeployOrderTargeter.cs index c6f63affe8..59b052ebf8 100755 --- a/OpenRA.Mods.RA/Orders/DeployOrderTargeter.cs +++ b/OpenRA.Mods.RA/Orders/DeployOrderTargeter.cs @@ -25,15 +25,18 @@ namespace OpenRA.Mods.RA.Orders public string OrderID { get; private set; } public int OrderPriority { get; private set; } - public bool CanTargetUnit( Actor self, Actor target, bool forceAttack, bool forceMove, ref string cursor ) + public bool CanTargetUnit( Actor self, Actor target, bool forceAttack, bool forceMove, bool forceQueued, ref string cursor ) { + IsQueued = forceQueued; cursor = useDeployCursor() ? "deploy" : "deploy-blocked"; return self == target; } - public bool CanTargetLocation( Actor self, int2 location, List actorsAtLocation, bool forceAttack, bool forceMove, ref string cursor ) + public bool CanTargetLocation(Actor self, int2 location, List actorsAtLocation, bool forceAttack, bool forceMove, bool forceQueued, ref string cursor) { return false; } + + public bool IsQueued { get; protected set; } } } diff --git a/OpenRA.Mods.RA/Orders/EnterBuildingOrderTargeter.cs b/OpenRA.Mods.RA/Orders/EnterBuildingOrderTargeter.cs index b76691614f..4a3c839aef 100755 --- a/OpenRA.Mods.RA/Orders/EnterBuildingOrderTargeter.cs +++ b/OpenRA.Mods.RA/Orders/EnterBuildingOrderTargeter.cs @@ -25,11 +25,12 @@ namespace OpenRA.Mods.RA.Orders this.useEnterCursor = useEnterCursor; } - public override bool CanTargetUnit( Actor self, Actor target, bool forceAttack, bool forceMove, ref string cursor ) + public override bool CanTargetUnit(Actor self, Actor target, bool forceAttack, bool forceMove, bool forceQueued, ref string cursor) { - if( !base.CanTargetUnit( self, target, forceAttack, forceMove, ref cursor ) ) return false; + if( !base.CanTargetUnit( self, target, forceAttack, forceMove, forceQueued, ref cursor ) ) return false; if( !canTarget( target ) ) return false; - cursor = useEnterCursor( target ) ? "enter" : "enter-blocked"; + cursor = useEnterCursor(target) ? "enter" : "enter-blocked"; + IsQueued = forceQueued; return true; } } diff --git a/OpenRA.Mods.RA/Orders/UnitOrderTargeter.cs b/OpenRA.Mods.RA/Orders/UnitOrderTargeter.cs index b03075182d..9ab00c36d8 100755 --- a/OpenRA.Mods.RA/Orders/UnitOrderTargeter.cs +++ b/OpenRA.Mods.RA/Orders/UnitOrderTargeter.cs @@ -31,12 +31,13 @@ namespace OpenRA.Mods.RA.Orders public string OrderID { get; private set; } public int OrderPriority { get; private set; } - public virtual bool CanTargetUnit( Actor self, Actor target, bool forceAttack, bool forceMove, ref string cursor ) + public virtual bool CanTargetUnit(Actor self, Actor target, bool forceAttack, bool forceMove, bool forceQueued, ref string cursor) { if( self == null ) throw new ArgumentNullException( "self" ); if( target == null ) throw new ArgumentNullException( "target" ); cursor = this.cursor; + IsQueued = forceQueued; var playerRelationship = self.Owner.Stances[ target.Owner ]; @@ -46,10 +47,11 @@ namespace OpenRA.Mods.RA.Orders return true; } - public virtual bool CanTargetLocation( Actor self, int2 location, List actorsAtLocation, bool forceAttack, bool forceMove, ref string cursor ) + public virtual bool CanTargetLocation(Actor self, int2 location, List actorsAtLocation, bool forceAttack, bool forceMove, bool forceQueued, ref string cursor) { return false; } + public virtual bool IsQueued { get; protected set; } } public class UnitTraitOrderTargeter : UnitOrderTargeter @@ -59,11 +61,13 @@ namespace OpenRA.Mods.RA.Orders { } - public override bool CanTargetUnit( Actor self, Actor target, bool forceAttack, bool forceMove, ref string cursor ) + public override bool CanTargetUnit(Actor self, Actor target, bool forceAttack, bool forceMove, bool forceQueued, ref string cursor) { - if( !base.CanTargetUnit( self, target, forceAttack, forceMove, ref cursor ) ) return false; + if( !base.CanTargetUnit( self, target, forceAttack, forceMove, forceQueued, ref cursor ) ) return false; if( !target.HasTrait() ) return false; + IsQueued = forceQueued; + return true; } } diff --git a/OpenRA.Mods.RA/RallyPoint.cs b/OpenRA.Mods.RA/RallyPoint.cs index f13ce135de..be3ecc5212 100755 --- a/OpenRA.Mods.RA/RallyPoint.cs +++ b/OpenRA.Mods.RA/RallyPoint.cs @@ -69,15 +69,17 @@ namespace OpenRA.Mods.RA public string OrderID { get { return "SetRallyPoint"; } } public int OrderPriority { get { return 0; } } - public bool CanTargetUnit( Actor self, Actor target, bool forceAttack, bool forceMove, ref string cursor ) + public bool CanTargetUnit(Actor self, Actor target, bool forceAttack, bool forceMove, bool forceQueued, ref string cursor) { return false; } - public bool CanTargetLocation( Actor self, int2 location, List actorsAtLocation, bool forceAttack, bool forceMove, ref string cursor ) + public bool CanTargetLocation(Actor self, int2 location, List actorsAtLocation, bool forceAttack, bool forceMove, bool forceQueued, ref string cursor) { return true; } + + public bool IsQueued { get { return false; } } // unused } } }