Fix StyleCop warnings in OpenRA.Game

This commit is contained in:
Hellhake
2015-01-01 23:04:18 +01:00
parent e9989496c4
commit 5a97a4b63b
119 changed files with 547 additions and 529 deletions

View File

@@ -15,6 +15,7 @@ namespace OpenRA.Graphics
{
public class Animation
{
readonly int defaultTick = 40; // 25 fps == 40 ms
public Sequence CurrentSequence { get; private set; }
public bool IsDecoration = false;
public Func<bool> Paused;
@@ -26,7 +27,6 @@ namespace OpenRA.Graphics
string name;
readonly int defaultTick = 40; // 25 fps == 40 ms
bool tickAlways;
public string Name { get { return name; } }
@@ -43,7 +43,7 @@ namespace OpenRA.Graphics
{
this.sequenceProvider = sequenceProvider;
this.name = name.ToLowerInvariant();
this.tickFunc = () => {};
this.tickFunc = () => { };
this.facingFunc = facingFunc;
}

View File

@@ -50,5 +50,4 @@ namespace OpenRA.Graphics
return new AnimationWithOffset(a, null, null, null, null);
}
}
}
}

View File

@@ -38,6 +38,7 @@ namespace OpenRA.Graphics
{
return lineWidth;
}
set
{
if (LineWidth != value)

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, this.GetType().GetField("rect")), root);
}
}
}

View File

@@ -23,6 +23,7 @@ namespace OpenRA.Graphics
uint this[int index] { get; }
void CopyToArray(Array destination, int destinationOffset);
}
public interface IPaletteRemap { Color GetRemappedColor(Color original, int index); }
public static class Palette

View File

@@ -87,13 +87,13 @@ namespace OpenRA.Graphics
float2 ScreenPosition(WorldRenderer wr)
{
return wr.ScreenPxPosition(pos) + wr.ScreenPxOffset(offset) - (0.5f*scale*sprite.size).ToInt2();
return wr.ScreenPxPosition(pos) + wr.ScreenPxOffset(offset) - (0.5f * scale * sprite.size).ToInt2();
}
public void BeforeRender(WorldRenderer wr) {}
public void BeforeRender(WorldRenderer wr) { }
public void Render(WorldRenderer wr)
{
Game.Renderer.WorldSpriteRenderer.DrawSprite(sprite, ScreenPosition(wr), palette, sprite.size*scale);
Game.Renderer.WorldSpriteRenderer.DrawSprite(sprite, ScreenPosition(wr), palette, sprite.size * scale);
}
public void RenderDebugGeometry(WorldRenderer wr)

View File

@@ -177,6 +177,7 @@ namespace OpenRA.Graphics
{
return currentBatchRenderer;
}
set
{
if (currentBatchRenderer == value)

View File

@@ -135,7 +135,7 @@ namespace OpenRA.Graphics
}
}
public void BeforeRender(WorldRenderer wr) {}
public void BeforeRender(WorldRenderer wr) { }
public void Render(WorldRenderer wr)
{
if (!actor.IsInWorld || actor.IsDead)
@@ -154,6 +154,6 @@ namespace OpenRA.Graphics
DrawExtraBars(wr, xy, Xy);
}
public void RenderDebugGeometry(WorldRenderer wr) {}
public void RenderDebugGeometry(WorldRenderer wr) { }
}
}

View File

@@ -45,7 +45,7 @@ namespace OpenRA.Graphics
public IRenderable OffsetBy(WVec vec) { return new SelectionBoxRenderable(pos + vec, bounds, scale, color); }
public IRenderable AsDecoration() { return this; }
public void BeforeRender(WorldRenderer wr) {}
public void BeforeRender(WorldRenderer wr) { }
public void Render(WorldRenderer wr)
{
var screenPos = wr.ScreenPxPosition(pos);
@@ -68,6 +68,6 @@ namespace OpenRA.Graphics
wlr.DrawLine(br, br - v, color, color);
}
public void RenderDebugGeometry(WorldRenderer wr) {}
public void RenderDebugGeometry(WorldRenderer wr) { }
}
}

View File

