diff --git a/OpenRA.Editor/MapSelect.cs b/OpenRA.Editor/MapSelect.cs
index c6dfef0517..68d1514497 100644
--- a/OpenRA.Editor/MapSelect.cs
+++ b/OpenRA.Editor/MapSelect.cs
@@ -79,7 +79,7 @@ namespace OpenRA.Editor
}
catch (Exception ed)
{
- Console.WriteLine("No map preview image found: {0}", ed.ToString());
+ Console.WriteLine("No map preview image found: {0}", ed);
}
}
}
diff --git a/OpenRA.FileFormats/FieldLoader.cs b/OpenRA.FileFormats/FieldLoader.cs
index 0dc062df43..d0039bde8c 100755
--- a/OpenRA.FileFormats/FieldLoader.cs
+++ b/OpenRA.FileFormats/FieldLoader.cs
@@ -314,7 +314,7 @@ namespace OpenRA.FileFormats
return null;
}
- static object ParseYesNo(string p, System.Type fieldType, string field)
+ static object ParseYesNo(string p, Type fieldType, string field)
{
p = p.ToLowerInvariant();
if (p == "yes") return true;
diff --git a/OpenRA.FileFormats/FieldSaver.cs b/OpenRA.FileFormats/FieldSaver.cs
index 65208da2b5..2cbe8415bf 100644
--- a/OpenRA.FileFormats/FieldSaver.cs
+++ b/OpenRA.FileFormats/FieldSaver.cs
@@ -48,7 +48,7 @@ namespace OpenRA.FileFormats
public static MiniYamlNode SaveField(object o, string field)
{
- return new MiniYamlNode(field, FieldSaver.FormatValue(o, o.GetType().GetField(field)));
+ return new MiniYamlNode(field, FormatValue(o, o.GetType().GetField(field)));
}
public static string FormatValue(object v, Type t)
diff --git a/OpenRA.FileFormats/FileFormats/CRC32.cs b/OpenRA.FileFormats/FileFormats/CRC32.cs
index 61de944e55..93de0e5827 100644
--- a/OpenRA.FileFormats/FileFormats/CRC32.cs
+++ b/OpenRA.FileFormats/FileFormats/CRC32.cs
@@ -92,7 +92,7 @@ namespace OpenRA.FileFormats
/// A fast (native) CRC32 implementation that can be used on a regular byte arrays.
///
/// The data from which to calculate the checksum.
- /// The polynomal.
+ /// The polynomal.
///
/// The calculated checksum.
///
@@ -115,7 +115,7 @@ namespace OpenRA.FileFormats
///
/// [in,out] If non-null, the.
/// The length of the data data.
- /// The polynomal to xor with.
+ /// The polynomal to xor with.
/// The calculated checksum.
public static unsafe uint Calculate(byte* data, uint len, uint polynomial)
{
diff --git a/OpenRA.FileFormats/FileFormats/IniFile.cs b/OpenRA.FileFormats/FileFormats/IniFile.cs
index 2ab2238b3d..3ead81baa5 100644
--- a/OpenRA.FileFormats/FileFormats/IniFile.cs
+++ b/OpenRA.FileFormats/FileFormats/IniFile.cs
@@ -56,7 +56,7 @@ namespace OpenRA.FileFormats
IniSection ProcessSection(string line)
{
Match m = sectionPattern.Match(line);
- if (m == null || !m.Success)
+ if (!m.Success)
return null;
string sectionName = m.Groups[1].Value.ToLowerInvariant();
diff --git a/OpenRA.FileFormats/FileSystem/FileSystem.cs b/OpenRA.FileFormats/FileSystem/FileSystem.cs
index 6046908e67..84f3f4c654 100644
--- a/OpenRA.FileFormats/FileSystem/FileSystem.cs
+++ b/OpenRA.FileFormats/FileSystem/FileSystem.cs
@@ -97,7 +97,7 @@ namespace OpenRA.FileFormats
name = Platform.SupportDir + name.Substring(1);
FolderPaths.Add(name);
- Action a = () => FileSystem.MountInner(OpenPackage(name, annotation, order++));
+ Action a = () => MountInner(OpenPackage(name, annotation, order++));
if (optional)
try { a(); }
@@ -197,8 +197,8 @@ namespace OpenRA.FileFormats
if (assemblyCache.TryGetValue(filename, out a))
return a;
- if (FileSystem.Exists(filename))
- using (var s = FileSystem.Open(filename))
+ if (Exists(filename))
+ using (var s = Open(filename))
{
var buf = new byte[s.Length];
s.Read(buf, 0, buf.Length);
diff --git a/OpenRA.FileFormats/Primitives/ObservableCollection.cs b/OpenRA.FileFormats/Primitives/ObservableCollection.cs
index 810623d232..d03945fb28 100644
--- a/OpenRA.FileFormats/Primitives/ObservableCollection.cs
+++ b/OpenRA.FileFormats/Primitives/ObservableCollection.cs
@@ -53,7 +53,7 @@ namespace OpenRA.FileFormats.Primitives
public IEnumerable ObservedItems
{
- get { return base.Items; }
+ get { return Items; }
}
}
}
diff --git a/OpenRA.Game/Game.cs b/OpenRA.Game/Game.cs
index 054dda2dd0..025d1414df 100644
--- a/OpenRA.Game/Game.cs
+++ b/OpenRA.Game/Game.cs
@@ -103,7 +103,7 @@ namespace OpenRA
// Load a widget with world, orderManager, worldRenderer args, without adding it to the widget tree
public static Widget LoadWidget(World world, string id, Widget parent, WidgetArgs args)
{
- return Game.modData.WidgetLoader.LoadWidget(new WidgetArgs(args)
+ return modData.WidgetLoader.LoadWidget(new WidgetArgs(args)
{
{ "world", world },
{ "orderManager", orderManager },
@@ -135,23 +135,23 @@ namespace OpenRA
// worldRenderer is null during the initial install/download screen
if (worldRenderer != null)
{
- Game.Renderer.BeginFrame(worldRenderer.Viewport.TopLeft.ToFloat2(), worldRenderer.Viewport.Zoom);
+ Renderer.BeginFrame(worldRenderer.Viewport.TopLeft.ToFloat2(), worldRenderer.Viewport.Zoom);
Sound.SetListenerPosition(worldRenderer.Position(worldRenderer.Viewport.CenterLocation));
worldRenderer.Draw();
}
else
- Game.Renderer.BeginFrame(float2.Zero, 1f);
+ Renderer.BeginFrame(float2.Zero, 1f);
using (new PerfSample("render_widgets"))
{
Ui.Draw();
var cursorName = Ui.Root.GetCursorOuter(Viewport.LastMousePos) ?? "default";
- CursorProvider.DrawCursor(Game.Renderer, cursorName, Viewport.LastMousePos, (int)cursorFrame);
+ CursorProvider.DrawCursor(Renderer, cursorName, Viewport.LastMousePos, (int)cursorFrame);
}
using (new PerfSample("render_flip"))
{
- Game.Renderer.EndFrame(new DefaultInputHandler(orderManager.world));
+ Renderer.EndFrame(new DefaultInputHandler(orderManager.world));
}
}
@@ -374,13 +374,13 @@ namespace OpenRA
JoinLocal();
- if (Game.Settings.Server.Dedicated)
+ if (Settings.Server.Dedicated)
{
while (true)
{
- Game.Settings.Server.Map = WidgetUtils.ChooseInitialMap(Game.Settings.Server.Map);
- Game.Settings.Save();
- Game.CreateServer(new ServerSettings(Game.Settings.Server));
+ Settings.Server.Map = WidgetUtils.ChooseInitialMap(Settings.Server.Map);
+ Settings.Save();
+ CreateServer(new ServerSettings(Settings.Server));
while (true)
{
System.Threading.Thread.Sleep(100);
@@ -393,15 +393,14 @@ namespace OpenRA
break;
}
}
- if (Game.Settings.Server.DedicatedLoop)
+ if (Settings.Server.DedicatedLoop)
{
Console.WriteLine("Starting a new server instance...");
continue;
}
- else
- break;
+ break;
}
- System.Environment.Exit(0);
+ Environment.Exit(0);
}
else
{
@@ -420,7 +419,7 @@ namespace OpenRA
var shellmaps = modData.AvailableMaps
.Where(m => m.Value.UseAsShellmap);
- if (shellmaps.Count() == 0)
+ if (!shellmaps.Any())
throw new InvalidDataException("No valid shellmaps available");
return shellmaps.Random(CosmeticRandom).Key;
@@ -482,7 +481,7 @@ namespace OpenRA
public static void CreateServer(ServerSettings settings)
{
server = new Server.Server(new IPEndPoint(IPAddress.Any, settings.ListenPort),
- Game.Settings.Game.Mods, settings, modData);
+ Settings.Game.Mods, settings, modData);
}
public static int CreateLocalServer(string map)
@@ -496,7 +495,7 @@ namespace OpenRA
};
server = new Server.Server(new IPEndPoint(IPAddress.Loopback, 0),
- Game.Settings.Game.Mods, settings, modData);
+ Settings.Game.Mods, settings, modData);
return server.Port;
}
@@ -510,7 +509,7 @@ namespace OpenRA
{
try
{
- var mod = Game.CurrentMods.FirstOrDefault().Value.Id;
+ var mod = CurrentMods.First().Value.Id;
var dirPath = "{1}maps{0}{2}".F(Path.DirectorySeparatorChar, Platform.SupportDir, mod);
if(!Directory.Exists(dirPath))
Directory.CreateDirectory(dirPath);
diff --git a/OpenRA.Game/Graphics/SheetBuilder.cs b/OpenRA.Game/Graphics/SheetBuilder.cs
index 75183a8e9a..a2ba52d535 100644
--- a/OpenRA.Game/Graphics/SheetBuilder.cs
+++ b/OpenRA.Game/Graphics/SheetBuilder.cs
@@ -38,7 +38,7 @@ namespace OpenRA.Graphics
public static Sheet AllocateSheet()
{
- return new Sheet(new Size(Renderer.SheetSize, Renderer.SheetSize));;
+ return new Sheet(new Size(Renderer.SheetSize, Renderer.SheetSize));
}
internal SheetBuilder(SheetType t)
diff --git a/OpenRA.Game/Graphics/Util.cs b/OpenRA.Game/Graphics/Util.cs
index c859121b9d..a997d1b6fa 100644
--- a/OpenRA.Game/Graphics/Util.cs
+++ b/OpenRA.Game/Graphics/Util.cs
@@ -258,7 +258,7 @@ namespace OpenRA.Graphics
for (var i = 0; i < 8; i++)
{
var vec = new float[] {bounds[ix[i]], bounds[iy[i]], bounds[iz[i]], 1};
- var tvec = Util.MatrixVectorMultiply(mtx, vec);
+ var tvec = MatrixVectorMultiply(mtx, vec);
ret[0] = Math.Min(ret[0], tvec[0]/tvec[3]);
ret[1] = Math.Min(ret[1], tvec[1]/tvec[3]);
diff --git a/OpenRA.Game/ModData.cs b/OpenRA.Game/ModData.cs
index 2e5a0b47f8..422914251e 100755
--- a/OpenRA.Game/ModData.cs
+++ b/OpenRA.Game/ModData.cs
@@ -162,7 +162,7 @@ namespace OpenRA
catch (Exception e)
{
Console.WriteLine("Failed to load map: {0}", path);
- Console.WriteLine("Details: {0}", e.ToString());
+ Console.WriteLine("Details: {0}", e);
}
}
diff --git a/OpenRA.Game/Network/Session.cs b/OpenRA.Game/Network/Session.cs
index 07da486a7d..0431c43e85 100644
--- a/OpenRA.Game/Network/Session.cs
+++ b/OpenRA.Game/Network/Session.cs
@@ -42,11 +42,11 @@ namespace OpenRA.Network
break;
case "Client":
- session.Clients.Add(FieldLoader.Load(y.Value));
+ session.Clients.Add(FieldLoader.Load(y.Value));
break;
case "Slot":
- var s = FieldLoader.Load(y.Value);
+ var s = FieldLoader.Load(y.Value);
session.Slots.Add(s.PlayerReference, s);
break;
}
@@ -143,7 +143,7 @@ namespace OpenRA.Network
public Session(string[] mods)
{
this.GlobalSettings.Mods = mods.ToArray();
- this.GlobalSettings.GameUid = System.Guid.NewGuid().ToString();
+ this.GlobalSettings.GameUid = Guid.NewGuid().ToString();
}
public string Serialize()
diff --git a/OpenRA.Game/Network/SyncReport.cs b/OpenRA.Game/Network/SyncReport.cs
index 079ec31138..5270b0427f 100755
--- a/OpenRA.Game/Network/SyncReport.cs
+++ b/OpenRA.Game/Network/SyncReport.cs
@@ -32,7 +32,7 @@ namespace OpenRA.Network
{
this.orderManager = orderManager;
for (var i = 0; i < NumSyncReports; i++)
- syncReports[i] = new SyncReport.Report();
+ syncReports[i] = new Report();
}
internal void UpdateSyncReport()
diff --git a/OpenRA.Game/Server/Server.cs b/OpenRA.Game/Server/Server.cs
index fb2186b5c3..23433f5b57 100644
--- a/OpenRA.Game/Server/Server.cs
+++ b/OpenRA.Game/Server/Server.cs
@@ -9,10 +9,12 @@
#endregion
using System;
+using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
+using System.Net.NetworkInformation;
using System.Net.Sockets;
using System.Threading;
@@ -338,7 +340,7 @@ namespace OpenRA.Server
if (File.Exists("{0}motd_{1}.txt".F(Platform.SupportDir, LobbyInfo.GlobalSettings.Mods[0])))
{
- var motd = System.IO.File.ReadAllText("{0}motd_{1}.txt".F(Platform.SupportDir, LobbyInfo.GlobalSettings.Mods[0]));
+ var motd = File.ReadAllText("{0}motd_{1}.txt".F(Platform.SupportDir, LobbyInfo.GlobalSettings.Mods[0]));
SendOrderTo(newConn, "Message", motd);
}
diff --git a/OpenRA.Game/Sound.cs b/OpenRA.Game/Sound.cs
index ae661db21d..c89649f875 100644
--- a/OpenRA.Game/Sound.cs
+++ b/OpenRA.Game/Sound.cs
@@ -604,8 +604,8 @@ namespace OpenRA
int state;
Al.alGetSourcei(b, Al.AL_SOURCE_STATE, out state);
return ((state == Al.AL_PLAYING || state == Al.AL_PAUSED) &&
- ((music != null) ? b != ((OpenAlSound)music).source : true) &&
- ((video != null) ? b != ((OpenAlSound)video).source : true));
+ ((music == null) || b != ((OpenAlSound)music).source) &&
+ ((video == null) || b != ((OpenAlSound)video).source));
}).ToList();
foreach (var s in sounds)
{
diff --git a/OpenRA.Game/Support/Arguments.cs b/OpenRA.Game/Support/Arguments.cs
index 3a33944f00..aed2a634b3 100644
--- a/OpenRA.Game/Support/Arguments.cs
+++ b/OpenRA.Game/Support/Arguments.cs
@@ -21,11 +21,11 @@ namespace OpenRA
public Arguments(params string[] src)
{
- Regex regex = new Regex("([^=]+)=(.*)");
- foreach (string s in src)
+ var regex = new Regex("([^=]+)=(.*)");
+ foreach (var s in src)
{
Match m = regex.Match(s);
- if (m == null || !m.Success)
+ if (!m.Success)
continue;
args[m.Groups[1].Value] = m.Groups[2].Value;
diff --git a/OpenRA.Game/Traits/SelectionDecorations.cs b/OpenRA.Game/Traits/SelectionDecorations.cs
index bb177099c1..87f6178675 100644
--- a/OpenRA.Game/Traits/SelectionDecorations.cs
+++ b/OpenRA.Game/Traits/SelectionDecorations.cs
@@ -64,7 +64,7 @@ namespace OpenRA.Traits
return;
var pipSources = self.TraitsImplementing();
- if (pipSources.Count() == 0)
+ if (!pipSources.Any())
return;
var pipImages = new Animation("pips");
diff --git a/OpenRA.Game/Traits/Target.cs b/OpenRA.Game/Traits/Target.cs
index 0dd0997faa..ee5879d3bb 100644
--- a/OpenRA.Game/Traits/Target.cs
+++ b/OpenRA.Game/Traits/Target.cs
@@ -32,14 +32,14 @@ namespace OpenRA.Traits
public static Target FromOrder(Order o)
{
return o.TargetActor != null
- ? Target.FromActor(o.TargetActor)
- : Target.FromCell(o.TargetLocation);
+ ? FromActor(o.TargetActor)
+ : FromCell(o.TargetLocation);
}
public static Target FromActor(Actor a)
{
if (a == null)
- return Target.Invalid;
+ return Invalid;
return new Target
{
diff --git a/OpenRA.Game/Traits/Util.cs b/OpenRA.Game/Traits/Util.cs
index da87c3144a..154737f026 100755
--- a/OpenRA.Game/Traits/Util.cs
+++ b/OpenRA.Game/Traits/Util.cs
@@ -134,7 +134,7 @@ namespace OpenRA.Traits
public static IEnumerable AdjacentCells(Target target)
{
var cells = target.Positions.Select(p => p.ToCPos()).Distinct();
- return Util.ExpandFootprint(cells, true);
+ return ExpandFootprint(cells, true);
}
}
}
diff --git a/OpenRA.Game/Widgets/ButtonWidget.cs b/OpenRA.Game/Widgets/ButtonWidget.cs
index c17f358967..4b3b6c7389 100644
--- a/OpenRA.Game/Widgets/ButtonWidget.cs
+++ b/OpenRA.Game/Widgets/ButtonWidget.cs
@@ -185,7 +185,7 @@ namespace OpenRA.Widgets
public virtual void DrawBackground(Rectangle rect, bool disabled, bool pressed, bool hover, bool highlighted)
{
- ButtonWidget.DrawBackground("button", rect, disabled, pressed, hover, highlighted);
+ DrawBackground("button", rect, disabled, pressed, hover, highlighted);
}
public static void DrawBackground(string baseName, Rectangle rect, bool disabled, bool pressed, bool hover, bool highlighted)
diff --git a/OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs b/OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs
index ad5503408d..b2dec7acef 100644
--- a/OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs
+++ b/OpenRA.Game/Widgets/WorldInteractionControllerWidget.cs
@@ -57,8 +57,8 @@ namespace OpenRA.Widgets
var useClassicMouseStyle = Game.Settings.Game.UseClassicMouseStyle;
- var hasBox = (SelectionBox != null) ? true : false;
- var multiClick = (mi.MultiTapCount >= 2) ? true : false;
+ var hasBox = SelectionBox != null;
+ var multiClick = mi.MultiTapCount >= 2;
if (mi.Button == MouseButton.Left && mi.Event == MouseInputEvent.Down)
{
@@ -68,7 +68,7 @@ namespace OpenRA.Widgets
dragStart = dragEnd = xy;
// place buildings
- if (!useClassicMouseStyle || (useClassicMouseStyle && !World.Selection.Actors.Any()))
+ if (!useClassicMouseStyle || !World.Selection.Actors.Any())
ApplyOrders(World, xy, mi);
}
diff --git a/OpenRA.Game/WorldUtils.cs b/OpenRA.Game/WorldUtils.cs
index e52195228f..db9d5f9c6c 100755
--- a/OpenRA.Game/WorldUtils.cs
+++ b/OpenRA.Game/WorldUtils.cs
@@ -91,7 +91,7 @@ namespace OpenRA
public static string GetTerrainType(this World world, CPos cell)
{
var custom = world.Map.CustomTerrain[cell.X, cell.Y];
- return custom != null ? custom : world.TileSet.GetTerrainType(world.Map.MapTiles.Value[cell.X, cell.Y]);
+ return custom ?? world.TileSet.GetTerrainType(world.Map.MapTiles.Value[cell.X, cell.Y]);
}
public static TerrainTypeInfo GetTerrainInfo(this World world, CPos cell)
diff --git a/OpenRA.Mods.RA/AI/HackyAI.cs b/OpenRA.Mods.RA/AI/HackyAI.cs
index fedfb95ce6..a76dc7bd57 100644
--- a/OpenRA.Mods.RA/AI/HackyAI.cs
+++ b/OpenRA.Mods.RA/AI/HackyAI.cs
@@ -12,6 +12,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using OpenRA.FileFormats;
+using OpenRA.Mods.RA.Activities;
using OpenRA.Mods.RA.Air;
using OpenRA.Mods.RA.Buildings;
using OpenRA.Mods.RA.Move;
@@ -181,15 +182,13 @@ namespace OpenRA.Mods.RA.AI
int CountBuilding(string frac, Player owner)
{
return world.ActorsWithTrait()
- .Where(a => a.Actor.Owner == owner && a.Actor.Info.Name == frac)
- .Count();
+ .Count(a => a.Actor.Owner == owner && a.Actor.Info.Name == frac);
}
int CountUnits(string unit, Player owner)
{
return world.ActorsWithTrait()
- .Where(a => a.Actor.Owner == owner && a.Actor.Info.Name == unit)
- .Count();
+ .Count(a => a.Actor.Owner == owner && a.Actor.Info.Name == unit);
}
int? CountBuildingByCommonName(string commonName, Player owner)
@@ -198,8 +197,7 @@ namespace OpenRA.Mods.RA.AI
return null;
return world.ActorsWithTrait()
- .Where(a => a.Actor.Owner == owner && Info.BuildingCommonNames[commonName].Contains(a.Actor.Info.Name))
- .Count();
+ .Count(a => a.Actor.Owner == owner && Info.BuildingCommonNames[commonName].Contains(a.Actor.Info.Name));
}
ActorInfo GetBuildingInfoByCommonName(string commonName, Player owner)
@@ -553,8 +551,8 @@ namespace OpenRA.Mods.RA.AI
var act = a.GetCurrentActivity();
// A Wait activity is technically idle:
- if ((act.GetType() != typeof(OpenRA.Mods.RA.Activities.Wait)) &&
- (act.NextActivity == null || act.NextActivity.GetType() != typeof(OpenRA.Mods.RA.Activities.FindResources)))
+ if ((act.GetType() != typeof(Wait)) &&
+ (act.NextActivity == null || act.NextActivity.GetType() != typeof(FindResources)))
continue;
}
@@ -814,7 +812,7 @@ namespace OpenRA.Mods.RA.AI
return;
// No construction yards - Build a new MCV
- if (!HasAdequateFact() && !self.World.Actors.Where(a => a.Owner == p && a.HasTrait() && a.HasTrait()).Any())
+ if (!HasAdequateFact() && !self.World.Actors.Any(a => a.Owner == p && a.HasTrait() && a.HasTrait()))
BuildUnit("Vehicle", GetUnitInfoByCommonName("Mcv", p).Name);
foreach (var q in Info.UnitQueues)
diff --git a/OpenRA.Mods.RA/AI/States/AirStates.cs b/OpenRA.Mods.RA/AI/States/AirStates.cs
index 99d7a7dcb1..685347504b 100644
--- a/OpenRA.Mods.RA/AI/States/AirStates.cs
+++ b/OpenRA.Mods.RA/AI/States/AirStates.cs
@@ -10,6 +10,7 @@
using System.Collections.Generic;
using System.Linq;
+using OpenRA.Mods.RA.Activities;
using OpenRA.Mods.RA.Air;
using OpenRA.Traits;
@@ -125,7 +126,7 @@ namespace OpenRA.Mods.RA.AI
return false;
var type = activity.GetType();
- if (type == typeof(OpenRA.Mods.RA.Activities.Rearm) || type == typeof(ResupplyAircraft))
+ if (type == typeof(Rearm) || type == typeof(ResupplyAircraft))
return true;
var next = activity.NextActivity;
@@ -133,7 +134,7 @@ namespace OpenRA.Mods.RA.AI
return false;
var nextType = next.GetType();
- if (nextType == typeof(OpenRA.Mods.RA.Activities.Rearm) || nextType == typeof(ResupplyAircraft))
+ if (nextType == typeof(Rearm) || nextType == typeof(ResupplyAircraft))
return true;
return false;
diff --git a/OpenRA.Mods.RA/AI/States/StateBase.cs b/OpenRA.Mods.RA/AI/States/StateBase.cs
index 040349b17a..c92e3dae0b 100644
--- a/OpenRA.Mods.RA/AI/States/StateBase.cs
+++ b/OpenRA.Mods.RA/AI/States/StateBase.cs
@@ -11,6 +11,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using OpenRA.Mods.RA.Activities;
using OpenRA.Mods.RA.Air;
using OpenRA.Mods.RA.Buildings;
using OpenRA.Traits;
@@ -44,7 +45,7 @@ namespace OpenRA.Mods.RA.AI
return false;
var type = a.GetCurrentActivity().GetType();
- if (type == typeof(OpenRA.Mods.RA.Activities.Attack) || type == typeof(FlyAttack))
+ if (type == typeof(Attack) || type == typeof(FlyAttack))
return true;
var next = a.GetCurrentActivity().NextActivity;
@@ -52,7 +53,7 @@ namespace OpenRA.Mods.RA.AI
return false;
var nextType = a.GetCurrentActivity().NextActivity.GetType();
- if (nextType == typeof(OpenRA.Mods.RA.Activities.Attack) || nextType == typeof(FlyAttack))
+ if (nextType == typeof(Attack) || nextType == typeof(FlyAttack))
return true;
return false;
diff --git a/OpenRA.Mods.RA/Air/HeliFly.cs b/OpenRA.Mods.RA/Air/HeliFly.cs
index 4861bc14b4..fba3c0aae0 100755
--- a/OpenRA.Mods.RA/Air/HeliFly.cs
+++ b/OpenRA.Mods.RA/Air/HeliFly.cs
@@ -41,7 +41,7 @@ namespace OpenRA.Mods.RA.Air
var helicopter = self.Trait();
var cruiseAltitude = new WRange(helicopter.Info.CruiseAltitude * 1024 / Game.CellSize);
- if (HeliFly.AdjustAltitude(self, helicopter, cruiseAltitude))
+ if (AdjustAltitude(self, helicopter, cruiseAltitude))
return this;
// Rotate towards the target
diff --git a/OpenRA.Mods.RA/Attack/AttackBase.cs b/OpenRA.Mods.RA/Attack/AttackBase.cs
index 2c18b1c542..decb66c065 100644
--- a/OpenRA.Mods.RA/Attack/AttackBase.cs
+++ b/OpenRA.Mods.RA/Attack/AttackBase.cs
@@ -97,7 +97,7 @@ namespace OpenRA.Mods.RA
{
get
{
- if (Armaments.Count() == 0)
+ if (!Armaments.Any())
yield break;
var negativeDamage = Armaments.First().Weapon.Warheads[0].Damage < 0;
diff --git a/OpenRA.Mods.RA/ConquestVictoryConditions.cs b/OpenRA.Mods.RA/ConquestVictoryConditions.cs
index f37020a031..fa903fdaa7 100644
--- a/OpenRA.Mods.RA/ConquestVictoryConditions.cs
+++ b/OpenRA.Mods.RA/ConquestVictoryConditions.cs
@@ -44,9 +44,9 @@ namespace OpenRA.Mods.RA
var others = self.World.Players.Where( p => !p.NonCombatant
&& p != self.Owner && p.Stances[self.Owner] != Stance.Ally );
- if (others.Count() == 0) return;
+ if (!others.Any()) return;
- if(others.All(p => p.WinState == WinState.Lost))
+ if (others.All(p => p.WinState == WinState.Lost))
Win(self);
}
diff --git a/OpenRA.Mods.RA/Move/PathFinder.cs b/OpenRA.Mods.RA/Move/PathFinder.cs
index 5b1abc9f26..3ea2d44632 100755
--- a/OpenRA.Mods.RA/Move/PathFinder.cs
+++ b/OpenRA.Mods.RA/Move/PathFinder.cs
@@ -103,7 +103,7 @@ namespace OpenRA.Mods.RA.Move
{
var passable = mi.GetMovementClass(world.TileSet);
tilesInRange = new List(tilesInRange.Where(t => domainIndex.IsPassable(src, t, (uint)passable)));
- if (tilesInRange.Count() == 0)
+ if (!tilesInRange.Any())
return emptyPath;
}
diff --git a/OpenRA.Mods.RA/PaletteFromCurrentTileset.cs b/OpenRA.Mods.RA/PaletteFromCurrentTileset.cs
index 59072acb04..d720da6554 100644
--- a/OpenRA.Mods.RA/PaletteFromCurrentTileset.cs
+++ b/OpenRA.Mods.RA/PaletteFromCurrentTileset.cs
@@ -9,6 +9,7 @@
#endregion
using OpenRA.FileFormats;
+using OpenRA.Graphics;
using OpenRA.Traits;
namespace OpenRA.Mods.RA
@@ -36,7 +37,7 @@ namespace OpenRA.Mods.RA
this.info = info;
}
- public void InitPalette(OpenRA.Graphics.WorldRenderer wr)
+ public void InitPalette(WorldRenderer wr)
{
wr.AddPalette(info.Name, new Palette(FileSystem.Open(world.TileSet.Palette), info.ShadowIndex), info.AllowModifiers);
}
diff --git a/OpenRA.Mods.RA/PlayerPaletteFromCurrentTileset.cs b/OpenRA.Mods.RA/PlayerPaletteFromCurrentTileset.cs
index 33d62fd07a..cb75d1d6e4 100644
--- a/OpenRA.Mods.RA/PlayerPaletteFromCurrentTileset.cs
+++ b/OpenRA.Mods.RA/PlayerPaletteFromCurrentTileset.cs
@@ -9,6 +9,7 @@
#endregion
using OpenRA.FileFormats;
+using OpenRA.Graphics;
using OpenRA.Traits;
namespace OpenRA.Mods.RA
@@ -36,10 +37,10 @@ namespace OpenRA.Mods.RA
this.info = info;
}
- public void InitPalette (OpenRA.Graphics.WorldRenderer wr)
+ public void InitPalette(WorldRenderer wr)
{
- string Filename = world.TileSet.PlayerPalette == null ? world.TileSet.Palette : world.TileSet.PlayerPalette;
- wr.AddPalette(info.Name, new Palette(FileSystem.Open(Filename), info.ShadowIndex), info.AllowModifiers);
+ var filename = world.TileSet.PlayerPalette ?? world.TileSet.Palette;
+ wr.AddPalette(info.Name, new Palette(FileSystem.Open(filename), info.ShadowIndex), info.AllowModifiers);
}
}
}
diff --git a/OpenRA.Mods.RA/Production.cs b/OpenRA.Mods.RA/Production.cs
index 2ed9f268e8..bb6264ab30 100755
--- a/OpenRA.Mods.RA/Production.cs
+++ b/OpenRA.Mods.RA/Production.cs
@@ -9,6 +9,7 @@
#endregion
using System.Drawing;
+using System.Linq;
using OpenRA.FileFormats;
using OpenRA.Mods.RA.Move;
using OpenRA.Traits;
diff --git a/OpenRA.Mods.RA/Render/RenderSpy.cs b/OpenRA.Mods.RA/Render/RenderSpy.cs
index ce1db612f8..6fb78c4a5b 100755
--- a/OpenRA.Mods.RA/Render/RenderSpy.cs
+++ b/OpenRA.Mods.RA/Render/RenderSpy.cs
@@ -30,7 +30,7 @@ namespace OpenRA.Mods.RA.Render
protected override string PaletteName(Actor self)
{
- var player = spy.disguisedAsPlayer != null ? spy.disguisedAsPlayer : self.Owner;
+ var player = spy.disguisedAsPlayer ?? self.Owner;
return info.Palette ?? info.PlayerPalette + player.InternalName;
}
@@ -39,10 +39,7 @@ namespace OpenRA.Mods.RA.Render
if (spy.disguisedAsSprite != disguisedAsSprite)
{
disguisedAsSprite = spy.disguisedAsSprite;
- if (disguisedAsSprite != null)
- anim.ChangeImage(disguisedAsSprite, info.StandAnimations.Random(Game.CosmeticRandom));
- else
- anim.ChangeImage(GetImage(self), info.StandAnimations.Random(Game.CosmeticRandom));
+ anim.ChangeImage(disguisedAsSprite ?? GetImage(self), info.StandAnimations.Random(Game.CosmeticRandom));
UpdatePalette();
}
base.Tick(self);
diff --git a/OpenRA.Mods.RA/Turreted.cs b/OpenRA.Mods.RA/Turreted.cs
index 4ad33e90ce..cb6b5b069e 100755
--- a/OpenRA.Mods.RA/Turreted.cs
+++ b/OpenRA.Mods.RA/Turreted.cs
@@ -97,7 +97,7 @@ namespace OpenRA.Mods.RA
// Quantize orientation to match a rendered sprite
// Implies no pitch or yaw
- var facing = Traits.Util.QuantizeFacing(local.Yaw.Angle / 4, QuantizedFacings) * (256 / QuantizedFacings);
+ var facing = Util.QuantizeFacing(local.Yaw.Angle / 4, QuantizedFacings) * (256 / QuantizedFacings);
return new WRot(WAngle.Zero, WAngle.Zero, WAngle.FromFacing(facing));
}
}
diff --git a/OpenRA.Mods.RA/Widgets/BuildPaletteWidget.cs b/OpenRA.Mods.RA/Widgets/BuildPaletteWidget.cs
index 1d9b018707..db0fe250f4 100755
--- a/OpenRA.Mods.RA/Widgets/BuildPaletteWidget.cs
+++ b/OpenRA.Mods.RA/Widgets/BuildPaletteWidget.cs
@@ -290,7 +290,7 @@ namespace OpenRA.Mods.RA.Widgets
new float2(Game.Renderer.Resolution.Width - 14, origin.Y - 23));
for (int i = 0; i < numActualRows; i++)
- WidgetUtils.DrawRGBA(ChromeProvider.GetImage(paletteCollection, "dock-" + (i % 4).ToString()),
+ WidgetUtils.DrawRGBA(ChromeProvider.GetImage(paletteCollection, "dock-" + (i % 4)),
new float2(Game.Renderer.Resolution.Width - 14, origin.Y + IconHeight * i));
WidgetUtils.DrawRGBA(ChromeProvider.GetImage(paletteCollection, "dock-bottom"),
diff --git a/OpenRA.Mods.RA/Widgets/Logic/ConvertGameFilesLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/ConvertGameFilesLogic.cs
index 76cb354e6c..8cd8bfcc60 100644
--- a/OpenRA.Mods.RA/Widgets/Logic/ConvertGameFilesLogic.cs
+++ b/OpenRA.Mods.RA/Widgets/Logic/ConvertGameFilesLogic.cs
@@ -12,6 +12,7 @@ using System;
using System.IO;
using System.Linq;
using System.Threading;
+using OpenRA.Utility;
using OpenRA.Widgets;
namespace OpenRA.Mods.RA.Widgets.Logic
@@ -69,21 +70,21 @@ namespace OpenRA.Mods.RA.Widgets.Logic
{
progressBar.Percentage = i*100/ExtractGameFiles.Count();
statusLabel.GetText = () => "Extracting...";
- Utility.Command.ExtractFiles(ExtractGameFiles[i]);
+ Command.ExtractFiles(ExtractGameFiles[i]);
}
for (int i = 0; i < ExportToPng.Length; i++)
{
progressBar.Percentage = i*100/ExportToPng.Count();
statusLabel.GetText = () => "Exporting SHP to PNG...";
- Utility.Command.ConvertShpToPng(ExportToPng[i]);
+ Command.ConvertShpToPng(ExportToPng[i]);
}
for (int i = 0; i < ImportFromPng.Length; i++)
{
progressBar.Percentage = i*100/ImportFromPng.Count();
statusLabel.GetText = () => "Converting PNG to SHP...";
- Utility.Command.ConvertPngToShp(ImportFromPng[i]);
+ Command.ConvertPngToShp(ImportFromPng[i]);
}
Game.RunAfterTick(() =>
diff --git a/OpenRA.Mods.RA/Widgets/Logic/LobbyLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/LobbyLogic.cs
index d6e585afd4..a7f0597644 100644
--- a/OpenRA.Mods.RA/Widgets/Logic/LobbyLogic.cs
+++ b/OpenRA.Mods.RA/Widgets/Logic/LobbyLogic.cs
@@ -319,7 +319,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
fragileAlliance.IsDisabled = () => Map.Options.FragileAlliances.HasValue || configurationDisabled();
fragileAlliance.OnClick = () => orderManager.IssueOrder(Order.Command(
"fragilealliance {0}".F(!orderManager.LobbyInfo.GlobalSettings.FragileAlliances)));
- };
+ }
var difficulty = optionsBin.GetOrNull("DIFFICULTY_DROPDOWNBUTTON");
if (difficulty != null)
@@ -417,7 +417,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
enableShroud.IsDisabled = () => Map.Options.Shroud.HasValue || configurationDisabled();
enableShroud.OnClick = () => orderManager.IssueOrder(Order.Command(
"shroud {0}".F(!orderManager.LobbyInfo.GlobalSettings.Shroud)));
- };
+ }
var enableFog = optionsBin.GetOrNull("FOG_CHECKBOX");
if (enableFog != null)
@@ -426,7 +426,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
enableFog.IsDisabled = () => Map.Options.Fog.HasValue || configurationDisabled();
enableFog.OnClick = () => orderManager.IssueOrder(Order.Command(
"fog {0}".F(!orderManager.LobbyInfo.GlobalSettings.Fog)));
- };
+ }
var disconnectButton = lobby.Get("DISCONNECT_BUTTON");
disconnectButton.OnClick = () => { CloseWindow(); onExit(); };
diff --git a/OpenRA.Mods.RA/Widgets/Logic/LobbyUtils.cs b/OpenRA.Mods.RA/Widgets/Logic/LobbyUtils.cs
index 3981edcab1..6b58d45abc 100644
--- a/OpenRA.Mods.RA/Widgets/Logic/LobbyUtils.cs
+++ b/OpenRA.Mods.RA/Widgets/Logic/LobbyUtils.cs
@@ -254,7 +254,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
slot.IsVisible = () => true;
slot.IsDisabled = () => orderManager.LocalClient.IsReady;
slot.GetText = () => c != null ? c.Name : s.Closed ? "Closed" : "Open";
- slot.OnMouseDown = _ => LobbyUtils.ShowSlotDropDown(slot, s, c, orderManager);
+ slot.OnMouseDown = _ => ShowSlotDropDown(slot, s, c, orderManager);
// Ensure Name selector (if present) is hidden
var name = parent.GetOrNull("NAME");
@@ -297,7 +297,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
{
var color = parent.Get("COLOR");
color.IsDisabled = () => (s != null && s.LockColor) || orderManager.LocalClient.IsReady;
- color.OnMouseDown = _ => LobbyUtils.ShowColorDropDown(color, c, orderManager, colorPreview);
+ color.OnMouseDown = _ => ShowColorDropDown(color, c, orderManager, colorPreview);
SetupColorWidget(color, s, c);
}
@@ -312,7 +312,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
{
var dropdown = parent.Get("FACTION");
dropdown.IsDisabled = () => s.LockRace || orderManager.LocalClient.IsReady;
- dropdown.OnMouseDown = _ => LobbyUtils.ShowRaceDropDown(dropdown, c, orderManager, countryNames);
+ dropdown.OnMouseDown = _ => ShowRaceDropDown(dropdown, c, orderManager, countryNames);
SetupFactionWidget(dropdown, s, c, countryNames);
}
@@ -329,7 +329,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
{
var dropdown = parent.Get("TEAM");
dropdown.IsDisabled = () => s.LockTeam || orderManager.LocalClient.IsReady;
- dropdown.OnMouseDown = _ => LobbyUtils.ShowTeamDropDown(dropdown, c, orderManager, teamCount);
+ dropdown.OnMouseDown = _ => ShowTeamDropDown(dropdown, c, orderManager, teamCount);
dropdown.GetText = () => (c.Team == 0) ? "-" : c.Team.ToString();
}
diff --git a/OpenRA.Mods.RA/Widgets/Logic/MusicPlayerLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/MusicPlayerLogic.cs
index ecba8e79e8..217d93b9ff 100644
--- a/OpenRA.Mods.RA/Widgets/Logic/MusicPlayerLogic.cs
+++ b/OpenRA.Mods.RA/Widgets/Logic/MusicPlayerLogic.cs
@@ -11,6 +11,7 @@
using System;
using System.Linq;
using OpenRA.GameRules;
+using OpenRA.Traits;
using OpenRA.Widgets;
namespace OpenRA.Mods.RA.Widgets.Logic
diff --git a/OpenRA.Mods.RA/Widgets/Logic/ServerBrowserLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/ServerBrowserLogic.cs
index 4eb90c85f9..9adb9855ee 100644
--- a/OpenRA.Mods.RA/Widgets/Logic/ServerBrowserLogic.cs
+++ b/OpenRA.Mods.RA/Widgets/Logic/ServerBrowserLogic.cs
@@ -194,7 +194,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
return;
}
- if (games.Count() == 0)
+ if (!games.Any())
{
searchStatus = SearchStatus.NoGames;
return;
diff --git a/OpenRA.Mods.RA/Widgets/SupportPowerBinWidget.cs b/OpenRA.Mods.RA/Widgets/SupportPowerBinWidget.cs
index 40ec8febb0..27a4f32dbb 100755
--- a/OpenRA.Mods.RA/Widgets/SupportPowerBinWidget.cs
+++ b/OpenRA.Mods.RA/Widgets/SupportPowerBinWidget.cs
@@ -126,7 +126,7 @@ namespace OpenRA.Mods.RA.Widgets
if (sp.TotalTime > 0)
{
pos += new int2(0,20);
- Game.Renderer.Fonts["Bold"].DrawText(WidgetUtils.FormatTime(sp.RemainingTime).ToString(), pos, Color.White);
+ Game.Renderer.Fonts["Bold"].DrawText(WidgetUtils.FormatTime(sp.RemainingTime), pos, Color.White);
Game.Renderer.Fonts["Bold"].DrawText("/ {0}".F(WidgetUtils.FormatTime(sp.TotalTime)), pos + new int2(45,0), Color.White);
}
diff --git a/OpenRA.Mods.RA/World/DomainIndex.cs b/OpenRA.Mods.RA/World/DomainIndex.cs
index a83832bbd9..dae2a6ca05 100644
--- a/OpenRA.Mods.RA/World/DomainIndex.cs
+++ b/OpenRA.Mods.RA/World/DomainIndex.cs
@@ -147,8 +147,7 @@ namespace OpenRA.Mods.RA
var toProcess = new Stack();
toProcess.Push(d1);
- var i = 0;
- while (toProcess.Count() > 0)
+ while (toProcess.Any())
{
var current = toProcess.Pop();
if (!transientConnections.ContainsKey(current))
@@ -163,7 +162,6 @@ namespace OpenRA.Mods.RA
}
visited.Add(current);
- i += 1;
}
return false;
diff --git a/OpenRA.Mods.RA/World/PathfinderDebugOverlay.cs b/OpenRA.Mods.RA/World/PathfinderDebugOverlay.cs
index 4433a9b3cd..7a4ba1f35b 100644
--- a/OpenRA.Mods.RA/World/PathfinderDebugOverlay.cs
+++ b/OpenRA.Mods.RA/World/PathfinderDebugOverlay.cs
@@ -17,7 +17,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.RA
{
- class PathfinderDebugOverlayInfo : Traits.TraitInfo { }
+ class PathfinderDebugOverlayInfo : TraitInfo { }
class PathfinderDebugOverlay : IRenderOverlay, IWorldLoaded
{
Dictionary layers;
diff --git a/OpenRA.Mods.RA/World/ResourceClaimLayer.cs b/OpenRA.Mods.RA/World/ResourceClaimLayer.cs
index 3a06ca0b48..1f94d71676 100644
--- a/OpenRA.Mods.RA/World/ResourceClaimLayer.cs
+++ b/OpenRA.Mods.RA/World/ResourceClaimLayer.cs
@@ -32,7 +32,7 @@ namespace OpenRA.Mods.RA
}
}
- public void WorldLoaded(OpenRA.World w, WorldRenderer wr)
+ public void WorldLoaded(World w, WorldRenderer wr)
{
// NOTE(jsd): 32 seems a sane default initial capacity for the total # of harvesters in a game. Purely a guesstimate.
claimByCell = new Dictionary(32);
diff --git a/OpenRA.Renderer.Cg/GraphicsDevice.cs b/OpenRA.Renderer.Cg/GraphicsDevice.cs
index 7da81d7b5e..15c8d69e46 100755
--- a/OpenRA.Renderer.Cg/GraphicsDevice.cs
+++ b/OpenRA.Renderer.Cg/GraphicsDevice.cs
@@ -55,8 +55,8 @@ namespace OpenRA.Renderer.Cg
Tao.Cg.Cg.cgSetErrorCallback(errorCallback);
- Tao.Cg.CgGl.cgGLRegisterStates(Context);
- Tao.Cg.CgGl.cgGLSetManageTextureParameters(Context, true);
+ CgGl.cgGLRegisterStates(Context);
+ CgGl.cgGLSetManageTextureParameters(Context, true);
VertexProfile = CgGl.cgGLGetLatestProfile(CgGl.CG_GL_VERTEX);
FragmentProfile = CgGl.cgGLGetLatestProfile(CgGl.CG_GL_FRAGMENT);
}
diff --git a/OpenRA.Renderer.Sdl2/Sdl2Input.cs b/OpenRA.Renderer.Sdl2/Sdl2Input.cs
index cef51cc280..37c021a524 100644
--- a/OpenRA.Renderer.Sdl2/Sdl2Input.cs
+++ b/OpenRA.Renderer.Sdl2/Sdl2Input.cs
@@ -47,7 +47,7 @@ namespace OpenRA.Renderer.Sdl2
switch (e.type)
{
case SDL.SDL_EventType.SDL_QUIT:
- OpenRA.Game.Exit();
+ Game.Exit();
break;
case SDL.SDL_EventType.SDL_WINDOWEVENT:
@@ -176,7 +176,7 @@ namespace OpenRA.Renderer.Sdl2
if (e.key.keysym.sym == SDL.SDL_Keycode.SDLK_F4 && mods.HasModifier(Modifiers.Alt) &&
Platform.CurrentPlatform == PlatformType.Windows)
{
- OpenRA.Game.Exit();
+ Game.Exit();
}
else
inputHandler.OnKeyInput(keyEvent);
diff --git a/OpenRA.Renderer.SdlCommon/SdlInput.cs b/OpenRA.Renderer.SdlCommon/SdlInput.cs
index 60f5d33b47..6305e0fb74 100644
--- a/OpenRA.Renderer.SdlCommon/SdlInput.cs
+++ b/OpenRA.Renderer.SdlCommon/SdlInput.cs
@@ -185,7 +185,7 @@ namespace OpenRA.Renderer.SdlCommon
switch (e.type)
{
case Sdl.SDL_QUIT:
- OpenRA.Game.Exit();
+ Game.Exit();
break;
case Sdl.SDL_MOUSEBUTTONDOWN:
@@ -264,7 +264,7 @@ namespace OpenRA.Renderer.SdlCommon
if (e.key.keysym.sym == Sdl.SDLK_F4 && mods.HasModifier(Modifiers.Alt) &&
Platform.CurrentPlatform == PlatformType.Windows)
{
- OpenRA.Game.Exit();
+ Game.Exit();
}
else
inputHandler.OnKeyInput(keyEvent);
diff --git a/OpenRA.TilesetBuilder/FormBuilder.cs b/OpenRA.TilesetBuilder/FormBuilder.cs
index 0e95081f41..7a56e0499f 100644
--- a/OpenRA.TilesetBuilder/FormBuilder.cs
+++ b/OpenRA.TilesetBuilder/FormBuilder.cs
@@ -429,7 +429,7 @@ namespace OpenRA.TilesetBuilder
Console.WriteLine("{0} {1} {2} {3} {4} {5} {6}",
cur,
idx,
- ((t.Key.Y * surface1.TilesPerRow) + t.Key.X).ToString(),
+ ((t.Key.Y * surface1.TilesPerRow) + t.Key.X),
tp.Width,
tp.Height,
t.Key.X,