Pushed down the MouseInput handling to the OrderGenerators and made a base class for handling the basic logic

This commit is contained in:
teinarss
2019-03-30 20:07:11 +01:00
committed by reaperrr
parent 9ec8d25dff
commit 1dd90a1d7b
13 changed files with 120 additions and 77 deletions

View File

@@ -20,7 +20,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Orders
{
public class PlaceBuildingOrderGenerator : IOrderGenerator
public class PlaceBuildingOrderGenerator : OrderGenerator
{
[Flags]
enum CellType { Valid = 0, Invalid = 1, LineBuild = 2 }
@@ -82,7 +82,7 @@ namespace OpenRA.Mods.Common.Orders
return cell;
}
public IEnumerable<Order> Order(World world, CPos cell, int2 worldPixel, MouseInput mi)
protected override IEnumerable<Order> OrderInner(World world, CPos cell, int2 worldPixel, MouseInput mi)
{
if (mi.Button == MouseButton.Right)
world.CancelInputMode();
@@ -147,7 +147,7 @@ namespace OpenRA.Mods.Common.Orders
}
}
public void Tick(World world)
protected override void Tick(World world)
{
if (queue.AllQueued().All(i => !i.Done || i.Item != actorInfo.Name))
world.CancelInputMode();
@@ -169,8 +169,8 @@ namespace OpenRA.Mods.Common.Orders
return host.TraitsImplementing<Pluggable>().Any(p => location + p.Info.Offset == cell && p.AcceptsPlug(host, plug.Type));
}
public IEnumerable<IRenderable> Render(WorldRenderer wr, World world) { yield break; }
public IEnumerable<IRenderable> RenderAboveShroud(WorldRenderer wr, World world)
protected override IEnumerable<IRenderable> Render(WorldRenderer wr, World world) { yield break; }
protected override IEnumerable<IRenderable> RenderAboveShroud(WorldRenderer wr, World world)
{
var topLeft = viewport.ViewToWorld(Viewport.LastMousePos + topLeftScreenOffset);
var centerPosition = world.Map.CenterOfCell(topLeft) + centerOffset;
@@ -250,7 +250,7 @@ namespace OpenRA.Mods.Common.Orders
}
}
public string GetCursor(World world, CPos cell, int2 worldPixel, MouseInput mi) { return "default"; }
protected override string GetCursor(World world, CPos cell, int2 worldPixel, MouseInput mi) { return "default"; }
IEnumerable<Order> ClearBlockersOrders(World world, CPos topLeft)
{