Ditto for OrderGenerators.
This commit is contained in:
@@ -47,7 +47,7 @@ namespace OpenRa
|
||||
{
|
||||
if (orderGenerator == null) return;
|
||||
|
||||
var orders = orderGenerator.Order(xy.ToInt2(), mi).ToArray();
|
||||
var orders = orderGenerator.Order(Game.world, xy.ToInt2(), mi).ToArray();
|
||||
recentOrders.AddRange( orders );
|
||||
|
||||
var voicedActor = orders.Select(o => o.Subject)
|
||||
@@ -157,7 +157,7 @@ namespace OpenRa
|
||||
Modifiers = GetModifierKeys(),
|
||||
};
|
||||
|
||||
return orderGenerator.GetCursor( MousePosition.ToInt2(), mi );
|
||||
return orderGenerator.GetCursor( Game.world, MousePosition.ToInt2(), mi );
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
@@ -131,7 +131,7 @@ namespace OpenRa
|
||||
{
|
||||
orderManager.Tick();
|
||||
if (controller.orderGenerator != null)
|
||||
controller.orderGenerator.Tick();
|
||||
controller.orderGenerator.Tick( world );
|
||||
|
||||
world.Tick();
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ namespace OpenRa.Graphics
|
||||
DrawBandBox();
|
||||
|
||||
if (Game.controller.orderGenerator != null)
|
||||
Game.controller.orderGenerator.Render();
|
||||
Game.controller.orderGenerator.Render( world );
|
||||
|
||||
world.LocalPlayer.Shroud.Draw(spriteRenderer);
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace OpenRa.Orders
|
||||
this.power = power;
|
||||
}
|
||||
|
||||
public IEnumerable<Order> Order(int2 xy, MouseInput mi)
|
||||
public IEnumerable<Order> Order(World world, int2 xy, MouseInput mi)
|
||||
{
|
||||
if (mi.Button == MouseButton.Left)
|
||||
{
|
||||
@@ -29,15 +29,15 @@ namespace OpenRa.Orders
|
||||
power != null ? power.Name : null);
|
||||
}
|
||||
|
||||
public void Tick() {}
|
||||
public void Render()
|
||||
public void Tick( World world ) {}
|
||||
public void Render( World world )
|
||||
{
|
||||
Game.world.WorldRenderer.DrawSelectionBox(self, Color.White, true);
|
||||
world.WorldRenderer.DrawSelectionBox(self, Color.White, true);
|
||||
}
|
||||
|
||||
public Cursor GetCursor(int2 xy, MouseInput mi)
|
||||
public Cursor GetCursor(World world, int2 xy, MouseInput mi)
|
||||
{
|
||||
if (!Game.world.LocalPlayer.Shroud.IsExplored(xy))
|
||||
if (!world.LocalPlayer.Shroud.IsExplored(xy))
|
||||
return Cursor.MoveBlocked;
|
||||
|
||||
var movement = self.traits.GetOrDefault<IMovement>();
|
||||
|
||||
@@ -15,21 +15,21 @@ namespace OpenRa.Orders
|
||||
this.power = power;
|
||||
}
|
||||
|
||||
public IEnumerable<Order> Order(int2 xy, MouseInput mi)
|
||||
public IEnumerable<Order> Order(World world, int2 xy, MouseInput mi)
|
||||
{
|
||||
if (mi.Button == MouseButton.Right)
|
||||
Game.controller.CancelInputMode();
|
||||
|
||||
return OrderInner(xy, mi);
|
||||
return OrderInner(world, xy, mi);
|
||||
}
|
||||
|
||||
IEnumerable<Order> OrderInner(int2 xy, MouseInput mi)
|
||||
IEnumerable<Order> OrderInner(World world, int2 xy, MouseInput mi)
|
||||
{
|
||||
if (mi.Button == MouseButton.Left)
|
||||
{
|
||||
var loc = mi.Location + Game.viewport.Location;
|
||||
var underCursor = Game.world.FindUnits(loc, loc)
|
||||
.Where(a => a.Owner == Game.world.LocalPlayer
|
||||
var underCursor = world.FindUnits(loc, loc)
|
||||
.Where(a => a.Owner == world.LocalPlayer
|
||||
&& a.traits.Contains<Chronoshiftable>()
|
||||
&& a.traits.Contains<Selectable>()).FirstOrDefault();
|
||||
|
||||
@@ -38,21 +38,21 @@ namespace OpenRa.Orders
|
||||
}
|
||||
}
|
||||
|
||||
public void Tick()
|
||||
public void Tick( World world )
|
||||
{
|
||||
var hasChronosphere = Game.world.Actors
|
||||
.Any(a => a.Owner == Game.world.LocalPlayer && a.traits.Contains<Chronosphere>());
|
||||
var hasChronosphere = world.Actors
|
||||
.Any(a => a.Owner == world.LocalPlayer && a.traits.Contains<Chronosphere>());
|
||||
|
||||
if (!hasChronosphere)
|
||||
Game.controller.CancelInputMode();
|
||||
}
|
||||
|
||||
public void Render() { }
|
||||
public void Render( World world ) { }
|
||||
|
||||
public Cursor GetCursor(int2 xy, MouseInput mi)
|
||||
public Cursor GetCursor(World world, int2 xy, MouseInput mi)
|
||||
{
|
||||
mi.Button = MouseButton.Left;
|
||||
return OrderInner(xy, mi).Any()
|
||||
return OrderInner(world, xy, mi).Any()
|
||||
? Cursor.ChronoshiftSelect : Cursor.MoveBlocked;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,9 +4,9 @@ namespace OpenRa
|
||||
{
|
||||
public interface IOrderGenerator
|
||||
{
|
||||
IEnumerable<Order> Order( int2 xy, MouseInput mi );
|
||||
void Tick();
|
||||
void Render();
|
||||
Cursor GetCursor(int2 xy, MouseInput mi);
|
||||
IEnumerable<Order> Order( World world, int2 xy, MouseInput mi );
|
||||
void Tick( World world );
|
||||
void Render( World world );
|
||||
Cursor GetCursor( World world, int2 xy, MouseInput mi );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,21 +15,21 @@ namespace OpenRa.Orders
|
||||
this.power = power;
|
||||
}
|
||||
|
||||
public IEnumerable<Order> Order(int2 xy, MouseInput mi)
|
||||
public IEnumerable<Order> Order(World world, int2 xy, MouseInput mi)
|
||||
{
|
||||
if (mi.Button == MouseButton.Right)
|
||||
Game.controller.CancelInputMode();
|
||||
|
||||
return OrderInner(xy, mi);
|
||||
return OrderInner(world, xy, mi);
|
||||
}
|
||||
|
||||
IEnumerable<Order> OrderInner(int2 xy, MouseInput mi)
|
||||
IEnumerable<Order> OrderInner(World world, int2 xy, MouseInput mi)
|
||||
{
|
||||
if (mi.Button == MouseButton.Left)
|
||||
{
|
||||
var loc = mi.Location + Game.viewport.Location;
|
||||
var underCursor = Game.world.FindUnits(loc, loc)
|
||||
.Where(a => a.Owner == Game.world.LocalPlayer
|
||||
var underCursor = world.FindUnits(loc, loc)
|
||||
.Where(a => a.Owner == world.LocalPlayer
|
||||
&& a.traits.Contains<IronCurtainable>()
|
||||
&& a.traits.Contains<Selectable>()).FirstOrDefault();
|
||||
|
||||
@@ -38,21 +38,21 @@ namespace OpenRa.Orders
|
||||
}
|
||||
}
|
||||
|
||||
public void Tick()
|
||||
public void Tick( World world )
|
||||
{
|
||||
var hasStructure = Game.world.Actors
|
||||
.Any(a => a.Owner == Game.world.LocalPlayer && a.traits.Contains<IronCurtain>());
|
||||
var hasStructure = world.Actors
|
||||
.Any(a => a.Owner == world.LocalPlayer && a.traits.Contains<IronCurtain>());
|
||||
|
||||
if (!hasStructure)
|
||||
Game.controller.CancelInputMode();
|
||||
}
|
||||
|
||||
public void Render() { }
|
||||
public void Render( World world ) { }
|
||||
|
||||
public Cursor GetCursor(int2 xy, MouseInput mi)
|
||||
public Cursor GetCursor(World world, int2 xy, MouseInput mi)
|
||||
{
|
||||
mi.Button = MouseButton.Left;
|
||||
return OrderInner(xy, mi).Any()
|
||||
return OrderInner(world, xy, mi).Any()
|
||||
? Cursor.Ability : Cursor.MoveBlocked;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,21 +16,21 @@ namespace OpenRa.Orders
|
||||
Building = name;
|
||||
}
|
||||
|
||||
public IEnumerable<Order> Order(int2 xy, MouseInput mi)
|
||||
public IEnumerable<Order> Order(World world, int2 xy, MouseInput mi)
|
||||
{
|
||||
if (mi.Button == MouseButton.Right)
|
||||
Game.controller.CancelInputMode();
|
||||
|
||||
return InnerOrder(xy, mi);
|
||||
return InnerOrder(world, xy, mi);
|
||||
}
|
||||
|
||||
IEnumerable<Order> InnerOrder(int2 xy, MouseInput mi)
|
||||
IEnumerable<Order> InnerOrder(World world, int2 xy, MouseInput mi)
|
||||
{
|
||||
if (mi.Button == MouseButton.Left)
|
||||
{
|
||||
var topLeft = xy - Footprint.AdjustForBuildingSize( BuildingInfo );
|
||||
if (!Game.world.CanPlaceBuilding( Building, BuildingInfo, topLeft, null)
|
||||
|| !Game.world.IsCloseEnoughToBase(Producer.Owner, Building, BuildingInfo, topLeft))
|
||||
if (!world.CanPlaceBuilding( Building, BuildingInfo, topLeft, null)
|
||||
|| !world.IsCloseEnoughToBase(Producer.Owner, Building, BuildingInfo, topLeft))
|
||||
{
|
||||
Sound.Play("nodeply1.aud");
|
||||
yield break;
|
||||
@@ -40,19 +40,19 @@ namespace OpenRa.Orders
|
||||
}
|
||||
}
|
||||
|
||||
public void Tick()
|
||||
public void Tick( World world )
|
||||
{
|
||||
var producing = Producer.traits.Get<Traits.ProductionQueue>().CurrentItem( Rules.Info[ Building ].Category );
|
||||
if (producing == null || producing.Item != Building || producing.RemainingTime != 0)
|
||||
Game.controller.CancelInputMode();
|
||||
}
|
||||
|
||||
public void Render()
|
||||
public void Render( World world )
|
||||
{
|
||||
Game.world.WorldRenderer.uiOverlay.DrawBuildingGrid( Building, BuildingInfo );
|
||||
world.WorldRenderer.uiOverlay.DrawBuildingGrid( Building, BuildingInfo );
|
||||
}
|
||||
|
||||
public Cursor GetCursor(int2 xy, MouseInput mi)
|
||||
public Cursor GetCursor(World world, int2 xy, MouseInput mi)
|
||||
{
|
||||
return Cursor.Default;
|
||||
}
|
||||
|
||||
@@ -9,21 +9,21 @@ namespace OpenRa.Orders
|
||||
{
|
||||
class PowerDownOrderGenerator : IOrderGenerator
|
||||
{
|
||||
public IEnumerable<Order> Order(int2 xy, MouseInput mi)
|
||||
public IEnumerable<Order> Order(World world, int2 xy, MouseInput mi)
|
||||
{
|
||||
if (mi.Button == MouseButton.Right)
|
||||
Game.controller.CancelInputMode();
|
||||
|
||||
return OrderInner(xy, mi);
|
||||
return OrderInner(world, xy, mi);
|
||||
}
|
||||
|
||||
IEnumerable<Order> OrderInner(int2 xy, MouseInput mi)
|
||||
IEnumerable<Order> OrderInner(World world, int2 xy, MouseInput mi)
|
||||
{
|
||||
if (mi.Button == MouseButton.Left)
|
||||
{
|
||||
var loc = mi.Location + Game.viewport.Location;
|
||||
var underCursor = Game.world.FindUnits(loc, loc)
|
||||
.Where(a => a.Owner == Game.world.LocalPlayer
|
||||
var underCursor = world.FindUnits(loc, loc)
|
||||
.Where(a => a.Owner == world.LocalPlayer
|
||||
&& a.traits.Contains<Building>()
|
||||
&& a.traits.Contains<Selectable>()).FirstOrDefault();
|
||||
|
||||
@@ -32,13 +32,13 @@ namespace OpenRa.Orders
|
||||
}
|
||||
}
|
||||
|
||||
public void Tick() { }
|
||||
public void Render() { }
|
||||
public void Tick( World world ) { }
|
||||
public void Render( World world ) { }
|
||||
|
||||
public Cursor GetCursor(int2 xy, MouseInput mi)
|
||||
public Cursor GetCursor(World world, int2 xy, MouseInput mi)
|
||||
{
|
||||
mi.Button = MouseButton.Left;
|
||||
return OrderInner(xy, mi).Any()
|
||||
return OrderInner(world, xy, mi).Any()
|
||||
? Cursor.PowerDown : Cursor.PowerDown;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,21 +9,21 @@ namespace OpenRa.Orders
|
||||
{
|
||||
class RepairOrderGenerator : IOrderGenerator
|
||||
{
|
||||
public IEnumerable<Order> Order(int2 xy, MouseInput mi)
|
||||
public IEnumerable<Order> Order(World world, int2 xy, MouseInput mi)
|
||||
{
|
||||
if (mi.Button == MouseButton.Right)
|
||||
Game.controller.CancelInputMode();
|
||||
|
||||
return OrderInner(xy, mi);
|
||||
return OrderInner(world, xy, mi);
|
||||
}
|
||||
|
||||
IEnumerable<Order> OrderInner(int2 xy, MouseInput mi)
|
||||
IEnumerable<Order> OrderInner(World world, int2 xy, MouseInput mi)
|
||||
{
|
||||
if (mi.Button == MouseButton.Left)
|
||||
{
|
||||
var loc = mi.Location + Game.viewport.Location;
|
||||
var underCursor = Game.world.FindUnits(loc, loc)
|
||||
.Where(a => a.Owner == Game.world.LocalPlayer
|
||||
var underCursor = world.FindUnits(loc, loc)
|
||||
.Where(a => a.Owner == world.LocalPlayer
|
||||
&& a.traits.Contains<Building>()
|
||||
&& a.traits.Contains<Selectable>()).FirstOrDefault();
|
||||
|
||||
@@ -34,24 +34,24 @@ namespace OpenRa.Orders
|
||||
}
|
||||
}
|
||||
|
||||
public void Tick()
|
||||
public void Tick( World world )
|
||||
{
|
||||
if (!Game.Settings.RepairRequiresConyard)
|
||||
return;
|
||||
|
||||
var hasFact = Game.world.Actors
|
||||
.Any(a => a.Owner == Game.world.LocalPlayer && a.traits.Contains<ConstructionYard>());
|
||||
var hasFact = world.Actors
|
||||
.Any(a => a.Owner == world.LocalPlayer && a.traits.Contains<ConstructionYard>());
|
||||
|
||||
if (!hasFact)
|
||||
Game.controller.CancelInputMode();
|
||||
}
|
||||
|
||||
public void Render() {}
|
||||
public void Render( World world ) {}
|
||||
|
||||
public Cursor GetCursor(int2 xy, MouseInput mi)
|
||||
public Cursor GetCursor(World world, int2 xy, MouseInput mi)
|
||||
{
|
||||
mi.Button = MouseButton.Left;
|
||||
return OrderInner(xy, mi).Any()
|
||||
return OrderInner(world, xy, mi).Any()
|
||||
? Cursor.Repair : Cursor.RepairBlocked;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,21 +9,21 @@ namespace OpenRa.Orders
|
||||
{
|
||||
class SellOrderGenerator : IOrderGenerator
|
||||
{
|
||||
public IEnumerable<Order> Order(int2 xy, MouseInput mi)
|
||||
public IEnumerable<Order> Order(World world, int2 xy, MouseInput mi)
|
||||
{
|
||||
if (mi.Button == MouseButton.Right)
|
||||
Game.controller.CancelInputMode();
|
||||
|
||||
return OrderInner(xy, mi);
|
||||
return OrderInner(world, xy, mi);
|
||||
}
|
||||
|
||||
IEnumerable<Order> OrderInner(int2 xy, MouseInput mi)
|
||||
IEnumerable<Order> OrderInner(World world, int2 xy, MouseInput mi)
|
||||
{
|
||||
if (mi.Button == MouseButton.Left)
|
||||
{
|
||||
var loc = mi.Location + Game.viewport.Location;
|
||||
var underCursor = Game.world.FindUnits(loc, loc)
|
||||
.Where(a => a.Owner == Game.world.LocalPlayer
|
||||
var underCursor = world.FindUnits(loc, loc)
|
||||
.Where(a => a.Owner == world.LocalPlayer
|
||||
&& a.traits.Contains<Building>()
|
||||
&& a.traits.Contains<Selectable>()).FirstOrDefault();
|
||||
|
||||
@@ -34,13 +34,13 @@ namespace OpenRa.Orders
|
||||
}
|
||||
}
|
||||
|
||||
public void Tick() {}
|
||||
public void Render() {}
|
||||
public void Tick( World world ) {}
|
||||
public void Render( World world ) {}
|
||||
|
||||
public Cursor GetCursor(int2 xy, MouseInput mi)
|
||||
public Cursor GetCursor(World world, int2 xy, MouseInput mi)
|
||||
{
|
||||
mi.Button = MouseButton.Left;
|
||||
return OrderInner(xy, mi).Any()
|
||||
return OrderInner(world, xy, mi).Any()
|
||||
? Cursor.Sell : Cursor.SellBlocked;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace OpenRa.Orders
|
||||
selection = selected.ToList();
|
||||
}
|
||||
|
||||
public IEnumerable<Order> Order( int2 xy, MouseInput mi )
|
||||
public IEnumerable<Order> Order( World world, int2 xy, MouseInput mi )
|
||||
{
|
||||
foreach( var unit in selection )
|
||||
{
|
||||
@@ -25,31 +25,31 @@ namespace OpenRa.Orders
|
||||
}
|
||||
}
|
||||
|
||||
public void Tick()
|
||||
public void Tick( World world )
|
||||
{
|
||||
selection.RemoveAll(a => !a.IsInWorld);
|
||||
}
|
||||
|
||||
public void Render()
|
||||
public void Render( World world )
|
||||
{
|
||||
foreach( var a in selection )
|
||||
Game.world.WorldRenderer.DrawSelectionBox( a, Color.White, true );
|
||||
world.WorldRenderer.DrawSelectionBox( a, Color.White, true );
|
||||
}
|
||||
|
||||
public Cursor GetCursor(int2 xy, MouseInput mi)
|
||||
public Cursor GetCursor( World world, int2 xy, MouseInput mi )
|
||||
{
|
||||
return ChooseCursor(mi);
|
||||
return ChooseCursor(world, mi);
|
||||
}
|
||||
|
||||
Cursor ChooseCursor( MouseInput mi )
|
||||
Cursor ChooseCursor( World world, MouseInput mi )
|
||||
{
|
||||
var p = Game.controller.MousePosition;
|
||||
var c = Order(p.ToInt2(), mi)
|
||||
var c = Order(world, p.ToInt2(), mi)
|
||||
.Select(o => CursorForOrderString(o.OrderString, o.Subject, o.TargetLocation))
|
||||
.FirstOrDefault(a => a != null);
|
||||
|
||||
return c ??
|
||||
(Game.world.SelectActorsInBox(Game.CellSize * p,
|
||||
(world.SelectActorsInBox(Game.CellSize * p,
|
||||
Game.CellSize * p).Any()
|
||||
? Cursor.Select : Cursor.Default);
|
||||
}
|
||||
@@ -69,7 +69,7 @@ namespace OpenRa.Orders
|
||||
return Cursor.MoveBlocked;
|
||||
case "DeployMcv":
|
||||
var factBuildingInfo = Rules.Info["fact"].Traits.Get<BuildingInfo>();
|
||||
if (Game.world.CanPlaceBuilding("fact", factBuildingInfo, a.Location - new int2(1, 1), a))
|
||||
if (a.World.CanPlaceBuilding("fact", factBuildingInfo, a.Location - new int2(1, 1), a))
|
||||
return Cursor.Deploy;
|
||||
else
|
||||
return Cursor.DeployBlocked;
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace OpenRa.Mods.Aftermath.Orders
|
||||
this.self = self;
|
||||
}
|
||||
|
||||
public IEnumerable<Order> Order(int2 xy, MouseInput mi)
|
||||
public IEnumerable<Order> Order(World world, int2 xy, MouseInput mi)
|
||||
{
|
||||
if (mi.Button == MouseButton.Left)
|
||||
{
|
||||
@@ -24,15 +24,15 @@ namespace OpenRa.Mods.Aftermath.Orders
|
||||
yield return new Order("ChronoshiftSelf", self, null, xy, null);
|
||||
}
|
||||
|
||||
public void Tick() { }
|
||||
public void Render()
|
||||
public void Tick( World world ) { }
|
||||
public void Render( World world )
|
||||
{
|
||||
Game.world.WorldRenderer.DrawSelectionBox(self, Color.White, true);
|
||||
world.WorldRenderer.DrawSelectionBox(self, Color.White, true);
|
||||
}
|
||||
|
||||
public Cursor GetCursor(int2 xy, MouseInput mi)
|
||||
public Cursor GetCursor(World world, int2 xy, MouseInput mi)
|
||||
{
|
||||
if (!Game.world.LocalPlayer.Shroud.IsExplored(xy))
|
||||
if (!world.LocalPlayer.Shroud.IsExplored(xy))
|
||||
return Cursor.MoveBlocked;
|
||||
|
||||
var movement = self.traits.GetOrDefault<IMovement>();
|
||||
|
||||
Reference in New Issue
Block a user