@@ -30,6 +30,7 @@ namespace OpenRA.Graphics
CreateBuffer();
return data;
}
public bool Buffered { get { return data != null || texture == null; } }
public Sheet(Size size)
@@ -83,7 +84,6 @@ namespace OpenRA.Graphics
if (data != null)
{
if (dirty)
{
texture.SetData(data, Size.Width, Size.Height);

View File

@@ -99,4 +99,3 @@ namespace OpenRA.Graphics
}
}
}

View File

@@ -24,10 +24,10 @@ namespace OpenRA.Graphics
public readonly float top, left, bottom, right;
public Sprite(Sheet sheet, Rectangle bounds, TextureChannel channel)
: this(sheet, bounds, float2.Zero, channel, BlendMode.Alpha) {}
: this(sheet, bounds, float2.Zero, channel, BlendMode.Alpha) { }
public Sprite(Sheet sheet, Rectangle bounds, TextureChannel channel, BlendMode blendMode)
: this(sheet, bounds, float2.Zero, channel, blendMode) {}
: this(sheet, bounds, float2.Zero, channel, blendMode) { }
public Sprite(Sheet sheet, Rectangle bounds, float2 offset, TextureChannel channel, BlendMode blendMode)
{
@@ -40,10 +40,10 @@ namespace OpenRA.Graphics
this.fractionalOffset = offset / this.size;
left = (float)(bounds.Left) / sheet.Size.Width;
top = (float)(bounds.Top) / sheet.Size.Height;
right = (float)(bounds.Right) / sheet.Size.Width;
bottom = (float)(bounds.Bottom) / sheet.Size.Height;
left = (float)bounds.Left / sheet.Size.Width;
top = (float)bounds.Top / sheet.Size.Height;
right = (float)bounds.Right / sheet.Size.Width;
bottom = (float)bounds.Bottom / sheet.Size.Height;
}
}

View File

@@ -136,7 +136,6 @@ namespace OpenRA.Graphics
}
}
s.sheet.CommitData();
return g;

View File

@@ -38,6 +38,7 @@ namespace OpenRA.Graphics
public SpriteCache(ISpriteLoader[] loaders, string[] exts, SheetBuilder sheetBuilder)
{
SheetBuilder = sheetBuilder;
// Include extension-less version
exts = exts.Append("").ToArray();
sprites = new Cache<string, Sprite[]>(filename => SpriteLoader.GetSprites(filename, exts, loaders, sheetBuilder));

View File

@@ -39,7 +39,7 @@ namespace OpenRA.Graphics
public IRenderable OffsetBy(WVec vec) { return new TargetLineRenderable(waypoints.Select(w => w + vec), color); }
public IRenderable AsDecoration() { return this; }
public void BeforeRender(WorldRenderer wr) {}
public void BeforeRender(WorldRenderer wr) { }
public void Render(WorldRenderer wr)
{
if (!waypoints.Any())
@@ -57,6 +57,6 @@ namespace OpenRA.Graphics
wr.DrawTargetMarker(color, first);
}
public void RenderDebugGeometry(WorldRenderer wr) {}
public void RenderDebugGeometry(WorldRenderer wr) { }
}
}

View File

