Simplify names, remove unused usings, remove redundant casts.

This commit is contained in:
RoosterDragon
2016-01-17 21:24:41 +00:00
parent aaeb715006
commit 8e89a6a696
304 changed files with 218 additions and 639 deletions

View File

@@ -288,7 +288,7 @@ namespace OpenRA
if (wasInWorld)
w.Add(this);
foreach (var t in this.TraitsImplementing<INotifyOwnerChanged>())
foreach (var t in TraitsImplementing<INotifyOwnerChanged>())
t.OnOwnerChanged(this, oldOwner, newOwner);
});
}
@@ -381,7 +381,7 @@ namespace OpenRA
public LuaValue Equals(LuaRuntime runtime, LuaValue left, LuaValue right)
{
Actor a, b;
if (!left.TryGetClrValue<Actor>(out a) || !right.TryGetClrValue<Actor>(out b))
if (!left.TryGetClrValue(out a) || !right.TryGetClrValue(out b))
return false;
return a == b;

View File

@@ -73,7 +73,7 @@ namespace OpenRA
{
CPos a;
CVec b;
if (!left.TryGetClrValue<CPos>(out a) || !right.TryGetClrValue<CVec>(out b))
if (!left.TryGetClrValue(out a) || !right.TryGetClrValue(out b))
throw new LuaException("Attempted to call CPos.Add(CPos, CVec) with invalid arguments ({0}, {1})".F(left.WrappedClrType().Name, right.WrappedClrType().Name));
return new LuaCustomClrObject(a + b);
@@ -83,7 +83,7 @@ namespace OpenRA
{
CPos a;
CVec b;
if (!left.TryGetClrValue<CPos>(out a) || !right.TryGetClrValue<CVec>(out b))
if (!left.TryGetClrValue(out a) || !right.TryGetClrValue(out b))
throw new LuaException("Attempted to call CPos.Subtract(CPos, CVec) with invalid arguments ({0}, {1})".F(left.WrappedClrType().Name, right.WrappedClrType().Name));
return new LuaCustomClrObject(a - b);
@@ -92,7 +92,7 @@ namespace OpenRA
public LuaValue Equals(LuaRuntime runtime, LuaValue left, LuaValue right)
{
CPos a, b;
if (!left.TryGetClrValue<CPos>(out a) || !right.TryGetClrValue<CPos>(out b))
if (!left.TryGetClrValue(out a) || !right.TryGetClrValue(out b))
return false;
return a == b;

View File

@@ -75,7 +75,7 @@ namespace OpenRA
public LuaValue Add(LuaRuntime runtime, LuaValue left, LuaValue right)
{
CVec a, b;
if (!left.TryGetClrValue<CVec>(out a) || !right.TryGetClrValue<CVec>(out b))
if (!left.TryGetClrValue(out a) || !right.TryGetClrValue(out b))
throw new LuaException("Attempted to call CVec.Add(CVec, CVec) with invalid arguments ({0}, {1})".F(left.WrappedClrType().Name, right.WrappedClrType().Name));
return new LuaCustomClrObject(a + b);
@@ -84,7 +84,7 @@ namespace OpenRA
public LuaValue Subtract(LuaRuntime runtime, LuaValue left, LuaValue right)
{
CVec a, b;
if (!left.TryGetClrValue<CVec>(out a) || !right.TryGetClrValue<CVec>(out b))
if (!left.TryGetClrValue(out a) || !right.TryGetClrValue(out b))
throw new LuaException("Attempted to call CVec.Subtract(CVec, CVec) with invalid arguments ({0}, {1})".F(left.WrappedClrType().Name, right.WrappedClrType().Name));
return new LuaCustomClrObject(a - b);
@@ -98,7 +98,7 @@ namespace OpenRA
public LuaValue Equals(LuaRuntime runtime, LuaValue left, LuaValue right)
{
CVec a, b;
if (!left.TryGetClrValue<CVec>(out a) || !right.TryGetClrValue<CVec>(out b))
if (!left.TryGetClrValue(out a) || !right.TryGetClrValue(out b))
return false;
return a == b;

View File

@@ -126,7 +126,7 @@ namespace OpenRA
return result;
}
if (t.IsGenericType && t.GetGenericTypeDefinition() == typeof(OpenRA.Primitives.Cache<,>))
if (t.IsGenericType && t.GetGenericTypeDefinition() == typeof(Primitives.Cache<,>))
return ""; // TODO
if (t == typeof(DateTime))

View File

@@ -55,7 +55,7 @@ namespace OpenRA.FileFormats
{
var pn = (byte*)tempPn;
var i = blen * 4;
for (; i > klen; i--) pn[i - 1] = (byte)sign;
for (; i > klen; i--) pn[i - 1] = sign;
for (; i > 0; i--) pn[i - 1] = key[klen - i];
}
}

View File

@@ -11,7 +11,6 @@
using System;
using System.IO;
using System.Linq;
using OpenRA.Graphics;
namespace OpenRA.FileFormats

View File

@@ -8,7 +8,6 @@
*/
#endregion
using System;
using System.IO;
namespace OpenRA.FileFormats

View File

@@ -49,11 +49,11 @@ namespace OpenRA.FileFormats
writer.Write(Encoding.ASCII.GetBytes("XCC by Olaf van der Spek"));
writer.Write(new byte[] { 0x1A, 0x04, 0x17, 0x27, 0x10, 0x19, 0x80, 0x00 });
writer.Write((int)(Entries.Aggregate(Entries.Length, (a, b) => a + b.Length) + 52)); // Size
writer.Write((int)0); // Type
writer.Write((int)0); // Version
writer.Write((int)0); // Game/Format (0 == TD)
writer.Write((int)Entries.Length); // Entries
writer.Write(Entries.Aggregate(Entries.Length, (a, b) => a + b.Length) + 52); // Size
writer.Write(0); // Type
writer.Write(0); // Version
writer.Write(0); // Game/Format (0 == TD)
writer.Write(Entries.Length); // Entries
foreach (var e in Entries)
{
writer.Write(Encoding.ASCII.GetBytes(e));

View File

@@ -8,7 +8,6 @@
*/
#endregion
using System;
using System.Collections.Generic;
using System.IO;

View File

@@ -43,7 +43,7 @@ namespace OpenRA.FileSystem
FirstFile = reader.ReadUInt32();
LastFile = reader.ReadUInt32();
reader.Seek(offset + (long)nameOffset, SeekOrigin.Begin);
reader.Seek(offset + nameOffset, SeekOrigin.Begin);
Name = reader.ReadASCIIZ();
}
}
@@ -107,7 +107,7 @@ namespace OpenRA.FileSystem
{
Version = reader.ReadUInt32();
VolumeInfo = reader.ReadUInt32();
CabDescriptorOffset = (long)reader.ReadUInt32();
CabDescriptorOffset = reader.ReadUInt32();
CabDescriptorSize = reader.ReadUInt32();
}
}
@@ -125,7 +125,7 @@ namespace OpenRA.FileSystem
public CabDescriptor(Stream reader, CommonHeader commonHeader)
{
reader.Seek(commonHeader.CabDescriptorOffset + 12, SeekOrigin.Begin);
FileTableOffset = (long)reader.ReadUInt32();
FileTableOffset = reader.ReadUInt32();
/* unknown */ reader.ReadUInt32();
FileTableSize = reader.ReadUInt32();
@@ -134,7 +134,7 @@ namespace OpenRA.FileSystem
/* unknown */ reader.ReadBytes(8);
FileCount = reader.ReadUInt32();
FileTableOffset2 = (long)reader.ReadUInt32();
FileTableOffset2 = reader.ReadUInt32();
}
}
@@ -201,7 +201,7 @@ namespace OpenRA.FileSystem
this.index = index;
this.commonName = commonName;
this.context = context;
volumeNumber = (ushort)((uint)fileDes.Volume - 1u);
volumeNumber = (ushort)(fileDes.Volume - 1u);
RemainingArchiveStream = 0;
if ((fileDes.Flags & FileCompressed) > 0)
RemainingFileStream = fileDes.CompressedSize;
@@ -374,7 +374,7 @@ namespace OpenRA.FileSystem
hdrFile.Seek((long)nextOffset + 4 + commonHeader.CabDescriptorOffset, SeekOrigin.Begin);
var descriptorOffset = hdrFile.ReadUInt32();
nextOffset = hdrFile.ReadUInt32();
hdrFile.Seek((long)descriptorOffset + commonHeader.CabDescriptorOffset, SeekOrigin.Begin);
hdrFile.Seek(descriptorOffset + commonHeader.CabDescriptorOffset, SeekOrigin.Begin);
fileGroups.Add(new FileGroup(hdrFile, commonHeader.CabDescriptorOffset));
}
@@ -387,7 +387,7 @@ namespace OpenRA.FileSystem
{
AddFileDescriptorToList(index);
var fileDescriptor = fileDescriptors[index];
var fullFilePath = "{0}\\{1}\\{2}".F(fileGroup.Name, DirectoryName((uint)fileDescriptor.DirectoryIndex), fileDescriptor.Filename);
var fullFilePath = "{0}\\{1}\\{2}".F(fileGroup.Name, DirectoryName(fileDescriptor.DirectoryIndex), fileDescriptor.Filename);
fileLookup.Add(fullFilePath, index);
}
}

