Let order generators account for selection changes
This commit is contained in:
@@ -18,13 +18,14 @@ namespace OpenRA.Orders
|
||||
public class GenericSelectTarget : UnitOrderGenerator
|
||||
{
|
||||
public readonly string OrderName;
|
||||
protected readonly IEnumerable<Actor> Subjects;
|
||||
protected readonly string Cursor;
|
||||
protected readonly MouseButton ExpectedButton;
|
||||
|
||||
protected IEnumerable<Actor> subjects;
|
||||
|
||||
public GenericSelectTarget(IEnumerable<Actor> subjects, string order, string cursor, MouseButton button)
|
||||
{
|
||||
Subjects = subjects;
|
||||
this.subjects = subjects;
|
||||
OrderName = order;
|
||||
Cursor = cursor;
|
||||
ExpectedButton = button;
|
||||
@@ -53,7 +54,7 @@ namespace OpenRA.Orders
|
||||
world.CancelInputMode();
|
||||
|
||||
var queued = mi.Modifiers.HasModifier(Modifiers.Shift);
|
||||
yield return new Order(OrderName, null, Target.FromCell(world, cell), queued, null, Subjects.ToArray());
|
||||
yield return new Order(OrderName, null, Target.FromCell(world, cell), queued, null, subjects.ToArray());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,6 +69,11 @@ namespace OpenRA.Orders
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void SelectionChanged(World world, IEnumerable<Actor> selected)
|
||||
{
|
||||
subjects = selected;
|
||||
}
|
||||
|
||||
public override bool ClearSelectionOnLeftClick { get { return false; } }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,5 +24,6 @@ namespace OpenRA
|
||||
string GetCursor(World world, CPos cell, int2 worldPixel, MouseInput mi);
|
||||
void Deactivate();
|
||||
bool HandleKeyPress(KeyInput e);
|
||||
void SelectionChanged(World world, IEnumerable<Actor> selected);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,6 +124,8 @@ namespace OpenRA.Orders
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual void SelectionChanged(World world, IEnumerable<Actor> selected) { }
|
||||
|
||||
/// <summary>
|
||||
/// Returns the most appropriate order for a given actor and target.
|
||||
/// First priority is given to orders that interact with the given actors.
|
||||
|
||||
Reference in New Issue
Block a user