@@ -46,7 +46,7 @@ namespace OpenRA.Graphics
public IRenderable OffsetBy(WVec vec) { return this; }
public IRenderable AsDecoration() { return this; }
public void BeforeRender(WorldRenderer wr) {}
public void BeforeRender(WorldRenderer wr) { }
public void Render(WorldRenderer wr)
{
Game.Renderer.SpriteRenderer.DrawSprite(sprite, screenPos, palette, sprite.size * scale);

View File

@@ -17,6 +17,8 @@ namespace OpenRA.Graphics
{
public static class Util
{
// yes, our channel order is nuts.
static readonly int[] channelMasks = { 2, 1, 0, 3 };
static float[] channelSelect = { 0.75f, 0.25f, -0.25f, -0.75f };
public static void FastCreateQuad(Vertex[] vertices, float2 o, Sprite r, int palette, int nv, float2 size)
@@ -38,8 +40,6 @@ namespace OpenRA.Graphics
vertices[nv + 3] = new Vertex(d, r.left, r.bottom, attribP, attribC);
}
static readonly int[] channelMasks = { 2, 1, 0, 3 }; // yes, our channel order is nuts.
public static void FastCopyIntoChannel(Sprite dest, byte[] src) { FastCopyIntoChannel(dest, 0, src); }
public static void FastCopyIntoChannel(Sprite dest, int channelOffset, byte[] src)
{
@@ -58,6 +58,7 @@ namespace OpenRA.Graphics
data[destOffset] = src[srcOffset];
destOffset += 4;
}
destOffset += destSkip;
}
}
@@ -107,9 +108,9 @@ namespace OpenRA.Graphics
for (var i = 0; i < 4; i++)
for (var j = 0; j < 4; j++)
{
mtx[4*i + j] = 0;
mtx[4 * i + j] = 0;
for (var k = 0; k < 4; k++)
mtx[4*i + j] += lhs[4*k + j]*rhs[4*i + k];
mtx[4 * i + j] += lhs[4 * k + j] * rhs[4 * i + k];
}
return mtx;
@@ -122,7 +123,7 @@ namespace OpenRA.Graphics
{
ret[j] = 0;
for (var k = 0; k < 4; k++)
ret[j] += mtx[4*k + j]*vec[k];
ret[j] += mtx[4 * k + j] * vec[k];
}
return ret;
@@ -132,124 +133,124 @@ namespace OpenRA.Graphics
{
var mtx = new float[16];
mtx[0] = m[5]*m[10]*m[15] -
m[5]*m[11]*m[14] -
m[9]*m[6]*m[15] +
m[9]*m[7]*m[14] +
m[13]*m[6]*m[11] -
m[13]*m[7]*m[10];
mtx[0] = m[5] * m[10] * m[15] -
m[5] * m[11] * m[14] -
m[9] * m[6] * m[15] +
m[9] * m[7] * m[14] +
m[13] * m[6] * m[11] -
m[13] * m[7] * m[10];
mtx[4] = -m[4]*m[10]*m[15] +
m[4]*m[11]*m[14] +
m[8]*m[6]*m[15] -
m[8]*m[7]*m[14] -
m[12]*m[6]*m[11] +
m[12]*m[7]*m[10];
mtx[4] = -m[4] * m[10] * m[15] +
m[4] * m[11] * m[14] +
m[8] * m[6] * m[15] -
m[8] * m[7] * m[14] -
m[12] * m[6] * m[11] +
m[12] * m[7] * m[10];
mtx[8] = m[4]*m[9]*m[15] -
m[4]*m[11]*m[13] -
m[8]*m[5]*m[15] +
m[8]*m[7]*m[13] +
m[12]*m[5]*m[11] -
m[12]*m[7]*m[9];
mtx[8] = m[4] * m[9] * m[15] -
m[4] * m[11] * m[13] -
m[8] * m[5] * m[15] +
m[8] * m[7] * m[13] +
m[12] * m[5] * m[11] -
m[12] * m[7] * m[9];
mtx[12] = -m[4]*m[9]*m[14] +
m[4]*m[10]*m[13] +
m[8]*m[5]*m[14] -
m[8]*m[6]*m[13] -
m[12]*m[5]*m[10] +
m[12]*m[6]*m[9];
mtx[12] = -m[4] * m[9] * m[14] +
m[4] * m[10] * m[13] +
m[8] * m[5] * m[14] -
m[8] * m[6] * m[13] -
m[12] * m[5] * m[10] +
m[12] * m[6] * m[9];
mtx[1] = -m[1]*m[10]*m[15] +
m[1]*m[11]*m[14] +
m[9]*m[2]*m[15] -
m[9]*m[3]*m[14] -
m[13]*m[2]*m[11] +
m[13]*m[3]*m[10];
mtx[1] = -m[1] * m[10] * m[15] +
m[1] * m[11] * m[14] +
m[9] * m[2] * m[15] -
m[9] * m[3] * m[14] -
m[13] * m[2] * m[11] +
m[13] * m[3] * m[10];
mtx[5] = m[0]*m[10]*m[15] -
m[0]*m[11]*m[14] -
m[8]*m[2]*m[15] +
m[8]*m[3]*m[14] +
m[12]*m[2]*m[11] -
m[12]*m[3]*m[10];
mtx[5] = m[0] * m[10] * m[15] -
m[0] * m[11] * m[14] -
m[8] * m[2] * m[15] +
m[8] * m[3] * m[14] +
m[12] * m[2] * m[11] -
m[12] * m[3] * m[10];
mtx[9] = -m[0]*m[9]*m[15] +
m[0]*m[11]*m[13] +
m[8]*m[1]*m[15] -
m[8]*m[3]*m[13] -
m[12]*m[1]*m[11] +
m[12]*m[3]*m[9];
mtx[9] = -m[0] * m[9] * m[15] +
m[0] * m[11] * m[13] +
m[8] * m[1] * m[15] -
m[8] * m[3] * m[13] -
m[12] * m[1] * m[11] +
m[12] * m[3] * m[9];
mtx[13] = m[0]*m[9]*m[14] -
m[0]*m[10]*m[13] -
m[8]*m[1]*m[14] +
m[8]*m[2]*m[13] +
m[12]*m[1]*m[10] -
m[12]*m[2]*m[9];
mtx[13] = m[0] * m[9] * m[14] -
m[0] * m[10] * m[13] -
m[8] * m[1] * m[14] +
m[8] * m[2] * m[13] +
m[12] * m[1] * m[10] -
m[12] * m[2] * m[9];
mtx[2] = m[1]*m[6]*m[15] -
m[1]*m[7]*m[14] -
m[5]*m[2]*m[15] +
m[5]*m[3]*m[14] +
m[13]*m[2]*m[7] -
m[13]*m[3]*m[6];
mtx[2] = m[1] * m[6] * m[15] -
m[1] * m[7] * m[14] -
m[5] * m[2] * m[15] +
m[5] * m[3] * m[14] +
m[13] * m[2] * m[7] -
m[13] * m[3] * m[6];
mtx[6] = -m[0]*m[6]*m[15] +
m[0]*m[7]*m[14] +
m[4]*m[2]*m[15] -
m[4]*m[3]*m[14] -
m[12]*m[2]*m[7] +
m[12]*m[3]*m[6];
mtx[6] = -m[0] * m[6] * m[15] +
m[0] * m[7] * m[14] +
m[4] * m[2] * m[15] -
m[4] * m[3] * m[14] -
m[12] * m[2] * m[7] +
m[12] * m[3] * m[6];
mtx[10] = m[0]*m[5]*m[15] -
m[0]*m[7]*m[13] -
m[4]*m[1]*m[15] +
m[4]*m[3]*m[13] +
m[12]*m[1]*m[7] -
m[12]*m[3]*m[5];
mtx[10] = m[0] * m[5] * m[15] -
m[0] * m[7] * m[13] -
m[4] * m[1] * m[15] +
m[4] * m[3] * m[13] +
m[12] * m[1] * m[7] -
m[12] * m[3] * m[5];
mtx[14] = -m[0]*m[5]*m[14] +
m[0]*m[6]*m[13] +
m[4]*m[1]*m[14] -
m[4]*m[2]*m[13] -
m[12]*m[1]*m[6] +
m[12]*m[2]*m[5];
mtx[14] = -m[0] * m[5] * m[14] +
m[0] * m[6] * m[13] +
m[4] * m[1] * m[14] -
m[4] * m[2] * m[13] -
m[12] * m[1] * m[6] +
m[12] * m[2] * m[5];
mtx[3] = -m[1]*m[6]*m[11] +
m[1]*m[7]*m[10] +
m[5]*m[2]*m[11] -
m[5]*m[3]*m[10] -
m[9]*m[2]*m[7] +
m[9]*m[3]*m[6];
mtx[3] = -m[1] * m[6] * m[11] +
m[1] * m[7] * m[10] +
m[5] * m[2] * m[11] -
m[5] * m[3] * m[10] -
m[9] * m[2] * m[7] +
m[9] * m[3] * m[6];
mtx[7] = m[0]*m[6]*m[11] -
m[0]*m[7]*m[10] -
m[4]*m[2]*m[11] +
m[4]*m[3]*m[10] +
m[8]*m[2]*m[7] -
m[8]*m[3]*m[6];
mtx[7] = m[0] * m[6] * m[11] -
m[0] * m[7] * m[10] -
m[4] * m[2] * m[11] +
m[4] * m[3] * m[10] +
m[8] * m[2] * m[7] -
m[8] * m[3] * m[6];
mtx[11] = -m[0]*m[5]*m[11] +
m[0]*m[7]*m[9] +
m[4]*m[1]*m[11] -
m[4]*m[3]*m[9] -
m[8]*m[1]*m[7] +
m[8]*m[3]*m[5];
mtx[11] = -m[0] * m[5] * m[11] +
m[0] * m[7] * m[9] +
m[4] * m[1] * m[11] -
m[4] * m[3] * m[9] -
m[8] * m[1] * m[7] +
m[8] * m[3] * m[5];
mtx[15] = m[0]*m[5]*m[10] -
m[0]*m[6]*m[9] -
m[4]*m[1]*m[10] +
m[4]*m[2]*m[9] +
m[8]*m[1]*m[6] -
m[8]*m[2]*m[5];
mtx[15] = m[0] * m[5] * m[10] -
m[0] * m[6] * m[9] -
m[4] * m[1] * m[10] +
m[4] * m[2] * m[9] +
m[8] * m[1] * m[6] -
m[8] * m[2] * m[5];
var det = m[0]*mtx[0] + m[1]*mtx[4] + m[2]*mtx[8] + m[3]*mtx[12];
var det = m[0] * mtx[0] + m[1] * mtx[4] + m[2] * mtx[8] + m[3] * mtx[12];
if (det == 0)
return null;
for (var i = 0; i < 16; i++)
mtx[i] *= 1/det;
mtx[i] *= 1 / det;
return mtx;
}
@@ -258,33 +259,33 @@ namespace OpenRA.Graphics
{
var fmtx = new float[16];
for (var i = 0; i < 16; i++)
fmtx[i] = imtx[i]*1f / imtx[15];
fmtx[i] = imtx[i] * 1f / imtx[15];
return fmtx;
}
public static float[] MatrixAABBMultiply(float[] mtx, float[] bounds)
{
// Corner offsets
var ix = new uint[] {0,0,0,0,3,3,3,3};
var iy = new uint[] {1,1,4,4,1,1,4,4};
var iz = new uint[] {2,5,2,5,2,5,2,5};
var ix = new uint[] { 0, 0, 0, 0, 3, 3, 3, 3 };
var iy = new uint[] { 1, 1, 4, 4, 1, 1, 4, 4 };
var iz = new uint[] { 2, 5, 2, 5, 2, 5, 2, 5 };
// Vectors to opposing corner
var ret = new float[] {float.MaxValue, float.MaxValue, float.MaxValue,
float.MinValue, float.MinValue, float.MinValue};
var ret = new float[] { float.MaxValue, float.MaxValue, float.MaxValue,
float.MinValue, float.MinValue, float.MinValue };
// Transform vectors and find new bounding box
for (var i = 0; i < 8; i++)
{
var vec = new float[] {bounds[ix[i]], bounds[iy[i]], bounds[iz[i]], 1};
var vec = new float[] { bounds[ix[i]], bounds[iy[i]], bounds[iz[i]], 1 };
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]);
ret[2] = Math.Min(ret[2], tvec[2]/tvec[3]);
ret[3] = Math.Max(ret[3], tvec[0]/tvec[3]);
ret[4] = Math.Max(ret[4], tvec[1]/tvec[3]);
ret[5] = Math.Max(ret[5], tvec[2]/tvec[3]);
ret[0] = Math.Min(ret[0], tvec[0] / tvec[3]);
ret[1] = Math.Min(ret[1], tvec[1] / tvec[3]);
ret[2] = Math.Min(ret[2], tvec[2] / tvec[3]);
ret[3] = Math.Max(ret[3], tvec[0] / tvec[3]);
ret[4] = Math.Max(ret[4], tvec[1] / tvec[3]);
ret[5] = Math.Max(ret[5], tvec[2] / tvec[3]);
}
return ret;

