StyleCop clean OpenRA.Game

This commit is contained in:
Matthias Mailänder
2015-01-02 15:11:36 +01:00
parent 9dd607c846
commit 44cd174a8d
61 changed files with 628 additions and 581 deletions

View File

@@ -101,12 +101,12 @@ namespace OpenRA.Graphics
// Cached sheet
Sheet sheet;
if (cachedSheets.ContainsKey(mi.src))
sheet = cachedSheets[mi.src];
if (cachedSheets.ContainsKey(mi.Src))
sheet = cachedSheets[mi.Src];
else
{
sheet = new Sheet(mi.src);
cachedSheets.Add(mi.src, sheet);
sheet = new Sheet(mi.Src);
cachedSheets.Add(mi.Src, sheet);
}
// Cache the sprite

View File

@@ -15,15 +15,15 @@ namespace OpenRA.Graphics
{
class MappedImage
{
public readonly Rectangle rect = Rectangle.Empty;
public readonly string src;
readonly Rectangle rect = Rectangle.Empty;
public readonly string Src;
public MappedImage(string defaultSrc, MiniYaml info)
{
FieldLoader.LoadField(this, "rect", info.Value);
FieldLoader.Load(this, info);
if (src == null)
src = defaultSrc;
if (Src == null)
Src = defaultSrc;
}
public Sprite GetImage(Sheet s)
@@ -34,8 +34,8 @@ namespace OpenRA.Graphics
public MiniYaml Save(string defaultSrc)
{
var root = new List<MiniYamlNode>();
if (defaultSrc != src)
root.Add(new MiniYamlNode("src", src));
if (defaultSrc != Src)
root.Add(new MiniYamlNode("Src", Src));
return new MiniYaml(FieldSaver.FormatValue(this, this.GetType().GetField("rect")), root);
}

View File

@@ -41,21 +41,21 @@ namespace OpenRA.Graphics
public IRenderable OffsetBy(WVec vec) { return new SelectionBarsRenderable(pos + vec, actor); }
public IRenderable AsDecoration() { return this; }
void DrawExtraBars(WorldRenderer wr, float2 xy, float2 Xy)
void DrawExtraBars(WorldRenderer wr, float2 start, float2 end)
{
foreach (var extraBar in actor.TraitsImplementing<ISelectionBar>())
{
var value = extraBar.GetValue();
if (value != 0)
{
xy.Y += (int)(4 / wr.Viewport.Zoom);
Xy.Y += (int)(4 / wr.Viewport.Zoom);
DrawSelectionBar(wr, xy, Xy, extraBar.GetValue(), extraBar.GetColor());
start.Y += (int)(4 / wr.Viewport.Zoom);
end.Y += (int)(4 / wr.Viewport.Zoom);
DrawSelectionBar(wr, start, end, extraBar.GetValue(), extraBar.GetColor());
}
}
}
void DrawSelectionBar(WorldRenderer wr, float2 xy, float2 Xy, float value, Color barColor)
void DrawSelectionBar(WorldRenderer wr, float2 start, float2 end, float value, Color barColor)
{
var c = Color.FromArgb(128, 30, 30, 30);
var c2 = Color.FromArgb(128, 10, 10, 10);
@@ -65,15 +65,15 @@ namespace OpenRA.Graphics
var barColor2 = Color.FromArgb(255, barColor.R / 2, barColor.G / 2, barColor.B / 2);
var z = float2.Lerp(xy, Xy, value);
var z = float2.Lerp(start, end, value);
var wlr = Game.Renderer.WorldLineRenderer;
wlr.DrawLine(xy + p, Xy + p, c, c);
wlr.DrawLine(xy + q, Xy + q, c2, c2);
wlr.DrawLine(xy + r, Xy + r, c, c);
wlr.DrawLine(start + p, end + p, c, c);
wlr.DrawLine(start + q, end + q, c2, c2);
wlr.DrawLine(start + r, end + r, c, c);
wlr.DrawLine(xy + p, z + p, barColor2, barColor2);
wlr.DrawLine(xy + q, z + q, barColor, barColor);
wlr.DrawLine(xy + r, z + r, barColor2, barColor2);
wlr.DrawLine(start + p, z + p, barColor2, barColor2);
wlr.DrawLine(start + q, z + q, barColor, barColor);
wlr.DrawLine(start + r, z + r, barColor2, barColor2);
}
Color GetHealthColor(Health health)
@@ -90,7 +90,7 @@ namespace OpenRA.Graphics
health.DamageState == DamageState.Heavy ? Color.Yellow : Color.LimeGreen;
}
void DrawHealthBar(WorldRenderer wr, Health health, float2 xy, float2 Xy)
void DrawHealthBar(WorldRenderer wr, Health health, float2 start, float2 end)
{
if (health == null || health.IsDead)
return;
@@ -108,16 +108,16 @@ namespace OpenRA.Graphics
healthColor.G / 2,
healthColor.B / 2);
var z = float2.Lerp(xy, Xy, (float)health.HP / health.MaxHP);
var z = float2.Lerp(start, end, (float)health.HP / health.MaxHP);
var wlr = Game.Renderer.WorldLineRenderer;
wlr.DrawLine(xy + p, Xy + p, c, c);
wlr.DrawLine(xy + q, Xy + q, c2, c2);
wlr.DrawLine(xy + r, Xy + r, c, c);
wlr.DrawLine(start + p, end + p, c, c);
wlr.DrawLine(start + q, end + q, c2, c2);
wlr.DrawLine(start + r, end + r, c, c);
wlr.DrawLine(xy + p, z + p, healthColor2, healthColor2);
wlr.DrawLine(xy + q, z + q, healthColor, healthColor);
wlr.DrawLine(xy + r, z + r, healthColor2, healthColor2);
wlr.DrawLine(start + p, z + p, healthColor2, healthColor2);
wlr.DrawLine(start + q, z + q, healthColor, healthColor);
wlr.DrawLine(start + r, z + r, healthColor2, healthColor2);
if (health.DisplayHp != health.HP)
{
@@ -127,7 +127,7 @@ namespace OpenRA.Graphics
deltaColor.R / 2,
deltaColor.G / 2,
deltaColor.B / 2);
var zz = float2.Lerp(xy, Xy, (float)health.DisplayHp / health.MaxHP);
var zz = float2.Lerp(start, end, (float)health.DisplayHp / health.MaxHP);
wlr.DrawLine(z + p, zz + p, deltaColor2, deltaColor2);
wlr.DrawLine(z + q, zz + q, deltaColor, deltaColor);
@@ -147,11 +147,11 @@ namespace OpenRA.Graphics
var bounds = actor.Bounds;
bounds.Offset(screenPos.X, screenPos.Y);
var xy = new float2(bounds.Left, bounds.Top);
var Xy = new float2(bounds.Right, bounds.Top);
var start = new float2(bounds.Left, bounds.Top);
var end = new float2(bounds.Right, bounds.Top);
DrawHealthBar(wr, health, xy, Xy);
DrawExtraBars(wr, xy, Xy);
DrawHealthBar(wr, health, start, end);
DrawExtraBars(wr, start, end);
}
public void RenderDebugGeometry(WorldRenderer wr) { }

View File

@@ -15,8 +15,8 @@ namespace OpenRA.Graphics
[StructLayout(LayoutKind.Sequential)]
public struct Vertex
{
public float x, y, z, u, v;
public float p, c;
float x, y, z, u, v;
float p, c;
public Vertex(float2 xy, float u, float v, float p, float c)
{

View File

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