View File

@@ -8,7 +8,6 @@
*/
#endregion
using System;
using System.Collections.Generic;
using System.IO;

View File

@@ -8,7 +8,6 @@
*/
#endregion
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;

View File

@@ -86,7 +86,7 @@ namespace OpenRA
// More accurate replacement for Environment.TickCount
static Stopwatch stopwatch = Stopwatch.StartNew();
public static int RunTime { get { return (int)Game.stopwatch.ElapsedMilliseconds; } }
public static int RunTime { get { return (int)stopwatch.ElapsedMilliseconds; } }
public static int RenderFrame = 0;
public static int NetFrameNumber { get { return OrderManager.NetFrameNumber; } }
@@ -461,8 +461,8 @@ namespace OpenRA
// Note: These delayed actions should only be used by widgets or disposing objects
// - things that depend on a particular world should be queuing them on the world actor.
static volatile ActionQueue delayedActions = new ActionQueue();
public static void RunAfterTick(Action a) { delayedActions.Add(a, Game.RunTime); }
public static void RunAfterDelay(int delayMilliseconds, Action a) { delayedActions.Add(a, Game.RunTime + delayMilliseconds); }
public static void RunAfterTick(Action a) { delayedActions.Add(a, RunTime); }
public static void RunAfterDelay(int delayMilliseconds, Action a) { delayedActions.Add(a, RunTime + delayMilliseconds); }
static void TakeScreenshotInner()
{
@@ -489,7 +489,7 @@ namespace OpenRA
bitmap.Dispose();
Game.RunAfterTick(() => Debug("Saved screenshot " + filename));
RunAfterTick(() => Debug("Saved screenshot " + filename));
});
}
@@ -571,7 +571,7 @@ namespace OpenRA
static void LogicTick()
{
delayedActions.PerformActions(Game.RunTime);
delayedActions.PerformActions(RunTime);
if (OrderManager.Connection.ConnectionState != lastConnectionState)
{
@@ -604,9 +604,9 @@ namespace OpenRA
using (new PerfSample("render_widgets"))
{
Game.Renderer.WorldVoxelRenderer.BeginFrame();
Renderer.WorldVoxelRenderer.BeginFrame();
Ui.PrepareRenderables();
Game.Renderer.WorldVoxelRenderer.EndFrame();
Renderer.WorldVoxelRenderer.EndFrame();
Ui.Draw();
@@ -684,7 +684,7 @@ namespace OpenRA
{
// Ideal time between logic updates. Timestep = 0 means the game is paused
// but we still call LogicTick() because it handles pausing internally.
var logicInterval = worldRenderer != null && worldRenderer.World.Timestep != 0 ? worldRenderer.World.Timestep : Game.Timestep;
var logicInterval = worldRenderer != null && worldRenderer.World.Timestep != 0 ? worldRenderer.World.Timestep : Timestep;
// Ideal time between screen updates
var maxFramerate = Settings.Graphics.CapFramerate ? Settings.Graphics.MaxFramerate.Clamp(1, 1000) : 1000;

View File

@@ -8,10 +8,7 @@
*/
#endregion
using System;
using System.Collections.Generic;
using System.Linq;
using OpenRA.Graphics;
namespace OpenRA
{

View File

@@ -10,11 +10,9 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using Meebey.SmartIrc4net;
using OpenRA;
using OpenRA.Primitives;
namespace OpenRA.Chat

View File

@@ -9,7 +9,6 @@
#endregion
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace OpenRA.Graphics

View File

@@ -12,8 +12,6 @@ using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using OpenRA.Graphics;
using OpenRA.Primitives;
namespace OpenRA.Graphics
{

View File

@@ -37,7 +37,7 @@ namespace OpenRA.Graphics
if (defaultSrc != Src)
root.Add(new MiniYamlNode("Src", Src));
return new MiniYaml(FieldSaver.FormatValue(this, this.GetType().GetField("rect")), root);
return new MiniYaml(FieldSaver.FormatValue(this, GetType().GetField("rect")), root);
}
}
}

View File

@@ -57,7 +57,7 @@ namespace OpenRA.Graphics
var b = new Bitmap(Size, 1, PixelFormat.Format32bppArgb);
var data = b.LockBits(new Rectangle(0, 0, b.Width, b.Height),
ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
var temp = new uint[Palette.Size];
var temp = new uint[Size];
palette.CopyToArray(temp, 0);
Marshal.Copy((int[])(object)temp, 0, data.Scan0, Size);
b.UnlockBits(data);

View File

@@ -8,12 +8,6 @@
*/
#endregion
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using OpenRA.Traits;
namespace OpenRA.Graphics
{
public sealed class PaletteReference

View File

@@ -29,7 +29,7 @@ namespace OpenRA.Graphics
{
// Increase luminosity if required to represent the full ramp
var rampRange = (byte)((1 - rampFraction) * c.L);
var c1 = new HSLColor(c.H, c.S, (byte)Math.Max(rampRange, c.L)).RGB;
var c1 = new HSLColor(c.H, c.S, Math.Max(rampRange, c.L)).RGB;
var c2 = new HSLColor(c.H, c.S, (byte)Math.Max(0, c.L - rampRange)).RGB;
var baseIndex = ramp[0];
var remapRamp = ramp.Select(r => r - ramp[0]);

View File

@@ -8,9 +8,7 @@
*/
#endregion
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
namespace OpenRA.Graphics
{

View File

@@ -9,7 +9,6 @@
#endregion
using System.Drawing;
using OpenRA.Graphics;
using OpenRA.Traits;
namespace OpenRA.Graphics

View File

@@ -10,9 +10,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
namespace OpenRA.Graphics
{
@@ -50,8 +48,8 @@ namespace OpenRA.Graphics
public SequenceProvider(SequenceCache cache, Map map)
{
this.sequences = Exts.Lazy(() => cache.LoadSequences(map));
this.SpriteCache = cache.SpriteCache;
sequences = Exts.Lazy(() => cache.LoadSequences(map));
SpriteCache = cache.SpriteCache;
}
public ISpriteSequence GetSequence(string unitName, string sequenceName)

View File

@@ -12,7 +12,6 @@ using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace OpenRA.Graphics

View File

@@ -11,7 +11,6 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
namespace OpenRA.Graphics
{

View File

@@ -10,9 +10,7 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using OpenRA.Graphics;
using OpenRA.Primitives;
namespace OpenRA.Graphics

View File

@@ -11,8 +11,6 @@
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using OpenRA.Graphics;
using OpenRA.Traits;
namespace OpenRA.Graphics
{

View File

@@ -12,8 +12,6 @@ using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using OpenRA.Traits;
namespace OpenRA.Graphics
{

View File

@@ -12,7 +12,6 @@ using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using OpenRA.FileSystem;
using OpenRA.Support;
namespace OpenRA.Graphics

View File

@@ -8,9 +8,7 @@
*/
#endregion
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
namespace OpenRA.Graphics
{

View File

@@ -11,7 +11,6 @@
using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.Runtime.InteropServices;
namespace OpenRA.Graphics
{

View File

@@ -25,7 +25,7 @@ namespace OpenRA.Graphics
public VoxelRenderProxy(Sprite sprite, Sprite shadowSprite, float2[] projectedShadowBounds, float shadowDirection)
{
this.Sprite = sprite;
Sprite = sprite;
ShadowSprite = shadowSprite;
ProjectedShadowBounds = projectedShadowBounds;
ShadowDirection = shadowDirection;

View File

@@ -86,12 +86,12 @@ namespace OpenRA
Player player;
public OwnerInit() { }
public OwnerInit(string playerName) { this.PlayerName = playerName; }
public OwnerInit(string playerName) { PlayerName = playerName; }
public OwnerInit(Player player)
{
this.player = player;
this.PlayerName = player.InternalName;
PlayerName = player.InternalName;
}
public Player Value(World world)

View File

@@ -74,7 +74,7 @@ namespace OpenRA
return uv.V * Size.Width + uv.U;
}
/// <summary>Gets or sets the <see cref="OpenRA.CellLayer"/> using cell coordinates</summary>
/// <summary>Gets or sets the <see cref="CellLayer"/> using cell coordinates</summary>
public T this[CPos cell]
{
get

View File

@@ -16,7 +16,6 @@ using System.Linq;
using System.Security.Cryptography;
using System.Text;
using OpenRA.FileSystem;
using OpenRA.GameRules;
using OpenRA.Graphics;
using OpenRA.Network;
using OpenRA.Support;
@@ -277,7 +276,7 @@ namespace OpenRA
{
var size = new Size(width, height);
Grid = Game.ModData.Manifest.Get<MapGrid>();
var tileRef = new TerrainTile(tileset.Templates.First().Key, (byte)0);
var tileRef = new TerrainTile(tileset.Templates.First().Key, 0);
Title = "Name your map here";
Description = "Describe your map here";
@@ -604,7 +603,7 @@ namespace OpenRA
foreach (var field in fields)
{
var f = this.GetType().GetField(field);
var f = GetType().GetField(field);
if (f.GetValue(this) == null)
continue;
root.Add(new MiniYamlNode(field, FieldSaver.FormatValue(this, f)));

View File

@@ -8,10 +8,8 @@
*/
#endregion
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
namespace OpenRA
{
@@ -64,8 +62,8 @@ namespace OpenRA
public MapCoordsRegion(MPos mapTopLeft, MPos mapBottomRight)
{
this.topLeft = mapTopLeft;
this.bottomRight = mapBottomRight;
topLeft = mapTopLeft;
bottomRight = mapBottomRight;
}
public MapCoordsEnumerator GetEnumerator()

View File

@@ -13,7 +13,6 @@ using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Net;

View File

@@ -79,9 +79,9 @@ namespace OpenRA
public TerrainTemplateInfo(ushort id, string[] images, int2 size, byte[] tiles)
{
this.Id = id;
this.Images = images;
this.Size = size;
Id = id;
Images = images;
Size = size;
}
public TerrainTemplateInfo(TileSet tileSet, MiniYaml my)

View File

@@ -68,7 +68,7 @@ namespace OpenRA.Network
public virtual void SendImmediate(List<byte[]> orders)
{
var ms = new MemoryStream();
ms.Write(BitConverter.GetBytes((int)0));
ms.Write(BitConverter.GetBytes(0));
foreach (var o in orders)
ms.Write(o);
Send(ms.ToArray());
@@ -196,12 +196,12 @@ namespace OpenRA.Network
try
{
var ms = new MemoryStream();
ms.Write(BitConverter.GetBytes((int)packet.Length));
ms.Write(BitConverter.GetBytes(packet.Length));
ms.Write(packet);
foreach (var q in queuedSyncPackets)
{
ms.Write(BitConverter.GetBytes((int)q.Length));
ms.Write(BitConverter.GetBytes(q.Length));
ms.Write(q);
base.Send(q);
}

View File

@@ -10,7 +10,6 @@
using System;
using System.IO;
using ICSharpCode.SharpZipLib.Core;
using ICSharpCode.SharpZipLib.GZip;
using MaxMind.GeoIP2;

View File

@@ -10,7 +10,6 @@
using System;
using System.IO;
using System.Linq;
using OpenRA.Network;
namespace OpenRA
@@ -52,14 +51,14 @@ namespace OpenRA
Order(string orderString, Actor subject,
Actor targetActor, CPos targetLocation, string targetString, bool queued, CPos extraLocation, uint extraData)
{
this.OrderString = orderString;
this.Subject = subject;
this.TargetActor = targetActor;
this.TargetLocation = targetLocation;
this.TargetString = targetString;
this.Queued = queued;
this.ExtraLocation = extraLocation;
this.ExtraData = extraData;
OrderString = orderString;
Subject = subject;
TargetActor = targetActor;
TargetLocation = targetLocation;
TargetString = targetString;
Queued = queued;
ExtraLocation = extraLocation;
ExtraData = extraData;
}
public static Order Deserialize(World world, BinaryReader r)

View File

@@ -9,7 +9,6 @@
#endregion
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using OpenRA.FileFormats;
@@ -64,7 +63,7 @@ namespace OpenRA.Network
}
file.Write(initialContent);
this.writer = new BinaryWriter(file);
writer = new BinaryWriter(file);
}
public void Receive(int clientID, byte[] data)

View File

@@ -9,7 +9,6 @@
#endregion
using System.Collections.Generic;
using OpenRA.Graphics;
namespace OpenRA.Orders
{

View File

@@ -167,11 +167,11 @@ namespace OpenRA.Orders
public UnitOrderResult(Actor actor, IOrderTargeter order, IIssueOrder trait, string cursor, Target target)
{
this.Actor = actor;
this.Order = order;
this.Trait = trait;
this.Cursor = cursor;
this.Target = target;
Actor = actor;
Order = order;
Trait = trait;
Cursor = cursor;
Target = target;
}
}
}

View File

@@ -18,7 +18,7 @@ namespace OpenRA
public struct int2 : IEquatable<int2>
{
public readonly int X, Y;
public int2(int x, int y) { this.X = x; this.Y = y; }
public int2(int x, int y) { X = x; Y = y; }
public int2(Point p) { X = p.X; Y = p.Y; }
public int2(Size p) { X = p.Width; Y = p.Height; }
@@ -66,7 +66,7 @@ namespace OpenRA
// Change endianness of a uint32
public static uint Swap(uint orig)
{
return (uint)((orig & 0xff000000) >> 24) | ((orig & 0x00ff0000) >> 8) | ((orig & 0x0000ff00) << 8) | ((orig & 0x000000ff) << 24);
return ((orig & 0xff000000) >> 24) | ((orig & 0x00ff0000) >> 8) | ((orig & 0x0000ff00) << 8) | ((orig & 0x000000ff) << 24);
}
public static int Lerp(int a, int b, int mul, int div)

View File

@@ -95,7 +95,7 @@ namespace OpenRA
if (Fonts != null)
foreach (var font in Fonts.Values)
font.Dispose();
using (new Support.PerfTimer("SpriteFonts"))
using (new PerfTimer("SpriteFonts"))
{
if (fontSheetBuilder != null)
fontSheetBuilder.Dispose();

View File

@@ -9,7 +9,6 @@
#endregion
using System;
using System.Collections.Generic;
using System.Linq;
namespace OpenRA.Scripting

View File

@@ -86,8 +86,8 @@ namespace OpenRA.Scripting
public ScriptGlobal(ScriptContext context)
: base(context)
{
// The 'this.' resolves the actual (subclass) type
var type = this.GetType();
// GetType resolves the actual (subclass) type
var type = GetType();
var names = type.GetCustomAttributes<ScriptGlobalAttribute>(true);
if (names.Length != 1)
throw new InvalidOperationException("[ScriptGlobal] attribute not found for global table '{0}'".F(type));

View File

@@ -9,7 +9,6 @@
#endregion
using System;
using System.Collections;
using Eluant;
namespace OpenRA.Scripting
@@ -145,16 +144,16 @@ namespace OpenRA.Scripting
return LuaNil.Instance;
if (obj is double)
return (LuaValue)(double)obj;
return (double)obj;
if (obj is int)
return (LuaValue)(int)obj;
return (int)obj;
if (obj is bool)
return (LuaValue)(bool)obj;
return (bool)obj;
if (obj is string)
return (LuaValue)(string)obj;
return (string)obj;
if (obj is IScriptBindable)
{

View File

@@ -29,7 +29,7 @@ namespace OpenRA
if (args == null)
return;
foreach (var f in this.GetType().GetFields())
foreach (var f in GetType().GetFields())
if (args.Contains("Launch" + "." + f.Name))
FieldLoader.LoadField(this, f.Name, args.GetValue("Launch" + "." + f.Name, ""));
}

View File

@@ -8,9 +8,6 @@
*/
#endregion
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using OpenRA.Primitives;

View File

@@ -8,11 +8,8 @@
*/
#endregion
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using OpenRA.Primitives;
namespace OpenRA.Support
{

View File

@@ -9,10 +9,7 @@
#endregion
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using OpenRA.Primitives;
namespace OpenRA.Support
{

View File

@@ -38,11 +38,11 @@ namespace OpenRA
{ typeof(int2), ((Func<int2, int>)HashInt2).Method },
{ typeof(CPos), ((Func<CPos, int>)HashCPos).Method },
{ typeof(CVec), ((Func<CVec, int>)HashCVec).Method },
{ typeof(WDist), ((Func<WDist, int>)Hash<WDist>).Method },
{ typeof(WPos), ((Func<WPos, int>)Hash<WPos>).Method },
{ typeof(WVec), ((Func<WVec, int>)Hash<WVec>).Method },
{ typeof(WAngle), ((Func<WAngle, int>)Hash<WAngle>).Method },
{ typeof(WRot), ((Func<WRot, int>)Hash<WRot>).Method },
{ typeof(WDist), ((Func<WDist, int>)Hash).Method },
{ typeof(WPos), ((Func<WPos, int>)Hash).Method },
{ typeof(WVec), ((Func<WVec, int>)Hash).Method },
{ typeof(WAngle), ((Func<WAngle, int>)Hash).Method },
{ typeof(WRot), ((Func<WRot, int>)Hash).Method },
{ typeof(TypeDictionary), ((Func<TypeDictionary, int>)HashTDict).Method },
{ typeof(Actor), ((Func<Actor, int>)HashActor).Method },
{ typeof(Player), ((Func<Player, int>)HashPlayer).Method },
@@ -152,7 +152,7 @@ namespace OpenRA
return (int)(t.FrozenActor.Actor.ActorID << 16) * 0x567;
case TargetType.Terrain:
return Hash<WPos>(t.CenterPosition);
return Hash(t.CenterPosition);
default:
case TargetType.Invalid:

View File

@@ -8,7 +8,6 @@
*/
#endregion
using System.Collections.Generic;
using OpenRA.Graphics;
namespace OpenRA.Traits

View File

@@ -8,7 +8,6 @@
*/
#endregion
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using OpenRA.Graphics;

View File

@@ -9,7 +9,6 @@
#endregion
using System.Collections.Generic;
using System.Linq;
namespace OpenRA.Traits
{

View File

@@ -43,7 +43,7 @@ namespace OpenRA.Traits
public ResourceType(ResourceTypeInfo info, World world)
{
this.Info = info;
Info = info;
Variants = new Dictionary<string, Sprite[]>();
foreach (var v in info.Variants)
{

View File

@@ -8,8 +8,6 @@
*/
#endregion
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using OpenRA.Traits;

View File

@@ -23,7 +23,7 @@ namespace OpenRA
public struct WDist : IComparable, IComparable<WDist>, IEquatable<WDist>, IScriptBindable, ILuaAdditionBinding, ILuaSubtractionBinding, ILuaEqualityBinding, ILuaTableBinding
{
public readonly int Length;
public long LengthSquared { get { return (long)Length * (long)Length; } }
public long LengthSquared { get { return (long)Length * Length; } }
public WDist(int r) { Length = r; }
public static readonly WDist Zero = new WDist(0);
@@ -57,7 +57,7 @@ namespace OpenRA
public static bool TryParse(string s, out WDist result)
{
result = WDist.Zero;
result = Zero;
if (string.IsNullOrEmpty(s))
return false;
@@ -115,7 +115,7 @@ namespace OpenRA
{
WDist a;
WDist b;
if (!left.TryGetClrValue<WDist>(out a) || !right.TryGetClrValue<WDist>(out b))
if (!left.TryGetClrValue(out a) || !right.TryGetClrValue(out b))
throw new LuaException("Attempted to call WDist.Add(WDist, WDist) with invalid arguments.");
return new LuaCustomClrObject(a + b);
@@ -125,7 +125,7 @@ namespace OpenRA
{
WDist a;
WDist b;
if (!left.TryGetClrValue<WDist>(out a) || !right.TryGetClrValue<WDist>(out b))
if (!left.TryGetClrValue(out a) || !right.TryGetClrValue(out b))
throw new LuaException("Attempted to call WDist.Subtract(WDist, WDist) with invalid arguments.");
return new LuaCustomClrObject(a - b);
@@ -135,7 +135,7 @@ namespace OpenRA
{
WDist a;
WDist b;
if (!left.TryGetClrValue<WDist>(out a) || !right.TryGetClrValue<WDist>(out b))
if (!left.TryGetClrValue(out a) || !right.TryGetClrValue(out b))
throw new LuaException("Attempted to call WDist.Equals(WDist, WDist) with invalid arguments.");
return a == b;

View File

@@ -81,7 +81,7 @@ namespace OpenRA
{
WPos a;
WVec b;
if (!left.TryGetClrValue<WPos>(out a) || !right.TryGetClrValue<WVec>(out b))
if (!left.TryGetClrValue(out a) || !right.TryGetClrValue(out b))
throw new LuaException("Attempted to call WPos.Add(WPos, WVec) with invalid arguments ({0}, {1})".F(left.WrappedClrType().Name, right.WrappedClrType().Name));
return new LuaCustomClrObject(a + b);
@@ -91,19 +91,19 @@ namespace OpenRA
{
WPos a;
var rightType = right.WrappedClrType();
if (!left.TryGetClrValue<WPos>(out a))
if (!left.TryGetClrValue(out a))
throw new LuaException("Attempted to call WPos.Subtract(WPos, WVec) with invalid arguments ({0}, {1})".F(left.WrappedClrType().Name, rightType));
if (rightType == typeof(WPos))
{
WPos b;
right.TryGetClrValue<WPos>(out b);
right.TryGetClrValue(out b);
return new LuaCustomClrObject(a - b);
}
else if (rightType == typeof(WVec))
{
WVec b;
right.TryGetClrValue<WVec>(out b);
right.TryGetClrValue(out b);
return new LuaCustomClrObject(a - b);
}
@@ -113,7 +113,7 @@ namespace OpenRA
public LuaValue Equals(LuaRuntime runtime, LuaValue left, LuaValue right)
{
WPos a, b;
if (!left.TryGetClrValue<WPos>(out a) || !right.TryGetClrValue<WPos>(out b))
if (!left.TryGetClrValue(out a) || !right.TryGetClrValue(out b))
return false;
return a == b;

View File

@@ -82,7 +82,7 @@ namespace OpenRA
// Add an additional quadratic variation to height
// Uses fp to avoid integer overflow
var offset = (int)((float)((float)(b - a).Length * pitch.Tan() * mul * (div - mul)) / (float)(1024 * div * div));
var offset = (int)((float)(b - a).Length * pitch.Tan() * mul * (div - mul) / (1024 * div * div));
return new WVec(ret.X, ret.Y, ret.Z + offset);
}
@@ -108,7 +108,7 @@ namespace OpenRA
public LuaValue Add(LuaRuntime runtime, LuaValue left, LuaValue right)
{
WVec a, b;
if (!left.TryGetClrValue<WVec>(out a) || !right.TryGetClrValue<WVec>(out b))
if (!left.TryGetClrValue(out a) || !right.TryGetClrValue(out b))
throw new LuaException("Attempted to call WVec.Add(WVec, WVec) with invalid arguments ({0}, {1})".F(left.WrappedClrType().Name, right.WrappedClrType().Name));
return new LuaCustomClrObject(a + b);
@@ -117,7 +117,7 @@ namespace OpenRA
public LuaValue Subtract(LuaRuntime runtime, LuaValue left, LuaValue right)
{
WVec a, b;
if (!left.TryGetClrValue<WVec>(out a) || !right.TryGetClrValue<WVec>(out b))
if (!left.TryGetClrValue(out a) || !right.TryGetClrValue(out b))
throw new LuaException("Attempted to call WVec.Subtract(WVec, WVec) with invalid arguments ({0}, {1})".F(left.WrappedClrType().Name, right.WrappedClrType().Name));
return new LuaCustomClrObject(a - b);
@@ -131,7 +131,7 @@ namespace OpenRA
public LuaValue Equals(LuaRuntime runtime, LuaValue left, LuaValue right)
{
WVec a, b;
if (!left.TryGetClrValue<WVec>(out a) || !right.TryGetClrValue<WVec>(out b))
if (!left.TryGetClrValue(out a) || !right.TryGetClrValue(out b))
return false;
return a == b;

View File

@@ -33,7 +33,7 @@ namespace OpenRA.Widgets
if (hk == Game.Settings.Keys.HideUserInterfaceKey)
{
foreach (var child in this.Children)
foreach (var child in Children)
child.Visible ^= true;
return true;

View File

@@ -503,7 +503,7 @@ namespace OpenRA.Widgets
public Widget GetOrNull(string id)
{
if (this.Id == id)
if (Id == id)
return this;
foreach (var child in Children)

View File

@@ -14,7 +14,6 @@ using System.Linq;
using OpenRA.Effects;
using OpenRA.Graphics;
using OpenRA.Orders;
using OpenRA.Primitives;
using OpenRA.Traits;
namespace OpenRA.Widgets
@@ -37,7 +36,7 @@ namespace OpenRA.Widgets
[ObjectCreator.UseCtor]
public WorldInteractionControllerWidget(World world, WorldRenderer worldRenderer)
{
this.World = world;
World = world;
this.worldRenderer = worldRenderer;
}

View File

@@ -196,7 +196,7 @@ namespace OpenRA
public void LoadComplete(WorldRenderer wr)
{
// ScreenMap must be initialized before anything else
using (new Support.PerfTimer("ScreenMap.WorldLoaded"))
using (new PerfTimer("ScreenMap.WorldLoaded"))
ScreenMap.WorldLoaded(this, wr);
foreach (var wlh in WorldActor.TraitsImplementing<IWorldLoaded>())
@@ -205,7 +205,7 @@ namespace OpenRA
if (wlh == ScreenMap)
continue;
using (new Support.PerfTimer(wlh.GetType().Name + ".WorldLoaded"))
using (new PerfTimer(wlh.GetType().Name + ".WorldLoaded"))
wlh.WorldLoaded(this, wr);
}
@@ -374,7 +374,7 @@ namespace OpenRA
public IEnumerable<Actor> ActorsHavingTrait<T>(Func<T, bool> predicate)
{
return TraitDict.ActorsHavingTrait<T>(predicate);
return TraitDict.ActorsHavingTrait(predicate);
}
public void OnPlayerWinStateChanged(Player player)

View File

@@ -12,7 +12,6 @@ using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using OpenRA.GameRules;
using OpenRA.Support;
using OpenRA.Traits;

View File

@@ -8,9 +8,7 @@
*/
#endregion
using System;
using System.Collections.Generic;
using System.Linq;
using OpenRA.Graphics;
using OpenRA.Mods.Common.Traits;
using OpenRA.Traits;

View File

@@ -9,9 +9,7 @@
#endregion
using System;
using System.Collections.Generic;
using System.Linq;
using OpenRA.Mods.Common.Graphics;
using OpenRA.Mods.Common.Traits;
using OpenRA.Traits;

View File

@@ -160,10 +160,10 @@ namespace OpenRA.Mods.Common.AI
public bool CanAttack(IEnumerable<Actor> ownUnits, IEnumerable<Actor> enemyUnits)
{
var inputValues = new Dictionary<FuzzyVariable, double>();
inputValues.Add(fuzzyEngine.InputByName("OwnHealth"), (double)NormalizedHealth(ownUnits, 100));
inputValues.Add(fuzzyEngine.InputByName("EnemyHealth"), (double)NormalizedHealth(enemyUnits, 100));
inputValues.Add(fuzzyEngine.InputByName("RelativeAttackPower"), (double)RelativePower(ownUnits, enemyUnits));
inputValues.Add(fuzzyEngine.InputByName("RelativeSpeed"), (double)RelativeSpeed(ownUnits, enemyUnits));
inputValues.Add(fuzzyEngine.InputByName("OwnHealth"), NormalizedHealth(ownUnits, 100));
inputValues.Add(fuzzyEngine.InputByName("EnemyHealth"), NormalizedHealth(enemyUnits, 100));
inputValues.Add(fuzzyEngine.InputByName("RelativeAttackPower"), RelativePower(ownUnits, enemyUnits));
inputValues.Add(fuzzyEngine.InputByName("RelativeSpeed"), RelativeSpeed(ownUnits, enemyUnits));
var result = fuzzyEngine.Calculate(inputValues);
var attackChance = result[fuzzyEngine.OutputByName("AttackOrFlee")];

View File

@@ -138,7 +138,7 @@ namespace OpenRA.Mods.Common.AI
[Desc("Should the AI repair its buildings if damaged?")]
public readonly bool ShouldRepairBuildings = true;
string IBotInfo.Name { get { return this.Name; } }
string IBotInfo.Name { get { return Name; } }
[Desc("What units to the AI should build.", "What % of the total army must be this type of unit.")]
public readonly Dictionary<string, float> UnitsToBuild = null;
@@ -245,7 +245,7 @@ namespace OpenRA.Mods.Common.AI
public readonly World World;
public Map Map { get { return World.Map; } }
IBotInfo IBot.Info { get { return this.Info; } }
IBotInfo IBot.Info { get { return Info; } }
int rushTicks;
int assignRolesTicks;

View File

@@ -9,7 +9,6 @@
#endregion
using System.Collections.Generic;
using System.Linq;
using OpenRA.Mods.Common.Traits;
using OpenRA.Traits;

View File

@@ -10,7 +10,6 @@
using System.Linq;
using OpenRA.Activities;
using OpenRA.GameRules;
using OpenRA.Mods.Common.Traits;
using OpenRA.Traits;

View File

@@ -8,8 +8,6 @@
*/
#endregion
using System;
using System.Collections.Generic;
using System.Linq;
using OpenRA.Activities;
using OpenRA.Mods.Common.Traits;

View File

@@ -8,12 +8,9 @@
*/
#endregion
using System;
using System.Collections.Generic;
using System.Linq;
using OpenRA.Activities;
using OpenRA.Mods.Common.Traits;
using OpenRA.Primitives;
using OpenRA.Traits;
namespace OpenRA.Mods.Common.Activities

View File

@@ -8,7 +8,6 @@
*/
#endregion
using System.Collections.Generic;
using System.Linq;
using OpenRA.Effects;
using OpenRA.Mods.Common.Traits;

View File

@@ -37,7 +37,7 @@ namespace OpenRA.Mods.Common.Activities
protected Enter(Actor self, Actor target, EnterBehaviour enterBehaviour, int maxTries = 1, bool targetCenter = false)
{
this.move = self.Trait<IMove>();
move = self.Trait<IMove>();
this.target = Target.FromActor(target);
this.maxTries = maxTries;
this.enterBehaviour = enterBehaviour;

View File

@@ -10,7 +10,6 @@
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using OpenRA.Activities;
using OpenRA.Mods.Common.Pathfinder;
using OpenRA.Mods.Common.Traits;

View File

@@ -9,7 +9,6 @@
#endregion
using System.Collections.Generic;
using System.Linq;
using OpenRA.Activities;
using OpenRA.Traits;

View File

@@ -53,7 +53,7 @@ namespace OpenRA.Mods.Common.Activities
return path;
};
this.destination = destination;
this.nearEnough = WDist.Zero;
nearEnough = WDist.Zero;
}
// HACK: for legacy code
@@ -95,7 +95,7 @@ namespace OpenRA.Mods.Common.Activities
};
this.destination = destination;
this.nearEnough = WDist.Zero;
nearEnough = WDist.Zero;
this.ignoredActor = ignoredActor;
}

View File

@@ -8,7 +8,6 @@
*/
#endregion
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;

View File

@@ -10,8 +10,6 @@
using System.Collections.Generic;
using System.Linq;
using OpenRA.Activities;
using OpenRA.Mods.Common.Traits;
using OpenRA.Traits;
namespace OpenRA.Mods.Common.Activities

View File

@@ -12,7 +12,6 @@ using System.Linq;
using OpenRA.Activities;
using OpenRA.Mods.Common.Traits;
using OpenRA.Primitives;
using OpenRA.Traits;
namespace OpenRA.Mods.Common.Activities
{

View File

@@ -8,10 +8,7 @@
*/
#endregion
using System.Collections.Generic;
using System.Linq;
using OpenRA.Activities;
using OpenRA.Mods.Common.Traits;
using OpenRA.Traits;
namespace OpenRA.Mods.Common.Activities

View File

@@ -8,19 +8,11 @@
*/
#endregion
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using OpenRA.FileFormats;
using OpenRA.Graphics;
using OpenRA.Mods.Common;
using OpenRA.Mods.Common.Graphics;
using OpenRA.Mods.Common.Traits;
using OpenRA.Orders;
using OpenRA.Primitives;
using OpenRA.Traits;
using OpenRA.Widgets;
namespace OpenRA.Mods.Common.Widgets
{

View File

@@ -10,17 +10,9 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using OpenRA.FileFormats;
using OpenRA.Graphics;
using OpenRA.Mods.Common;
using OpenRA.Mods.Common.Graphics;
using OpenRA.Mods.Common.Traits;
using OpenRA.Orders;
using OpenRA.Primitives;
using OpenRA.Traits;
using OpenRA.Widgets;
namespace OpenRA.Mods.Common.Widgets
{

View File

@@ -10,17 +10,10 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using OpenRA.FileFormats;
using OpenRA.Graphics;
using OpenRA.Mods.Common;
using OpenRA.Mods.Common.Graphics;
using OpenRA.Mods.Common.Traits;
using OpenRA.Orders;
using OpenRA.Primitives;
using OpenRA.Traits;
using OpenRA.Widgets;
namespace OpenRA.Mods.Common.Widgets
{

View File

@@ -8,19 +8,9 @@
*/
#endregion
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using OpenRA.FileFormats;
using OpenRA.Graphics;
using OpenRA.Mods.Common;
using OpenRA.Mods.Common.Graphics;
using OpenRA.Mods.Common.Traits;
using OpenRA.Orders;
using OpenRA.Primitives;
using OpenRA.Traits;
using OpenRA.Widgets;
namespace OpenRA.Mods.Common.Widgets
{

View File

@@ -8,19 +8,9 @@
*/
#endregion
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using OpenRA.FileFormats;
using OpenRA.Graphics;
using OpenRA.Mods.Common;
using OpenRA.Mods.Common.Graphics;
using OpenRA.Mods.Common.Traits;
using OpenRA.Orders;
using OpenRA.Primitives;
using OpenRA.Traits;
using OpenRA.Widgets;
namespace OpenRA.Mods.Common.Widgets
{

View File

@@ -11,7 +11,6 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using OpenRA.Effects;
using OpenRA.GameRules;
using OpenRA.Graphics;

View File

@@ -11,7 +11,6 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using OpenRA.Effects;
using OpenRA.GameRules;
using OpenRA.Graphics;
@@ -100,7 +99,7 @@ namespace OpenRA.Mods.Common.Effects
{
this.info = info;
this.args = args;
this.pos = args.Source;
pos = args.Source;
var world = args.SourceActor.World;

View File

@@ -29,11 +29,11 @@ namespace OpenRA.Mods.Common.Effects
public FloatingText(WPos pos, Color color, string text, int duration)
{
this.font = Game.Renderer.Fonts["TinyBold"];
font = Game.Renderer.Fonts["TinyBold"];
this.pos = pos;
this.color = color;
this.text = text;
this.remaining = duration;
remaining = duration;
}
public void Tick(World world)

View File

@@ -68,10 +68,10 @@ namespace OpenRA.Mods.Common.Effects
this.args = args;
this.info = info;
this.color = color;
this.target = args.PassiveTarget;
target = args.PassiveTarget;
if (!string.IsNullOrEmpty(info.HitAnim))
this.hitanim = new Animation(args.SourceActor.World, info.HitAnim);
hitanim = new Animation(args.SourceActor.World, info.HitAnim);
}
public void Tick(World world)

View File

@@ -40,7 +40,7 @@ namespace OpenRA.Mods.Common.Effects
this.firedBy = firedBy;
this.weapon = weapon;
this.delay = delay;
this.turn = delay / 2;
turn = delay / 2;
this.flashType = flashType;
var offset = new WVec(WDist.Zero, WDist.Zero, velocity * turn);

View File

@@ -122,25 +122,25 @@ namespace OpenRA.Mods.Common.Graphics
try
{
Start = LoadField<int>(d, "Start", 0);
ShadowStart = LoadField<int>(d, "ShadowStart", -1);
ShadowZOffset = LoadField<WDist>(d, "ShadowZOffset", DefaultShadowSpriteZOffset).Length;
ZOffset = LoadField<WDist>(d, "ZOffset", WDist.Zero).Length;
Tick = LoadField<int>(d, "Tick", 40);
transpose = LoadField<bool>(d, "Transpose", false);
Start = LoadField(d, "Start", 0);
ShadowStart = LoadField(d, "ShadowStart", -1);
ShadowZOffset = LoadField(d, "ShadowZOffset", DefaultShadowSpriteZOffset).Length;
ZOffset = LoadField(d, "ZOffset", WDist.Zero).Length;
Tick = LoadField(d, "Tick", 40);
transpose = LoadField(d, "Transpose", false);
Frames = LoadField<int[]>(d, "Frames", null);
var flipX = LoadField<bool>(d, "FlipX", false);
var flipY = LoadField<bool>(d, "FlipY", false);
var flipX = LoadField(d, "FlipX", false);
var flipY = LoadField(d, "FlipY", false);
Facings = LoadField<int>(d, "Facings", 1);
Facings = LoadField(d, "Facings", 1);
if (Facings < 0)
{
reverseFacings = true;
Facings = -Facings;
}
var offset = LoadField<float2>(d, "Offset", float2.Zero);
var blendMode = LoadField<BlendMode>(d, "BlendMode", BlendMode.Alpha);
var offset = LoadField(d, "Offset", float2.Zero);
var blendMode = LoadField(d, "BlendMode", BlendMode.Alpha);
MiniYaml combine;
if (d.TryGetValue("Combine", out combine))
@@ -151,10 +151,10 @@ namespace OpenRA.Mods.Common.Graphics
var sd = sub.Value.ToDictionary();
// Allow per-sprite offset, start, and length
var subStart = LoadField<int>(sd, "Start", 0);
var subOffset = LoadField<float2>(sd, "Offset", float2.Zero);
var subFlipX = LoadField<bool>(sd, "FlipX", false);
var subFlipY = LoadField<bool>(sd, "FlipY", false);
var subStart = LoadField(sd, "Start", 0);
var subOffset = LoadField(sd, "Offset", float2.Zero);
var subFlipX = LoadField(sd, "FlipX", false);
var subFlipY = LoadField(sd, "FlipY", false);
var subSrc = GetSpriteSrc(modData, tileSet, sequence, animation, sub.Key, sd);
var subSprites = cache[subSrc].Select(
@@ -165,7 +165,7 @@ namespace OpenRA.Mods.Common.Graphics
if (sd.TryGetValue("Length", out subLengthYaml) && subLengthYaml.Value == "*")
subLength = subSprites.Count() - subStart;
else
subLength = LoadField<int>(sd, "Length", 1);
subLength = LoadField(sd, "Length", 1);
combined = combined.Concat(subSprites.Skip(subStart).Take(subLength));
}
@@ -185,17 +185,17 @@ namespace OpenRA.Mods.Common.Graphics
if (d.TryGetValue("Length", out length) && length.Value == "*")
Length = sprites.Length - Start;
else
Length = LoadField<int>(d, "Length", 1);
Length = LoadField(d, "Length", 1);
// Plays the animation forwards, and then in reverse
if (LoadField<bool>(d, "Reverses", false))
if (LoadField(d, "Reverses", false))
{
var frames = Frames ?? Exts.MakeArray(Length, i => Start + i);
Frames = frames.Concat(frames.Skip(1).Take(frames.Length - 2).Reverse()).ToArray();
Length = 2 * Length - 2;
}
Stride = LoadField<int>(d, "Stride", Length);
Stride = LoadField(d, "Stride", Length);
if (Length > Stride)
throw new InvalidOperationException(

View File

@@ -30,7 +30,7 @@ namespace OpenRA.Mods.Common.Graphics
this.centerPosition = centerPosition;
this.radius = radius;
this.zOffset = zOffset;
this.trailCount = lineTrails;
trailCount = lineTrails;
this.trailSeparation = trailSeparation;
this.trailAngle = trailAngle;
this.color = color;

View File

@@ -55,10 +55,10 @@ namespace OpenRA.Mods.Common.Graphics
{
var wcr = Game.Renderer.WorldRgbaColorRenderer;
var offset = new WVec(radius.Length, 0, 0);
for (var i = 0; i < RangeCircleRenderable.RangeCircleSegments; i++)
for (var i = 0; i < RangeCircleSegments; i++)
{
var a = wr.ScreenPosition(centerPosition + offset.Rotate(RangeCircleRenderable.RangeCircleStartRotations[i]));
var b = wr.ScreenPosition(centerPosition + offset.Rotate(RangeCircleRenderable.RangeCircleEndRotations[i]));
var a = wr.ScreenPosition(centerPosition + offset.Rotate(RangeCircleStartRotations[i]));
var b = wr.ScreenPosition(centerPosition + offset.Rotate(RangeCircleEndRotations[i]));
if (contrastWidth > 0)
wcr.DrawLine(a, b, contrastWidth / wr.Viewport.Zoom, contrastColor);

View File

@@ -10,7 +10,6 @@
using System.Drawing;
using OpenRA.Graphics;
using OpenRA.Traits;
namespace OpenRA.Mods.Common.Graphics
{

View File

@@ -8,10 +8,8 @@
*/
#endregion
using System;
using System.Collections.Generic;
using OpenRA.Graphics;
using OpenRA.Primitives;
namespace OpenRA.Mods.Common.Graphics
{

Some files were not shown because too many files have changed in this diff Show More