Kill Controller
This commit is contained in:
@@ -1,74 +0,0 @@
|
|||||||
#region Copyright & License Information
|
|
||||||
/*
|
|
||||||
* Copyright 2007-2010 The OpenRA Developers (see AUTHORS)
|
|
||||||
* This file is part of OpenRA, which is free software. It is made
|
|
||||||
* available to you under the terms of the GNU General Public License
|
|
||||||
* as published by the Free Software Foundation. For more information,
|
|
||||||
* see LICENSE.
|
|
||||||
*/
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Linq;
|
|
||||||
using OpenRA.FileFormats;
|
|
||||||
using OpenRA.Graphics;
|
|
||||||
using OpenRA.Orders;
|
|
||||||
using OpenRA.Traits;
|
|
||||||
|
|
||||||
namespace OpenRA
|
|
||||||
{
|
|
||||||
public class Controller
|
|
||||||
{
|
|
||||||
public IOrderGenerator orderGenerator = new UnitOrderGenerator();
|
|
||||||
public Selection selection = new Selection();
|
|
||||||
|
|
||||||
public void CancelInputMode() { orderGenerator = new UnitOrderGenerator(); }
|
|
||||||
|
|
||||||
public bool ToggleInputMode<T>() where T : IOrderGenerator, new()
|
|
||||||
{
|
|
||||||
if (orderGenerator is T)
|
|
||||||
{
|
|
||||||
CancelInputMode();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
orderGenerator = new T();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ApplyOrders(World world, float2 xy, MouseInput mi)
|
|
||||||
{
|
|
||||||
if (orderGenerator == null) return;
|
|
||||||
|
|
||||||
var orders = orderGenerator.Order(world, xy.ToInt2(), mi).ToArray();
|
|
||||||
Game.orderManager.IssueOrders( orders );
|
|
||||||
|
|
||||||
// Find an actor with a phrase to say
|
|
||||||
var done = false;
|
|
||||||
foreach (var o in orders)
|
|
||||||
{
|
|
||||||
foreach (var v in o.Subject.traits.WithInterface<IOrderVoice>())
|
|
||||||
{
|
|
||||||
if (Sound.PlayVoice(v.VoicePhraseForOrder(o.Subject, o), o.Subject))
|
|
||||||
{
|
|
||||||
done = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (done) break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public float2 dragStart, dragEnd;
|
|
||||||
public Pair<float2, float2>? SelectionBox
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (dragStart == dragEnd) return null;
|
|
||||||
return Pair.New(Game.CellSize * dragStart, Game.CellSize * dragEnd);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -37,7 +37,6 @@ namespace OpenRA
|
|||||||
|
|
||||||
public static World world;
|
public static World world;
|
||||||
internal static Viewport viewport;
|
internal static Viewport viewport;
|
||||||
public static Controller controller;
|
|
||||||
internal static UserSettings Settings;
|
internal static UserSettings Settings;
|
||||||
|
|
||||||
internal static OrderManager orderManager;
|
internal static OrderManager orderManager;
|
||||||
@@ -286,9 +285,8 @@ namespace OpenRA
|
|||||||
|
|
||||||
if (isNetTick) orderManager.Tick(world);
|
if (isNetTick) orderManager.Tick(world);
|
||||||
|
|
||||||
controller.orderGenerator.Tick(world);
|
world.OrderGenerator.Tick(world);
|
||||||
controller.selection.Tick(world);
|
world.Selection.Tick(world);
|
||||||
|
|
||||||
world.Tick();
|
world.Tick();
|
||||||
|
|
||||||
PerfHistory.Tick();
|
PerfHistory.Tick();
|
||||||
@@ -501,8 +499,6 @@ namespace OpenRA
|
|||||||
var resolution = GetResolution(settings, Game.Settings.WindowMode);
|
var resolution = GetResolution(settings, Game.Settings.WindowMode);
|
||||||
Renderer = new Renderer(resolution, Game.Settings.WindowMode);
|
Renderer = new Renderer(resolution, Game.Settings.WindowMode);
|
||||||
resolution = Renderer.Resolution;
|
resolution = Renderer.Resolution;
|
||||||
|
|
||||||
controller = new Controller();
|
|
||||||
clientSize = new int2(resolution);
|
clientSize = new int2(resolution);
|
||||||
|
|
||||||
Sound.Initialize();
|
Sound.Initialize();
|
||||||
|
|||||||
@@ -99,8 +99,8 @@ namespace OpenRA.Graphics
|
|||||||
|
|
||||||
terrainRenderer.Draw(Game.viewport);
|
terrainRenderer.Draw(Game.viewport);
|
||||||
|
|
||||||
if (Game.controller.orderGenerator != null)
|
if (world.OrderGenerator != null)
|
||||||
Game.controller.orderGenerator.RenderBeforeWorld(world);
|
world.OrderGenerator.RenderBeforeWorld(world);
|
||||||
|
|
||||||
Game.Renderer.SpriteRenderer.Flush();
|
Game.Renderer.SpriteRenderer.Flush();
|
||||||
Game.Renderer.LineRenderer.Flush();
|
Game.Renderer.LineRenderer.Flush();
|
||||||
@@ -109,10 +109,9 @@ namespace OpenRA.Graphics
|
|||||||
Game.Renderer.SpriteRenderer.DrawSprite(image.Sprite, image.Pos, image.Palette);
|
Game.Renderer.SpriteRenderer.DrawSprite(image.Sprite, image.Pos, image.Palette);
|
||||||
uiOverlay.Draw(world);
|
uiOverlay.Draw(world);
|
||||||
Game.Renderer.SpriteRenderer.Flush();
|
Game.Renderer.SpriteRenderer.Flush();
|
||||||
DrawBandBox();
|
|
||||||
|
|
||||||
if (Game.controller.orderGenerator != null)
|
if (world.OrderGenerator != null)
|
||||||
Game.controller.orderGenerator.RenderAfterWorld(world);
|
world.OrderGenerator.RenderAfterWorld(world);
|
||||||
|
|
||||||
if (world.LocalPlayer != null)
|
if (world.LocalPlayer != null)
|
||||||
world.LocalPlayer.Shroud.Draw();
|
world.LocalPlayer.Shroud.Draw();
|
||||||
@@ -155,24 +154,6 @@ namespace OpenRA.Graphics
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawBandBox()
|
|
||||||
{
|
|
||||||
var selbox = Game.controller.SelectionBox;
|
|
||||||
if (selbox == null) return;
|
|
||||||
|
|
||||||
var a = selbox.Value.First;
|
|
||||||
var b = new float2(selbox.Value.Second.X - a.X, 0);
|
|
||||||
var c = new float2(0, selbox.Value.Second.Y - a.Y);
|
|
||||||
|
|
||||||
Game.Renderer.LineRenderer.DrawLine(a, a + b, Color.White, Color.White);
|
|
||||||
Game.Renderer.LineRenderer.DrawLine(a + b, a + b + c, Color.White, Color.White);
|
|
||||||
Game.Renderer.LineRenderer.DrawLine(a + b + c, a + c, Color.White, Color.White);
|
|
||||||
Game.Renderer.LineRenderer.DrawLine(a, a + c, Color.White, Color.White);
|
|
||||||
|
|
||||||
foreach (var u in world.SelectActorsInBox(selbox.Value.First, selbox.Value.Second))
|
|
||||||
DrawSelectionBox(u, Color.Yellow);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void DrawSelectionBox(Actor selectedUnit, Color c)
|
public void DrawSelectionBox(Actor selectedUnit, Color c)
|
||||||
{
|
{
|
||||||
var bounds = selectedUnit.GetBounds(true);
|
var bounds = selectedUnit.GetBounds(true);
|
||||||
|
|||||||
@@ -130,7 +130,6 @@
|
|||||||
<Compile Include="Traits\World\ChoosePaletteOnSelect.cs" />
|
<Compile Include="Traits\World\ChoosePaletteOnSelect.cs" />
|
||||||
<Compile Include="Traits\World\Country.cs" />
|
<Compile Include="Traits\World\Country.cs" />
|
||||||
<Compile Include="Actor.cs" />
|
<Compile Include="Actor.cs" />
|
||||||
<Compile Include="Controller.cs" />
|
|
||||||
<Compile Include="Cursor.cs" />
|
<Compile Include="Cursor.cs" />
|
||||||
<Compile Include="GameRules\Footprint.cs" />
|
<Compile Include="GameRules\Footprint.cs" />
|
||||||
<Compile Include="GameRules\Rules.cs" />
|
<Compile Include="GameRules\Rules.cs" />
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ namespace OpenRA.Orders
|
|||||||
public IEnumerable<Order> Order(World world, int2 xy, MouseInput mi)
|
public IEnumerable<Order> Order(World world, int2 xy, MouseInput mi)
|
||||||
{
|
{
|
||||||
if (mi.Button == MouseButton.Right)
|
if (mi.Button == MouseButton.Right)
|
||||||
Game.controller.CancelInputMode();
|
world.CancelInputMode();
|
||||||
return OrderInner(world, xy, mi);
|
return OrderInner(world, xy, mi);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,7 +60,7 @@ namespace OpenRA.Orders
|
|||||||
.Any();
|
.Any();
|
||||||
|
|
||||||
if (!hasStructure)
|
if (!hasStructure)
|
||||||
Game.controller.CancelInputMode();
|
world.CancelInputMode();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ namespace OpenRA.Orders
|
|||||||
public IEnumerable<Order> Order(World world, int2 xy, MouseInput mi)
|
public IEnumerable<Order> Order(World world, int2 xy, MouseInput mi)
|
||||||
{
|
{
|
||||||
if (mi.Button == MouseButton.Right)
|
if (mi.Button == MouseButton.Right)
|
||||||
Game.controller.CancelInputMode();
|
world.CancelInputMode();
|
||||||
|
|
||||||
return InnerOrder(world, xy, mi);
|
return InnerOrder(world, xy, mi);
|
||||||
}
|
}
|
||||||
@@ -58,7 +58,7 @@ namespace OpenRA.Orders
|
|||||||
{
|
{
|
||||||
var producing = Producer.traits.Get<Traits.ProductionQueue>().CurrentItem( Rules.Info[ Building ].Category );
|
var producing = Producer.traits.Get<Traits.ProductionQueue>().CurrentItem( Rules.Info[ Building ].Category );
|
||||||
if (producing == null || producing.Item != Building || producing.RemainingTime != 0)
|
if (producing == null || producing.Item != Building || producing.RemainingTime != 0)
|
||||||
Game.controller.CancelInputMode();
|
world.CancelInputMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RenderAfterWorld( World world ) {}
|
public void RenderAfterWorld( World world ) {}
|
||||||
|
|||||||
@@ -1,65 +1,65 @@
|
|||||||
#region Copyright & License Information
|
#region Copyright & License Information
|
||||||
/*
|
/*
|
||||||
* Copyright 2007-2010 The OpenRA Developers (see AUTHORS)
|
* Copyright 2007-2010 The OpenRA Developers (see AUTHORS)
|
||||||
* This file is part of OpenRA, which is free software. It is made
|
* This file is part of OpenRA, which is free software. It is made
|
||||||
* available to you under the terms of the GNU General Public License
|
* available to you under the terms of the GNU General Public License
|
||||||
* as published by the Free Software Foundation. For more information,
|
* as published by the Free Software Foundation. For more information,
|
||||||
* see LICENSE.
|
* see LICENSE.
|
||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
|
||||||
namespace OpenRA.Orders
|
namespace OpenRA.Orders
|
||||||
{
|
{
|
||||||
class UnitOrderGenerator : IOrderGenerator
|
class UnitOrderGenerator : IOrderGenerator
|
||||||
{
|
{
|
||||||
public IEnumerable<Order> Order( World world, int2 xy, MouseInput mi )
|
public IEnumerable<Order> Order( World world, int2 xy, MouseInput mi )
|
||||||
{
|
{
|
||||||
var orders = Game.controller.selection.Actors
|
var orders = world.Selection.Actors
|
||||||
.Select(a => a.Order(xy, mi))
|
.Select(a => a.Order(xy, mi))
|
||||||
.Where(o => o != null)
|
.Where(o => o != null)
|
||||||
.ToArray();
|
.ToArray();
|
||||||
|
|
||||||
var actorsInvolved = orders.Select(o => o.Subject).Distinct();
|
var actorsInvolved = orders.Select(o => o.Subject).Distinct();
|
||||||
if (actorsInvolved.Any())
|
if (actorsInvolved.Any())
|
||||||
yield return new Order("CreateGroup", actorsInvolved.First().Owner.PlayerActor,
|
yield return new Order("CreateGroup", actorsInvolved.First().Owner.PlayerActor,
|
||||||
string.Join(",", actorsInvolved.Select(a => a.ActorID.ToString()).ToArray()));
|
string.Join(",", actorsInvolved.Select(a => a.ActorID.ToString()).ToArray()));
|
||||||
|
|
||||||
foreach (var o in orders)
|
foreach (var o in orders)
|
||||||
yield return o;
|
yield return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Tick( World world ) {}
|
public void Tick( World world ) {}
|
||||||
|
|
||||||
public void RenderBeforeWorld(World world)
|
public void RenderBeforeWorld(World world)
|
||||||
{
|
{
|
||||||
foreach (var a in Game.controller.selection.Actors)
|
foreach (var a in world.Selection.Actors)
|
||||||
foreach (var t in a.traits.WithInterface<IPreRenderSelection>())
|
foreach (var t in a.traits.WithInterface<IPreRenderSelection>())
|
||||||
t.RenderBeforeWorld(a);
|
t.RenderBeforeWorld(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RenderAfterWorld( World world )
|
public void RenderAfterWorld( World world )
|
||||||
{
|
{
|
||||||
foreach (var a in Game.controller.selection.Actors)
|
foreach (var a in world.Selection.Actors)
|
||||||
foreach (var t in a.traits.WithInterface<IPostRenderSelection>())
|
foreach (var t in a.traits.WithInterface<IPostRenderSelection>())
|
||||||
t.RenderAfterWorld(a);
|
t.RenderAfterWorld(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetCursor( World world, int2 xy, MouseInput mi )
|
public string GetCursor( World world, int2 xy, MouseInput mi )
|
||||||
{
|
{
|
||||||
var c = Order(world, xy, mi)
|
var c = Order(world, xy, mi)
|
||||||
.Select(o => o.Subject.traits.WithInterface<IOrderCursor>()
|
.Select(o => o.Subject.traits.WithInterface<IOrderCursor>()
|
||||||
.Select(pc => pc.CursorForOrder(o.Subject, o)).FirstOrDefault(a => a != null))
|
.Select(pc => pc.CursorForOrder(o.Subject, o)).FirstOrDefault(a => a != null))
|
||||||
.FirstOrDefault(a => a != null);
|
.FirstOrDefault(a => a != null);
|
||||||
|
|
||||||
return c ??
|
return c ??
|
||||||
(world.FindUnitsAtMouse(mi.Location)
|
(world.FindUnitsAtMouse(mi.Location)
|
||||||
.Any(a => a.Info.Traits.Contains<SelectableInfo>())
|
.Any(a => a.Info.Traits.Contains<SelectableInfo>())
|
||||||
? "select" : "default");
|
? "select" : "default");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ namespace OpenRA.Traits
|
|||||||
|
|
||||||
public void RenderAfterWorld (Actor self)
|
public void RenderAfterWorld (Actor self)
|
||||||
{
|
{
|
||||||
var force = Game.controller.GetModifiers().HasModifier(Modifiers.Alt);
|
var force = Game.GetModifierKeys().HasModifier(Modifiers.Alt);
|
||||||
if ((lifetime <= 0 || --lifetime <= 0) && !force)
|
if ((lifetime <= 0 || --lifetime <= 0) && !force)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ namespace OpenRA.Traits
|
|||||||
|
|
||||||
public IEnumerable<Renderable> Render(Actor self)
|
public IEnumerable<Renderable> Render(Actor self)
|
||||||
{
|
{
|
||||||
if (self.Owner == self.World.LocalPlayer && Game.controller.selection.Actors.Contains(self))
|
if (self.Owner == self.World.LocalPlayer && self.World.Selection.Actors.Contains(self))
|
||||||
yield return Util.Centered(self,
|
yield return Util.Centered(self,
|
||||||
anim.Image, Util.CenterOfCell(rallyPoint));
|
anim.Image, Util.CenterOfCell(rallyPoint));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ namespace OpenRA.Traits
|
|||||||
|
|
||||||
void DrawControlGroup(Actor self, float2 basePosition)
|
void DrawControlGroup(Actor self, float2 basePosition)
|
||||||
{
|
{
|
||||||
var group = Game.controller.selection.GetControlGroupForActor(self);
|
var group = self.World.Selection.GetControlGroupForActor(self);
|
||||||
if (group == null) return;
|
if (group == null) return;
|
||||||
|
|
||||||
var pipImages = new Animation("pips");
|
var pipImages = new Animation("pips");
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ namespace OpenRA.Traits
|
|||||||
{
|
{
|
||||||
public void SelectionChanged()
|
public void SelectionChanged()
|
||||||
{
|
{
|
||||||
var firstItem = Game.controller.selection.Actors.FirstOrDefault(
|
var firstItem = Game.world.Selection.Actors.FirstOrDefault(
|
||||||
a => a.World.LocalPlayer == a.Owner && a.traits.Contains<Production>());
|
a => a.World.LocalPlayer == a.Owner && a.traits.Contains<Production>());
|
||||||
|
|
||||||
if (firstItem == null)
|
if (firstItem == null)
|
||||||
|
|||||||
@@ -348,7 +348,7 @@ namespace OpenRA.Widgets
|
|||||||
if (producing.Done)
|
if (producing.Done)
|
||||||
{
|
{
|
||||||
if (unit.Traits.Contains<BuildingInfo>())
|
if (unit.Traits.Contains<BuildingInfo>())
|
||||||
Game.controller.orderGenerator = new PlaceBuildingOrderGenerator(player.PlayerActor, item);
|
world.OrderGenerator = new PlaceBuildingOrderGenerator(player.PlayerActor, item);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,9 +9,12 @@
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRA.Orders;
|
using OpenRA.Orders;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
using OpenRA.FileFormats;
|
||||||
|
|
||||||
namespace OpenRA.Widgets
|
namespace OpenRA.Widgets
|
||||||
{
|
{
|
||||||
@@ -19,7 +22,26 @@ namespace OpenRA.Widgets
|
|||||||
{
|
{
|
||||||
public DefaultInputControllerWidget() : base() {}
|
public DefaultInputControllerWidget() : base() {}
|
||||||
protected DefaultInputControllerWidget(DefaultInputControllerWidget widget) : base(widget) {}
|
protected DefaultInputControllerWidget(DefaultInputControllerWidget widget) : base(widget) {}
|
||||||
public override void DrawInner( World world ) { }
|
|
||||||
|
public override void DrawInner( World world )
|
||||||
|
{
|
||||||
|
var selbox = SelectionBox;
|
||||||
|
if (selbox == null) return;
|
||||||
|
|
||||||
|
var a = selbox.Value.First;
|
||||||
|
var b = new float2(selbox.Value.Second.X - a.X, 0);
|
||||||
|
var c = new float2(0, selbox.Value.Second.Y - a.Y);
|
||||||
|
|
||||||
|
Game.Renderer.LineRenderer.DrawLine(a, a + b, Color.White, Color.White);
|
||||||
|
Game.Renderer.LineRenderer.DrawLine(a + b, a + b + c, Color.White, Color.White);
|
||||||
|
Game.Renderer.LineRenderer.DrawLine(a + b + c, a + c, Color.White, Color.White);
|
||||||
|
Game.Renderer.LineRenderer.DrawLine(a, a + c, Color.White, Color.White);
|
||||||
|
|
||||||
|
foreach (var u in world.SelectActorsInBox(selbox.Value.First, selbox.Value.Second))
|
||||||
|
world.WorldRenderer.DrawSelectionBox(u, Color.Yellow);
|
||||||
|
|
||||||
|
Game.Renderer.LineRenderer.Flush();
|
||||||
|
}
|
||||||
|
|
||||||
static internal bool scrollUp = false;
|
static internal bool scrollUp = false;
|
||||||
static internal bool scrollDown = false;
|
static internal bool scrollDown = false;
|
||||||
@@ -36,7 +58,7 @@ namespace OpenRA.Widgets
|
|||||||
if (mi.Button == MouseButton.Left && mi.Event == MouseInputEvent.Down)
|
if (mi.Button == MouseButton.Left && mi.Event == MouseInputEvent.Down)
|
||||||
{
|
{
|
||||||
dragStart = dragEnd = xy;
|
dragStart = dragEnd = xy;
|
||||||
Game.controller.ApplyOrders(world, xy, mi);
|
ApplyOrders(world, xy, mi);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mi.Button == MouseButton.Left && mi.Event == MouseInputEvent.Move)
|
if (mi.Button == MouseButton.Left && mi.Event == MouseInputEvent.Move)
|
||||||
@@ -44,10 +66,10 @@ namespace OpenRA.Widgets
|
|||||||
|
|
||||||
if (mi.Button == MouseButton.Left && mi.Event == MouseInputEvent.Up)
|
if (mi.Button == MouseButton.Left && mi.Event == MouseInputEvent.Up)
|
||||||
{
|
{
|
||||||
if (Game.controller.orderGenerator is UnitOrderGenerator)
|
if (world.OrderGenerator is UnitOrderGenerator)
|
||||||
{
|
{
|
||||||
var newSelection = Game.world.SelectActorsInBox(Game.CellSize * dragStart, Game.CellSize * xy);
|
var newSelection = Game.world.SelectActorsInBox(Game.CellSize * dragStart, Game.CellSize * xy);
|
||||||
Game.controller.selection.Combine(world, newSelection, mi.Modifiers.HasModifier(Modifiers.Shift), dragStart == xy);
|
world.Selection.Combine(world, newSelection, mi.Modifiers.HasModifier(Modifiers.Shift), dragStart == xy);
|
||||||
}
|
}
|
||||||
|
|
||||||
dragStart = dragEnd = xy;
|
dragStart = dragEnd = xy;
|
||||||
@@ -62,13 +84,42 @@ namespace OpenRA.Widgets
|
|||||||
dragStart = dragEnd = xy;
|
dragStart = dragEnd = xy;
|
||||||
|
|
||||||
if (mi.Button == MouseButton.Right && mi.Event == MouseInputEvent.Down)
|
if (mi.Button == MouseButton.Right && mi.Event == MouseInputEvent.Down)
|
||||||
Game.controller.ApplyOrders(world, xy, mi);
|
ApplyOrders(world, xy, mi);
|
||||||
|
|
||||||
Game.controller.dragStart = dragStart;
|
|
||||||
Game.controller.dragEnd = dragEnd;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Pair<float2, float2>? SelectionBox
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (dragStart == dragEnd) return null;
|
||||||
|
return Pair.New(Game.CellSize * dragStart, Game.CellSize * dragEnd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ApplyOrders(World world, float2 xy, MouseInput mi)
|
||||||
|
{
|
||||||
|
if (world.OrderGenerator == null) return;
|
||||||
|
|
||||||
|
var orders = world.OrderGenerator.Order(world, xy.ToInt2(), mi).ToArray();
|
||||||
|
Game.orderManager.IssueOrders( orders );
|
||||||
|
|
||||||
|
// Find an actor with a phrase to say
|
||||||
|
var done = false;
|
||||||
|
foreach (var o in orders)
|
||||||
|
{
|
||||||
|
foreach (var v in o.Subject.traits.WithInterface<IOrderVoice>())
|
||||||
|
{
|
||||||
|
if (Sound.PlayVoice(v.VoicePhraseForOrder(o.Subject, o), o.Subject))
|
||||||
|
{
|
||||||
|
done = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (done) break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public override string GetCursor(int2 pos)
|
public override string GetCursor(int2 pos)
|
||||||
{
|
{
|
||||||
var world = Game.world;
|
var world = Game.world;
|
||||||
@@ -85,7 +136,7 @@ namespace OpenRA.Widgets
|
|||||||
Modifiers = Game.GetModifierKeys()
|
Modifiers = Game.GetModifierKeys()
|
||||||
};
|
};
|
||||||
|
|
||||||
return Game.controller.orderGenerator.GetCursor( world, Game.viewport.ViewToWorld(mi).ToInt2(), mi );
|
return Game.world.OrderGenerator.GetCursor( world, Game.viewport.ViewToWorld(mi).ToInt2(), mi );
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
@@ -117,7 +168,7 @@ namespace OpenRA.Widgets
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (e.KeyName.Length == 1 && char.IsDigit(e.KeyName[0]))
|
if (e.KeyName.Length == 1 && char.IsDigit(e.KeyName[0]))
|
||||||
Game.controller.selection.DoControlGroup(Game.world, e.KeyName[0] - '0', e.Modifiers);
|
Game.world.Selection.DoControlGroup(Game.world, e.KeyName[0] - '0', e.Modifiers);
|
||||||
|
|
||||||
if (e.KeyChar == 08)
|
if (e.KeyChar == 08)
|
||||||
GotoNextBase();
|
GotoNextBase();
|
||||||
@@ -151,20 +202,21 @@ namespace OpenRA.Widgets
|
|||||||
|
|
||||||
public void GotoNextBase()
|
public void GotoNextBase()
|
||||||
{
|
{
|
||||||
var bases = Game.world.Queries.OwnedBy[Game.world.LocalPlayer].WithTrait<BaseBuilding>().ToArray();
|
var world = Game.world;
|
||||||
|
var bases = world.Queries.OwnedBy[world.LocalPlayer].WithTrait<BaseBuilding>().ToArray();
|
||||||
if (!bases.Any()) return;
|
if (!bases.Any()) return;
|
||||||
|
|
||||||
var next = bases
|
var next = bases
|
||||||
.Select( b => b.Actor )
|
.Select( b => b.Actor )
|
||||||
.SkipWhile(b => Game.controller.selection.Actors.Contains(b))
|
.SkipWhile(b => world.Selection.Actors.Contains(b))
|
||||||
.Skip(1)
|
.Skip(1)
|
||||||
.FirstOrDefault();
|
.FirstOrDefault();
|
||||||
|
|
||||||
if (next == null)
|
if (next == null)
|
||||||
next = bases.Select(b => b.Actor).First();
|
next = bases.Select(b => b.Actor).First();
|
||||||
|
|
||||||
Game.controller.selection.Combine(Game.world, new Actor[] { next }, false, true);
|
world.Selection.Combine(world, new Actor[] { next }, false, true);
|
||||||
Game.viewport.Center(Game.controller.selection.Actors);
|
Game.viewport.Center(world.Selection.Actors);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Widget Clone() { return new DefaultInputControllerWidget(this); }
|
public override Widget Clone() { return new DefaultInputControllerWidget(this); }
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ namespace OpenRA.Widgets
|
|||||||
Modifiers = Game.GetModifierKeys()
|
Modifiers = Game.GetModifierKeys()
|
||||||
};
|
};
|
||||||
|
|
||||||
var cursor = Game.controller.orderGenerator.GetCursor( world, loc, mi );
|
var cursor = Game.world.OrderGenerator.GetCursor( world, loc, mi );
|
||||||
if (cursor == null)
|
if (cursor == null)
|
||||||
return "default";
|
return "default";
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ using OpenRA.Collections;
|
|||||||
using OpenRA.Effects;
|
using OpenRA.Effects;
|
||||||
using OpenRA.FileFormats;
|
using OpenRA.FileFormats;
|
||||||
using OpenRA.Graphics;
|
using OpenRA.Graphics;
|
||||||
|
using OpenRA.Orders;
|
||||||
using OpenRA.Support;
|
using OpenRA.Support;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
|
||||||
@@ -56,6 +57,25 @@ namespace OpenRA
|
|||||||
|
|
||||||
public readonly WorldRenderer WorldRenderer;
|
public readonly WorldRenderer WorldRenderer;
|
||||||
|
|
||||||
|
public IOrderGenerator OrderGenerator = new UnitOrderGenerator();
|
||||||
|
public Selection Selection = new Selection();
|
||||||
|
|
||||||
|
public void CancelInputMode() { OrderGenerator = new UnitOrderGenerator(); }
|
||||||
|
|
||||||
|
public bool ToggleInputMode<T>() where T : IOrderGenerator, new()
|
||||||
|
{
|
||||||
|
if (OrderGenerator is T)
|
||||||
|
{
|
||||||
|
CancelInputMode();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
OrderGenerator = new T();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public World(Manifest manifest, Map map)
|
public World(Manifest manifest, Map map)
|
||||||
{
|
{
|
||||||
Timer.Time( "----World.ctor" );
|
Timer.Time( "----World.ctor" );
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ namespace OpenRA.Mods.Cnc
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (Owner == Owner.World.LocalPlayer)
|
if (Owner == Owner.World.LocalPlayer)
|
||||||
Game.controller.CancelInputMode();
|
self.World.CancelInputMode();
|
||||||
|
|
||||||
FinishActivate();
|
FinishActivate();
|
||||||
}
|
}
|
||||||
@@ -42,7 +42,7 @@ namespace OpenRA.Mods.Cnc
|
|||||||
|
|
||||||
protected override void OnActivate()
|
protected override void OnActivate()
|
||||||
{
|
{
|
||||||
Game.controller.orderGenerator =
|
Game.world.OrderGenerator =
|
||||||
new GenericSelectTargetWithBuilding<IonControl>(Owner.PlayerActor, "IonCannon", "ability");
|
new GenericSelectTargetWithBuilding<IonControl>(Owner.PlayerActor, "IonCannon", "ability");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
|
|
||||||
self.World.AddFrameEndTask(w =>
|
self.World.AddFrameEndTask(w =>
|
||||||
{
|
{
|
||||||
var selected = Game.controller.selection.Contains(self);
|
var selected = w.Selection.Contains(self);
|
||||||
|
|
||||||
self.World.Remove(self);
|
self.World.Remove(self);
|
||||||
foreach (var s in sounds)
|
foreach (var s in sounds)
|
||||||
@@ -50,7 +50,7 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
a.Health = GetHealthToTransfer(self, a, transferPercentage);
|
a.Health = GetHealthToTransfer(self, a, transferPercentage);
|
||||||
|
|
||||||
if (selected)
|
if (selected)
|
||||||
Game.controller.selection.Add(w, a);
|
w.Selection.Add(w, a);
|
||||||
});
|
});
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
|
|
||||||
void DoUndeploy(World w, Actor self)
|
void DoUndeploy(World w, Actor self)
|
||||||
{
|
{
|
||||||
var selected = Game.controller.selection.Contains(self);
|
var selected = w.Selection.Contains(self);
|
||||||
w.Remove(self);
|
w.Remove(self);
|
||||||
|
|
||||||
var mcv = w.CreateActor("mcv", self.Location + new int2(1, 1), self.Owner);
|
var mcv = w.CreateActor("mcv", self.Location + new int2(1, 1), self.Owner);
|
||||||
@@ -28,7 +28,7 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
mcv.traits.Get<Unit>().Facing = 96;
|
mcv.traits.Get<Unit>().Facing = 96;
|
||||||
|
|
||||||
if (selected)
|
if (selected)
|
||||||
Game.controller.selection.Add(w, mcv);
|
w.Selection.Add(w, mcv);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IActivity Tick(Actor self)
|
public IActivity Tick(Actor self)
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ namespace OpenRA.Mods.RA
|
|||||||
if (order.OrderString == "ChronoshiftDeploy")
|
if (order.OrderString == "ChronoshiftDeploy")
|
||||||
{
|
{
|
||||||
if (self.Owner == self.World.LocalPlayer)
|
if (self.Owner == self.World.LocalPlayer)
|
||||||
Game.controller.orderGenerator = new SetChronoTankDestination(self);
|
self.World.OrderGenerator = new SetChronoTankDestination(self);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,7 +55,7 @@ namespace OpenRA.Mods.RA
|
|||||||
{
|
{
|
||||||
if (self.Owner == self.World.LocalPlayer)
|
if (self.Owner == self.World.LocalPlayer)
|
||||||
{
|
{
|
||||||
Game.controller.CancelInputMode();
|
self.World.CancelInputMode();
|
||||||
self.World.AddFrameEndTask(w => w.Add(new MoveFlash(self.World, order.TargetLocation)));
|
self.World.AddFrameEndTask(w => w.Add(new MoveFlash(self.World, order.TargetLocation)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -51,13 +51,13 @@ namespace OpenRA.Mods.RA
|
|||||||
{
|
{
|
||||||
minefieldStart = order.TargetLocation;
|
minefieldStart = order.TargetLocation;
|
||||||
if (self.Owner == self.World.LocalPlayer)
|
if (self.Owner == self.World.LocalPlayer)
|
||||||
Game.controller.orderGenerator = new MinefieldOrderGenerator(self);
|
self.World.OrderGenerator = new MinefieldOrderGenerator(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (order.OrderString == "PlaceMinefield")
|
if (order.OrderString == "PlaceMinefield")
|
||||||
{
|
{
|
||||||
if (self.Owner == self.World.LocalPlayer)
|
if (self.Owner == self.World.LocalPlayer)
|
||||||
Game.controller.CancelInputMode();
|
self.World.CancelInputMode();
|
||||||
|
|
||||||
var movement = self.traits.Get<IMove>();
|
var movement = self.traits.Get<IMove>();
|
||||||
|
|
||||||
@@ -100,7 +100,7 @@ namespace OpenRA.Mods.RA
|
|||||||
{
|
{
|
||||||
if (mi.Button == MouseButton.Left)
|
if (mi.Button == MouseButton.Left)
|
||||||
{
|
{
|
||||||
Game.controller.CancelInputMode();
|
world.CancelInputMode();
|
||||||
yield break;
|
yield break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,7 +116,7 @@ namespace OpenRA.Mods.RA
|
|||||||
public void Tick(World world)
|
public void Tick(World world)
|
||||||
{
|
{
|
||||||
if (minelayer.IsDead || !minelayer.IsInWorld)
|
if (minelayer.IsDead || !minelayer.IsInWorld)
|
||||||
Game.controller.CancelInputMode();
|
world.CancelInputMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
int2 lastMousePos;
|
int2 lastMousePos;
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ namespace OpenRA.Mods.RA.Orders
|
|||||||
public IEnumerable<Order> Order(World world, int2 xy, MouseInput mi)
|
public IEnumerable<Order> Order(World world, int2 xy, MouseInput mi)
|
||||||
{
|
{
|
||||||
if (mi.Button == MouseButton.Right)
|
if (mi.Button == MouseButton.Right)
|
||||||
Game.controller.CancelInputMode();
|
world.CancelInputMode();
|
||||||
|
|
||||||
return OrderInner(world, xy, mi);
|
return OrderInner(world, xy, mi);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ namespace OpenRA.Mods.RA.Orders
|
|||||||
public IEnumerable<Order> Order(World world, int2 xy, MouseInput mi)
|
public IEnumerable<Order> Order(World world, int2 xy, MouseInput mi)
|
||||||
{
|
{
|
||||||
if (mi.Button == MouseButton.Right)
|
if (mi.Button == MouseButton.Right)
|
||||||
Game.controller.CancelInputMode();
|
world.CancelInputMode();
|
||||||
|
|
||||||
return OrderInner(world, xy, mi);
|
return OrderInner(world, xy, mi);
|
||||||
}
|
}
|
||||||
@@ -43,7 +43,7 @@ namespace OpenRA.Mods.RA.Orders
|
|||||||
public void Tick( World world )
|
public void Tick( World world )
|
||||||
{
|
{
|
||||||
if( !PlayerIsAllowedToRepair( world ) )
|
if( !PlayerIsAllowedToRepair( world ) )
|
||||||
Game.controller.CancelInputMode();
|
world.CancelInputMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool PlayerIsAllowedToRepair( World world )
|
public static bool PlayerIsAllowedToRepair( World world )
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ namespace OpenRA.Mods.RA.Orders
|
|||||||
public IEnumerable<Order> Order(World world, int2 xy, MouseInput mi)
|
public IEnumerable<Order> Order(World world, int2 xy, MouseInput mi)
|
||||||
{
|
{
|
||||||
if (mi.Button == MouseButton.Right)
|
if (mi.Button == MouseButton.Right)
|
||||||
Game.controller.CancelInputMode();
|
world.CancelInputMode();
|
||||||
|
|
||||||
return OrderInner(world, xy, mi);
|
return OrderInner(world, xy, mi);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ namespace OpenRA.Mods.RA.Orders
|
|||||||
{
|
{
|
||||||
if (mi.Button == MouseButton.Left)
|
if (mi.Button == MouseButton.Left)
|
||||||
{
|
{
|
||||||
Game.controller.CancelInputMode();
|
world.CancelInputMode();
|
||||||
yield break;
|
yield break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
protected override void OnActivate()
|
protected override void OnActivate()
|
||||||
{
|
{
|
||||||
Game.controller.orderGenerator = new GenericSelectTarget(Owner.PlayerActor, Info.OrderName, "ability");
|
Game.world.OrderGenerator = new GenericSelectTarget(Owner.PlayerActor, Info.OrderName, "ability");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ResolveOrder(Actor self, Order order)
|
public void ResolveOrder(Actor self, Order order)
|
||||||
@@ -63,7 +63,7 @@ namespace OpenRA.Mods.RA
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (Owner == Owner.World.LocalPlayer)
|
if (Owner == Owner.World.LocalPlayer)
|
||||||
Game.controller.CancelInputMode();
|
self.World.CancelInputMode();
|
||||||
|
|
||||||
FinishActivate();
|
FinishActivate();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ namespace OpenRA.Mods.RA
|
|||||||
class ChronoshiftPower : SupportPower, IResolveOrder
|
class ChronoshiftPower : SupportPower, IResolveOrder
|
||||||
{
|
{
|
||||||
public ChronoshiftPower(Actor self, ChronoshiftPowerInfo info) : base(self, info) { }
|
public ChronoshiftPower(Actor self, ChronoshiftPowerInfo info) : base(self, info) { }
|
||||||
protected override void OnActivate() { Game.controller.orderGenerator = new SelectTarget(); }
|
protected override void OnActivate() { Game.world.OrderGenerator = new SelectTarget(); }
|
||||||
|
|
||||||
public void ResolveOrder(Actor self, Order order)
|
public void ResolveOrder(Actor self, Order order)
|
||||||
{
|
{
|
||||||
@@ -32,13 +32,13 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
if (order.OrderString == "ChronosphereSelect" && self.Owner == self.World.LocalPlayer)
|
if (order.OrderString == "ChronosphereSelect" && self.Owner == self.World.LocalPlayer)
|
||||||
{
|
{
|
||||||
Game.controller.orderGenerator = new SelectDestination(order.TargetActor);
|
self.World.OrderGenerator = new SelectDestination(order.TargetActor);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (order.OrderString == "ChronosphereActivate")
|
if (order.OrderString == "ChronosphereActivate")
|
||||||
{
|
{
|
||||||
if (self.Owner == self.World.LocalPlayer)
|
if (self.Owner == self.World.LocalPlayer)
|
||||||
Game.controller.CancelInputMode();
|
self.World.CancelInputMode();
|
||||||
|
|
||||||
// Ensure the target cell is valid for the unit
|
// Ensure the target cell is valid for the unit
|
||||||
var movement = order.TargetActor.traits.GetOrDefault<IMove>();
|
var movement = order.TargetActor.traits.GetOrDefault<IMove>();
|
||||||
@@ -61,7 +61,7 @@ namespace OpenRA.Mods.RA
|
|||||||
public IEnumerable<Order> Order(World world, int2 xy, MouseInput mi)
|
public IEnumerable<Order> Order(World world, int2 xy, MouseInput mi)
|
||||||
{
|
{
|
||||||
if (mi.Button == MouseButton.Right)
|
if (mi.Button == MouseButton.Right)
|
||||||
Game.controller.CancelInputMode();
|
world.CancelInputMode();
|
||||||
|
|
||||||
return OrderInner(world, xy, mi);
|
return OrderInner(world, xy, mi);
|
||||||
}
|
}
|
||||||
@@ -88,7 +88,7 @@ namespace OpenRA.Mods.RA
|
|||||||
.Any();
|
.Any();
|
||||||
|
|
||||||
if (!hasChronosphere)
|
if (!hasChronosphere)
|
||||||
Game.controller.CancelInputMode();
|
world.CancelInputMode();
|
||||||
|
|
||||||
// TODO: Check if the selected unit is still alive
|
// TODO: Check if the selected unit is still alive
|
||||||
}
|
}
|
||||||
@@ -113,7 +113,7 @@ namespace OpenRA.Mods.RA
|
|||||||
{
|
{
|
||||||
if (mi.Button == MouseButton.Right)
|
if (mi.Button == MouseButton.Right)
|
||||||
{
|
{
|
||||||
Game.controller.CancelInputMode();
|
world.CancelInputMode();
|
||||||
yield break;
|
yield break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,7 +129,7 @@ namespace OpenRA.Mods.RA
|
|||||||
.Any();
|
.Any();
|
||||||
|
|
||||||
if (!hasChronosphere)
|
if (!hasChronosphere)
|
||||||
Game.controller.CancelInputMode();
|
world.CancelInputMode();
|
||||||
|
|
||||||
// TODO: Check if the selected unit is still alive
|
// TODO: Check if the selected unit is still alive
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ namespace OpenRA.Mods.RA
|
|||||||
protected override void OnFinishCharging() { Sound.PlayToPlayer(Owner, "ironrdy1.aud"); }
|
protected override void OnFinishCharging() { Sound.PlayToPlayer(Owner, "ironrdy1.aud"); }
|
||||||
protected override void OnActivate()
|
protected override void OnActivate()
|
||||||
{
|
{
|
||||||
Game.controller.orderGenerator = new SelectTarget();
|
Game.world.OrderGenerator = new SelectTarget();
|
||||||
Sound.Play("slcttgt1.aud");
|
Sound.Play("slcttgt1.aud");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -40,7 +40,7 @@ namespace OpenRA.Mods.RA
|
|||||||
if (order.OrderString == "IronCurtain")
|
if (order.OrderString == "IronCurtain")
|
||||||
{
|
{
|
||||||
if (self.Owner == self.World.LocalPlayer)
|
if (self.Owner == self.World.LocalPlayer)
|
||||||
Game.controller.CancelInputMode();
|
self.World.CancelInputMode();
|
||||||
|
|
||||||
var curtain = self.World.Queries.WithTrait<IronCurtain>()
|
var curtain = self.World.Queries.WithTrait<IronCurtain>()
|
||||||
.Where(a => a.Actor.Owner != null)
|
.Where(a => a.Actor.Owner != null)
|
||||||
@@ -64,7 +64,7 @@ namespace OpenRA.Mods.RA
|
|||||||
public IEnumerable<Order> Order(World world, int2 xy, MouseInput mi)
|
public IEnumerable<Order> Order(World world, int2 xy, MouseInput mi)
|
||||||
{
|
{
|
||||||
if (mi.Button == MouseButton.Right)
|
if (mi.Button == MouseButton.Right)
|
||||||
Game.controller.CancelInputMode();
|
world.CancelInputMode();
|
||||||
|
|
||||||
return OrderInner(world, xy, mi);
|
return OrderInner(world, xy, mi);
|
||||||
}
|
}
|
||||||
@@ -92,7 +92,7 @@ namespace OpenRA.Mods.RA
|
|||||||
.Any();
|
.Any();
|
||||||
|
|
||||||
if (!hasStructure)
|
if (!hasStructure)
|
||||||
Game.controller.CancelInputMode();
|
world.CancelInputMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RenderAfterWorld(World world) { }
|
public void RenderAfterWorld(World world) { }
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
protected override void OnActivate()
|
protected override void OnActivate()
|
||||||
{
|
{
|
||||||
Game.controller.orderGenerator =
|
Game.world.OrderGenerator =
|
||||||
new GenericSelectTargetWithBuilding<NukeSilo>(Owner.PlayerActor, "NuclearMissile", "nuke");
|
new GenericSelectTargetWithBuilding<NukeSilo>(Owner.PlayerActor, "NuclearMissile", "nuke");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,7 +49,7 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
silo.traits.Get<NukeSilo>().Attack(order.TargetLocation);
|
silo.traits.Get<NukeSilo>().Attack(order.TargetLocation);
|
||||||
|
|
||||||
Game.controller.CancelInputMode();
|
self.World.CancelInputMode();
|
||||||
FinishActivate();
|
FinishActivate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
protected override void OnActivate()
|
protected override void OnActivate()
|
||||||
{
|
{
|
||||||
Game.controller.orderGenerator =
|
Game.world.OrderGenerator =
|
||||||
new GenericSelectTarget( Owner.PlayerActor, "ParatroopersActivate", "ability" );
|
new GenericSelectTarget( Owner.PlayerActor, "ParatroopersActivate", "ability" );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,7 +43,7 @@ namespace OpenRA.Mods.RA
|
|||||||
if (order.OrderString == "ParatroopersActivate")
|
if (order.OrderString == "ParatroopersActivate")
|
||||||
{
|
{
|
||||||
if (self.Owner == self.World.LocalPlayer)
|
if (self.Owner == self.World.LocalPlayer)
|
||||||
Game.controller.CancelInputMode();
|
self.World.CancelInputMode();
|
||||||
|
|
||||||
DoParadrop(Owner, order.TargetLocation,
|
DoParadrop(Owner, order.TargetLocation,
|
||||||
self.Info.Traits.Get<ParatroopersPowerInfo>().DropItems);
|
self.Info.Traits.Get<ParatroopersPowerInfo>().DropItems);
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ namespace OpenRA.Mods.RA
|
|||||||
protected override void OnFinishCharging() { Sound.PlayToPlayer(Owner, "spypln1.aud"); }
|
protected override void OnFinishCharging() { Sound.PlayToPlayer(Owner, "spypln1.aud"); }
|
||||||
protected override void OnActivate()
|
protected override void OnActivate()
|
||||||
{
|
{
|
||||||
Game.controller.orderGenerator = new GenericSelectTarget(Owner.PlayerActor, "SpyPlane", "ability");
|
Game.world.OrderGenerator = new GenericSelectTarget(Owner.PlayerActor, "SpyPlane", "ability");
|
||||||
Sound.Play("slcttgt1.aud");
|
Sound.Play("slcttgt1.aud");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,7 +41,7 @@ namespace OpenRA.Mods.RA
|
|||||||
FinishActivate();
|
FinishActivate();
|
||||||
|
|
||||||
if (order.Player == Owner.World.LocalPlayer)
|
if (order.Player == Owner.World.LocalPlayer)
|
||||||
Game.controller.CancelInputMode();
|
self.World.CancelInputMode();
|
||||||
|
|
||||||
var enterCell = self.World.ChooseRandomEdgeCell();
|
var enterCell = self.World.ChooseRandomEdgeCell();
|
||||||
|
|
||||||
|
|||||||
@@ -26,23 +26,23 @@ namespace OpenRA.Mods.RA.Widgets.Delegates
|
|||||||
var sell = moneybin.GetWidget<OrderButtonWidget>("SELL");
|
var sell = moneybin.GetWidget<OrderButtonWidget>("SELL");
|
||||||
if (sell != null)
|
if (sell != null)
|
||||||
{
|
{
|
||||||
sell.Pressed = () => Game.controller.orderGenerator is SellOrderGenerator;
|
sell.Pressed = () => Game.world.OrderGenerator is SellOrderGenerator;
|
||||||
sell.OnMouseDown = mi => { Game.controller.ToggleInputMode<SellOrderGenerator>(); return true; };
|
sell.OnMouseDown = mi => { Game.world.ToggleInputMode<SellOrderGenerator>(); return true; };
|
||||||
}
|
}
|
||||||
|
|
||||||
var powerdown = moneybin.GetWidget<OrderButtonWidget>("POWER_DOWN");
|
var powerdown = moneybin.GetWidget<OrderButtonWidget>("POWER_DOWN");
|
||||||
if (powerdown != null)
|
if (powerdown != null)
|
||||||
{
|
{
|
||||||
powerdown.Pressed = () => Game.controller.orderGenerator is PowerDownOrderGenerator;
|
powerdown.Pressed = () => Game.world.OrderGenerator is PowerDownOrderGenerator;
|
||||||
powerdown.OnMouseDown = mi => { Game.controller.ToggleInputMode<PowerDownOrderGenerator>(); return true; };
|
powerdown.OnMouseDown = mi => { Game.world.ToggleInputMode<PowerDownOrderGenerator>(); return true; };
|
||||||
}
|
}
|
||||||
|
|
||||||
var repair = moneybin.GetWidget<OrderButtonWidget>("REPAIR");
|
var repair = moneybin.GetWidget<OrderButtonWidget>("REPAIR");
|
||||||
if (repair != null)
|
if (repair != null)
|
||||||
{
|
{
|
||||||
repair.Enabled = () => { return RepairOrderGenerator.PlayerIsAllowedToRepair( Game.world ); };
|
repair.Enabled = () => { return RepairOrderGenerator.PlayerIsAllowedToRepair( Game.world ); };
|
||||||
repair.Pressed = () => Game.controller.orderGenerator is RepairOrderGenerator;
|
repair.Pressed = () => Game.world.OrderGenerator is RepairOrderGenerator;
|
||||||
repair.OnMouseDown = mi => { Game.controller.ToggleInputMode<RepairOrderGenerator>(); return true; };
|
repair.OnMouseDown = mi => { Game.world.ToggleInputMode<RepairOrderGenerator>(); return true; };
|
||||||
repair.GetLongDesc = () => { return repair.Enabled() ? repair.LongDesc : repair.LongDesc + "\n\nRequires: Construction Yard"; };
|
repair.GetLongDesc = () => { return repair.Enabled() ? repair.LongDesc : repair.LongDesc + "\n\nRequires: Construction Yard"; };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user