View File

@@ -61,12 +61,12 @@ namespace OpenRA.Graphics
var l = limbData[limb];
var t = new float[16];
Array.Copy(transforms, 16*(Limbs*frame + limb), t, 0, 16);
Array.Copy(transforms, 16 * (Limbs * frame + limb), t, 0, 16);
// Fix limb position
t[12] *= l.Scale*(l.Bounds[3] - l.Bounds[0]) / l.Size[0];
t[13] *= l.Scale*(l.Bounds[4] - l.Bounds[1]) / l.Size[1];
t[14] *= l.Scale*(l.Bounds[5] - l.Bounds[2]) / l.Size[2];
t[12] *= l.Scale * (l.Bounds[3] - l.Bounds[0]) / l.Size[0];
t[13] *= l.Scale * (l.Bounds[4] - l.Bounds[1]) / l.Size[1];
t[14] *= l.Scale * (l.Bounds[5] - l.Bounds[2]) / l.Size[2];
// Center, flip and scale
t = Util.MatrixMultiply(t, Util.TranslationMatrix(l.Bounds[0], l.Bounds[1], l.Bounds[2]));
@@ -84,8 +84,8 @@ namespace OpenRA.Graphics
{
get
{
return limbData.Select(a => a.Size.Select(b => a.Scale*b).ToArray())
.Aggregate((a,b) => new float[]
return limbData.Select(a => a.Size.Select(b => a.Scale * b).ToArray())
.Aggregate((a, b) => new float[]
{
Math.Max(a[0], b[0]),
Math.Max(a[1], b[1]),
@@ -96,8 +96,8 @@ namespace OpenRA.Graphics
public float[] Bounds(uint frame)
{
var ret = new float[] {float.MaxValue,float.MaxValue,float.MaxValue,
float.MinValue,float.MinValue,float.MinValue};
var ret = new float[] { float.MaxValue, float.MaxValue, float.MaxValue,
float.MinValue, float.MinValue, float.MinValue };
for (uint j = 0; j < Limbs; j++)
{
@@ -115,7 +115,7 @@ namespace OpenRA.Graphics
for (var i = 0; i < 3; i++)
{
ret[i] = Math.Min(ret[i], bb[i]);
ret[i+3] = Math.Max(ret[i+3], bb[i+3]);
ret[i + 3] = Math.Max(ret[i + 3], bb[i + 3]);
}
}

View File

@@ -30,5 +30,4 @@ namespace OpenRA.Graphics
FrameFunc = frame;
}
}
}
}

View File

@@ -93,7 +93,7 @@ namespace OpenRA.Graphics
return new Vertex[4]
{
new Vertex(coord(0, 0), s.left, s.top, channelP, channelC),
new Vertex(coord(su, 0),s.right, s.top, channelP, channelC),
new Vertex(coord(su, 0), s.right, s.top, channelP, channelC),
new Vertex(coord(su, sv), s.right, s.bottom, channelP, channelC),
new Vertex(coord(0, sv), s.left, s.bottom, channelP, channelC)
};

View File

@@ -39,7 +39,7 @@ namespace OpenRA.Graphics
var hva = unit;
if (info.Value != null)
{
var fields = info.Value.Split(new char[] {','}, StringSplitOptions.RemoveEmptyEntries);
var fields = info.Value.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
if (fields.Length >= 1)
vxl = hva = fields[0].Trim();
@@ -58,7 +58,7 @@ namespace OpenRA.Graphics
var seq = sequences.ToDictionary(my => LoadVoxel(unit, my));
units.Add(unit, seq);
}
catch (FileNotFoundException) {} // Do nothing; we can crash later if we actually wanted art
catch (FileNotFoundException) { } // Do nothing; we can crash later if we actually wanted art
}
public static Voxel GetVoxel(string unitName, string voxelName)

View File

@@ -92,7 +92,7 @@ namespace OpenRA.Graphics
if (world.OrderGenerator != null)
effectRenderables = effectRenderables.Concat(world.OrderGenerator.RenderAfterWorld(this, world));
// Iterating via foreach() copies the structs, so enumerate by index
// Iterating via foreach copies the structs, so enumerate by index
var renderables = worldRenderables.Concat(effectRenderables).ToList();
Game.Renderer.WorldVoxelRenderer.BeginFrame();