Begin imposing sanity on order ordering
This commit is contained in:
@@ -122,6 +122,7 @@ namespace OpenRA
|
|||||||
.FirstOrDefault();
|
.FirstOrDefault();
|
||||||
|
|
||||||
return TraitsImplementing<IIssueOrder>()
|
return TraitsImplementing<IIssueOrder>()
|
||||||
|
.OrderByDescending( x => x.OrderPriority( this, xy, mi, underCursor ) )
|
||||||
.Select( x => x.IssueOrder( this, xy, mi, underCursor ) )
|
.Select( x => x.IssueOrder( this, xy, mi, underCursor ) )
|
||||||
.FirstOrDefault( x => x != null );
|
.FirstOrDefault( x => x != null );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -113,22 +113,21 @@ namespace OpenRA.Traits
|
|||||||
self.CenterLocation = Util.CenterOfCell(fromCell);
|
self.CenterLocation = Util.CenterOfCell(fromCell);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int OrderPriority(Actor self, int2 xy, MouseInput mi, Actor underCursor)
|
||||||
|
{
|
||||||
|
// Force move takes precidence
|
||||||
|
return mi.Modifiers.HasModifier(Modifiers.Alt) ? int.MaxValue : 0;
|
||||||
|
}
|
||||||
|
|
||||||
public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
|
public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
|
||||||
{
|
{
|
||||||
if (Info.OnRails) return null;
|
if (Info.OnRails) return null;
|
||||||
|
|
||||||
if (mi.Button == MouseButton.Left) return null;
|
if (mi.Button == MouseButton.Left) return null;
|
||||||
|
|
||||||
// force-fire should *always* take precedence over move.
|
if (!CanEnterCell(xy))
|
||||||
if (mi.Modifiers.HasModifier(Modifiers.Ctrl)) return null;
|
return null;
|
||||||
|
|
||||||
if (underCursor != null && underCursor.Owner != null)
|
|
||||||
{
|
|
||||||
// force-move
|
|
||||||
if (!mi.Modifiers.HasModifier(Modifiers.Alt)) return null;
|
|
||||||
if (!CanEnterCell(underCursor.Location, null, true)) return null;
|
|
||||||
}
|
|
||||||
if (MovementSpeedForCell(self, toCell) == 0) return null; /* allow disabling move orders from modifiers */
|
|
||||||
if (xy == toCell) return null;
|
if (xy == toCell) return null;
|
||||||
|
|
||||||
return new Order("Move", self, xy, mi.Modifiers.HasModifier(Modifiers.Shift));
|
return new Order("Move", self, xy, mi.Modifiers.HasModifier(Modifiers.Shift));
|
||||||
|
|||||||
@@ -25,6 +25,11 @@ namespace OpenRA.Traits
|
|||||||
yield return (isPrimary) ? TagType.Primary : TagType.None;
|
yield return (isPrimary) ? TagType.Primary : TagType.None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int OrderPriority(Actor self, int2 xy, MouseInput mi, Actor underCursor)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
|
public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
|
||||||
{
|
{
|
||||||
if (mi.Button == MouseButton.Right && underCursor == self)
|
if (mi.Button == MouseButton.Right && underCursor == self)
|
||||||
|
|||||||
@@ -42,6 +42,11 @@ namespace OpenRA.Traits
|
|||||||
anim.Image, Util.CenterOfCell(rallyPoint));
|
anim.Image, Util.CenterOfCell(rallyPoint));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int OrderPriority(Actor self, int2 xy, MouseInput mi, Actor underCursor)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
|
public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
|
||||||
{
|
{
|
||||||
if (mi.Button == MouseButton.Left || underCursor != null) return null;
|
if (mi.Button == MouseButton.Left || underCursor != null) return null;
|
||||||
|
|||||||
@@ -33,7 +33,11 @@ namespace OpenRA.Traits
|
|||||||
|
|
||||||
public interface ITick { void Tick(Actor self); }
|
public interface ITick { void Tick(Actor self); }
|
||||||
public interface IRender { IEnumerable<Renderable> Render(Actor self); }
|
public interface IRender { IEnumerable<Renderable> Render(Actor self); }
|
||||||
public interface IIssueOrder { Order IssueOrder( Actor self, int2 xy, MouseInput mi, Actor underCursor ); }
|
public interface IIssueOrder
|
||||||
|
{
|
||||||
|
Order IssueOrder( Actor self, int2 xy, MouseInput mi, Actor underCursor );
|
||||||
|
int OrderPriority( Actor self, int2 xy, MouseInput mi, Actor underCursor );
|
||||||
|
}
|
||||||
public interface IResolveOrder { void ResolveOrder(Actor self, Order order); }
|
public interface IResolveOrder { void ResolveOrder(Actor self, Order order); }
|
||||||
public interface IOrderCursor { string CursorForOrder(Actor self, Order order); }
|
public interface IOrderCursor { string CursorForOrder(Actor self, Order order); }
|
||||||
public interface IOrderVoice { string VoicePhraseForOrder(Actor self, Order order); }
|
public interface IOrderVoice { string VoicePhraseForOrder(Actor self, Order order); }
|
||||||
|
|||||||
@@ -174,6 +174,11 @@ namespace OpenRA.Mods.RA
|
|||||||
return info.FireDelay;
|
return info.FireDelay;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int OrderPriority(Actor self, int2 xy, MouseInput mi, Actor underCursor)
|
||||||
|
{
|
||||||
|
return mi.Modifiers.HasModifier(Modifiers.Ctrl) ? int.MaxValue : 1;
|
||||||
|
}
|
||||||
|
|
||||||
public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
|
public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
|
||||||
{
|
{
|
||||||
if (mi.Button == MouseButton.Left) return null;
|
if (mi.Button == MouseButton.Left) return null;
|
||||||
|
|||||||
@@ -23,6 +23,11 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
class C4Demolition : IIssueOrder, IResolveOrder, IOrderCursor, IOrderVoice
|
class C4Demolition : IIssueOrder, IResolveOrder, IOrderCursor, IOrderVoice
|
||||||
{
|
{
|
||||||
|
public int OrderPriority(Actor self, int2 xy, MouseInput mi, Actor underCursor)
|
||||||
|
{
|
||||||
|
return 5;
|
||||||
|
}
|
||||||
|
|
||||||
public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
|
public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
|
||||||
{
|
{
|
||||||
if (mi.Button != MouseButton.Right) return null;
|
if (mi.Button != MouseButton.Right) return null;
|
||||||
|
|||||||
@@ -26,6 +26,11 @@ namespace OpenRA.Mods.RA
|
|||||||
List<Actor> cargo = new List<Actor>();
|
List<Actor> cargo = new List<Actor>();
|
||||||
public IEnumerable<Actor> Passengers { get { return cargo; } }
|
public IEnumerable<Actor> Passengers { get { return cargo; } }
|
||||||
|
|
||||||
|
public int OrderPriority(Actor self, int2 xy, MouseInput mi, Actor underCursor)
|
||||||
|
{
|
||||||
|
return 5;
|
||||||
|
}
|
||||||
|
|
||||||
public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
|
public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
|
||||||
{
|
{
|
||||||
if (mi.Button == MouseButton.Right && underCursor == self)
|
if (mi.Button == MouseButton.Right && underCursor == self)
|
||||||
|
|||||||
@@ -33,6 +33,11 @@ namespace OpenRA.Mods.RA
|
|||||||
chargeTick--;
|
chargeTick--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int OrderPriority(Actor self, int2 xy, MouseInput mi, Actor underCursor)
|
||||||
|
{
|
||||||
|
return 5;
|
||||||
|
}
|
||||||
|
|
||||||
public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
|
public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
|
||||||
{
|
{
|
||||||
if (mi.Button == MouseButton.Right && xy == self.Location)
|
if (mi.Button == MouseButton.Right && xy == self.Location)
|
||||||
|
|||||||
@@ -19,6 +19,11 @@ namespace OpenRA.Mods.RA
|
|||||||
class EngineerCaptureInfo : TraitInfo<EngineerCapture> {}
|
class EngineerCaptureInfo : TraitInfo<EngineerCapture> {}
|
||||||
class EngineerCapture : IIssueOrder, IResolveOrder, IOrderCursor, IOrderVoice
|
class EngineerCapture : IIssueOrder, IResolveOrder, IOrderCursor, IOrderVoice
|
||||||
{
|
{
|
||||||
|
public int OrderPriority(Actor self, int2 xy, MouseInput mi, Actor underCursor)
|
||||||
|
{
|
||||||
|
return 5;
|
||||||
|
}
|
||||||
|
|
||||||
public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
|
public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
|
||||||
{
|
{
|
||||||
if (mi.Button != MouseButton.Right) return null;
|
if (mi.Button != MouseButton.Right) return null;
|
||||||
|
|||||||
@@ -20,6 +20,11 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
class EngineerRepair : IIssueOrder, IResolveOrder, IOrderCursor, IOrderVoice
|
class EngineerRepair : IIssueOrder, IResolveOrder, IOrderCursor, IOrderVoice
|
||||||
{
|
{
|
||||||
|
public int OrderPriority(Actor self, int2 xy, MouseInput mi, Actor underCursor)
|
||||||
|
{
|
||||||
|
return 5;
|
||||||
|
}
|
||||||
|
|
||||||
public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
|
public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
|
||||||
{
|
{
|
||||||
if (mi.Button != MouseButton.Right) return null;
|
if (mi.Button != MouseButton.Right) return null;
|
||||||
|
|||||||
@@ -93,6 +93,11 @@ namespace OpenRA.Mods.RA
|
|||||||
contents.Clear();
|
contents.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int OrderPriority(Actor self, int2 xy, MouseInput mi, Actor underCursor)
|
||||||
|
{
|
||||||
|
return 5;
|
||||||
|
}
|
||||||
|
|
||||||
public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
|
public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
|
||||||
{
|
{
|
||||||
if (mi.Button == MouseButton.Left) return null;
|
if (mi.Button == MouseButton.Left) return null;
|
||||||
|
|||||||
@@ -39,10 +39,15 @@ namespace OpenRA.Mods.RA
|
|||||||
Info = info;
|
Info = info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int OrderPriority(Actor self, int2 xy, MouseInput mi, Actor underCursor)
|
||||||
|
{
|
||||||
|
// Force move takes precidence
|
||||||
|
return mi.Modifiers.HasModifier(Modifiers.Alt) ? int.MaxValue : 0;
|
||||||
|
}
|
||||||
|
|
||||||
public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
|
public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
|
||||||
{
|
{
|
||||||
if (mi.Button == MouseButton.Left) return null;
|
if (mi.Button == MouseButton.Left) return null;
|
||||||
if (mi.Modifiers.HasModifier(Modifiers.Ctrl)) return null;
|
|
||||||
|
|
||||||
if (underCursor == null)
|
if (underCursor == null)
|
||||||
if (self.TraitOrDefault<IMove>().CanEnterCell(xy))
|
if (self.TraitOrDefault<IMove>().CanEnterCell(xy))
|
||||||
|
|||||||
@@ -32,6 +32,11 @@ namespace OpenRA.Mods.RA
|
|||||||
public int2[] minefield = null;
|
public int2[] minefield = null;
|
||||||
[Sync] int2 minefieldStart;
|
[Sync] int2 minefieldStart;
|
||||||
|
|
||||||
|
public int OrderPriority(Actor self, int2 xy, MouseInput mi, Actor underCursor)
|
||||||
|
{
|
||||||
|
return 5;
|
||||||
|
}
|
||||||
|
|
||||||
public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
|
public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
|
||||||
{
|
{
|
||||||
if (mi.Button == MouseButton.Right && underCursor == null && mi.Modifiers.HasModifier(Modifiers.Ctrl))
|
if (mi.Button == MouseButton.Right && underCursor == null && mi.Modifiers.HasModifier(Modifiers.Ctrl))
|
||||||
|
|||||||
@@ -25,6 +25,11 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
class Passenger : IIssueOrder, IResolveOrder, IOrderCursor, IOrderVoice
|
class Passenger : IIssueOrder, IResolveOrder, IOrderCursor, IOrderVoice
|
||||||
{
|
{
|
||||||
|
public int OrderPriority(Actor self, int2 xy, MouseInput mi, Actor underCursor)
|
||||||
|
{
|
||||||
|
return 5;
|
||||||
|
}
|
||||||
|
|
||||||
public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
|
public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
|
||||||
{
|
{
|
||||||
if (mi.Button != MouseButton.Right)
|
if (mi.Button != MouseButton.Right)
|
||||||
|
|||||||
@@ -46,6 +46,12 @@ namespace OpenRA.Mods.RA
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int OrderPriority(Actor self, int2 xy, MouseInput mi, Actor underCursor)
|
||||||
|
{
|
||||||
|
// Force move takes precidence
|
||||||
|
return mi.Modifiers.HasModifier(Modifiers.Alt) ? int.MaxValue : 0;
|
||||||
|
}
|
||||||
|
|
||||||
public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
|
public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
|
||||||
{
|
{
|
||||||
if (mi.Button == MouseButton.Left) return null;
|
if (mi.Button == MouseButton.Left) return null;
|
||||||
|
|||||||
@@ -46,6 +46,11 @@ namespace OpenRA.Mods.RA.Render
|
|||||||
disguisedAs = order.TargetActor == self ? null : order.TargetActor;
|
disguisedAs = order.TargetActor == self ? null : order.TargetActor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int OrderPriority(Actor self, int2 xy, MouseInput mi, Actor underCursor)
|
||||||
|
{
|
||||||
|
return 5;
|
||||||
|
}
|
||||||
|
|
||||||
public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
|
public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
|
||||||
{
|
{
|
||||||
if (underCursor != null && underCursor.HasTrait<RenderInfantry>())
|
if (underCursor != null && underCursor.HasTrait<RenderInfantry>())
|
||||||
|
|||||||
@@ -31,11 +31,15 @@ namespace OpenRA.Mods.RA
|
|||||||
Health = self.Trait<Health>();
|
Health = self.Trait<Health>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int OrderPriority(Actor self, int2 xy, MouseInput mi, Actor underCursor)
|
||||||
|
{
|
||||||
|
return 5;
|
||||||
|
}
|
||||||
|
|
||||||
public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
|
public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
|
||||||
{
|
{
|
||||||
if (mi.Button != MouseButton.Right) return null;
|
if (mi.Button != MouseButton.Right) return null;
|
||||||
if (underCursor == null) return null;
|
if (underCursor == null) return null;
|
||||||
if (mi.Modifiers.HasModifier(Modifiers.Ctrl)) return null; // force-fire, so don't do this.
|
|
||||||
|
|
||||||
if (self.Info.Traits.Get<RepairableInfo>().RepairBuildings.Contains(underCursor.Info.Name)
|
if (self.Info.Traits.Get<RepairableInfo>().RepairBuildings.Contains(underCursor.Info.Name)
|
||||||
&& underCursor.Owner == self.Owner)
|
&& underCursor.Owner == self.Owner)
|
||||||
|
|||||||
@@ -24,6 +24,11 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
class RepairableNear : IIssueOrder, IResolveOrder, IOrderCursor
|
class RepairableNear : IIssueOrder, IResolveOrder, IOrderCursor
|
||||||
{
|
{
|
||||||
|
public int OrderPriority(Actor self, int2 xy, MouseInput mi, Actor underCursor)
|
||||||
|
{
|
||||||
|
return 5;
|
||||||
|
}
|
||||||
|
|
||||||
public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
|
public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
|
||||||
{
|
{
|
||||||
if (mi.Button != MouseButton.Right) return null;
|
if (mi.Button != MouseButton.Right) return null;
|
||||||
|
|||||||
@@ -19,6 +19,11 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
class Spy : IIssueOrder, IResolveOrder, IOrderCursor
|
class Spy : IIssueOrder, IResolveOrder, IOrderCursor
|
||||||
{
|
{
|
||||||
|
public int OrderPriority(Actor self, int2 xy, MouseInput mi, Actor underCursor)
|
||||||
|
{
|
||||||
|
return 5;
|
||||||
|
}
|
||||||
|
|
||||||
public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
|
public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
|
||||||
{
|
{
|
||||||
if (mi.Button != MouseButton.Right) return null;
|
if (mi.Button != MouseButton.Right) return null;
|
||||||
|
|||||||
@@ -38,6 +38,11 @@ namespace OpenRA.Mods.RA
|
|||||||
bi = Rules.Info[info.IntoActor].Traits.GetOrDefault<BuildingInfo>();
|
bi = Rules.Info[info.IntoActor].Traits.GetOrDefault<BuildingInfo>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int OrderPriority(Actor self, int2 xy, MouseInput mi, Actor underCursor)
|
||||||
|
{
|
||||||
|
return 5;
|
||||||
|
}
|
||||||
|
|
||||||
public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
|
public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
|
||||||
{
|
{
|
||||||
if (mi.Button == MouseButton.Right && self == underCursor)
|
if (mi.Button == MouseButton.Right && self == underCursor)
|
||||||
|
|||||||
Reference in New Issue
Block a user