Begin imposing sanity on order ordering
This commit is contained in:
@@ -121,7 +121,8 @@ namespace OpenRA
|
||||
.OrderByDescending(a => a.Info.Traits.Contains<SelectableInfo>() ? a.Info.Traits.Get<SelectableInfo>().Priority : int.MinValue)
|
||||
.FirstOrDefault();
|
||||
|
||||
return TraitsImplementing<IIssueOrder>()
|
||||
return TraitsImplementing<IIssueOrder>()
|
||||
.OrderByDescending( x => x.OrderPriority( this, xy, mi, underCursor ) )
|
||||
.Select( x => x.IssueOrder( this, xy, mi, underCursor ) )
|
||||
.FirstOrDefault( x => x != null );
|
||||
}
|
||||
|
||||
@@ -113,22 +113,21 @@ namespace OpenRA.Traits
|
||||
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)
|
||||
{
|
||||
if (Info.OnRails) return null;
|
||||
|
||||
if (mi.Button == MouseButton.Left) return null;
|
||||
|
||||
// force-fire should *always* take precedence over move.
|
||||
if (mi.Modifiers.HasModifier(Modifiers.Ctrl)) 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 (!CanEnterCell(xy))
|
||||
return null;
|
||||
|
||||
if (xy == toCell) return null;
|
||||
|
||||
return new Order("Move", self, xy, mi.Modifiers.HasModifier(Modifiers.Shift));
|
||||
|
||||
@@ -24,6 +24,11 @@ namespace OpenRA.Traits
|
||||
{
|
||||
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)
|
||||
{
|
||||
|
||||
@@ -42,6 +42,11 @@ namespace OpenRA.Traits
|
||||
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)
|
||||
{
|
||||
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 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 IOrderCursor { string CursorForOrder(Actor self, Order order); }
|
||||
public interface IOrderVoice { string VoicePhraseForOrder(Actor self, Order order); }
|
||||
|
||||
Reference in New Issue
Block a user