Use expression body syntax

This commit is contained in:
teinarss
2021-02-25 20:52:13 +01:00
committed by Paul Chote
parent 555c43843b
commit 4a1e4f3e16
403 changed files with 1342 additions and 2031 deletions

View File

@@ -49,8 +49,8 @@ namespace OpenRA.Graphics
this.paused = paused;
}
public int CurrentFrame { get { return backwards ? CurrentSequence.Length - frame - 1 : frame; } }
public Sprite Image { get { return CurrentSequence.GetSprite(CurrentFrame, facingFunc()); } }
public int CurrentFrame => backwards ? CurrentSequence.Length - frame - 1 : frame;
public Sprite Image => CurrentSequence.GetSprite(CurrentFrame, facingFunc());
public IRenderable[] Render(WPos pos, WVec offset, int zOffset, PaletteReference palette)
{

View File

@@ -63,7 +63,7 @@ namespace OpenRA.Graphics
class PlaceholderModelCache : IModelCache
{
public IVertexBuffer<Vertex> VertexBuffer { get { throw new NotImplementedException(); } }
public IVertexBuffer<Vertex> VertexBuffer => throw new NotImplementedException();
public void Dispose() { }

View File

@@ -46,12 +46,6 @@ namespace OpenRA.Graphics
xy.Y + (int)(r.Bottom * scale));
}
public bool IsVisible
{
get
{
return DisableFunc == null || !DisableFunc();
}
}
public bool IsVisible => DisableFunc == null || !DisableFunc();
}
}

View File

@@ -44,7 +44,8 @@ namespace OpenRA.Graphics
{
IPalette palette;
public ReadOnlyPalette(IPalette palette) { this.palette = palette; }
public uint this[int index] { get { return palette[index]; } }
public uint this[int index] => palette[index];
public void CopyToArray(Array destination, int destinationOffset)
{
palette.CopyToArray(destination, destinationOffset);
@@ -56,10 +57,7 @@ namespace OpenRA.Graphics
{
readonly uint[] colors = new uint[Palette.Size];
public uint this[int index]
{
get { return colors[index]; }
}
public uint this[int index] => colors[index];
public void CopyToArray(Array destination, int destinationOffset)
{
@@ -126,8 +124,8 @@ namespace OpenRA.Graphics
public uint this[int index]
{
get { return colors[index]; }
set { colors[index] = value; }
get => colors[index];
set => colors[index] = value;
}
public void CopyToArray(Array destination, int destinationOffset)

View File

@@ -18,8 +18,8 @@ namespace OpenRA.Graphics
public readonly string Name;
public IPalette Palette { get; internal set; }
public float TextureIndex { get { return index / hardwarePalette.Height; } }
public float TextureMidIndex { get { return (index + 0.5f) / hardwarePalette.Height; } }
public float TextureIndex => index / hardwarePalette.Height;
public float TextureMidIndex => (index + 0.5f) / hardwarePalette.Height;
public PaletteReference(string name, int index, IPalette palette, HardwarePalette hardwarePalette)
{

View File

@@ -52,7 +52,7 @@ namespace OpenRA.Graphics
readonly string tileSet;
readonly Lazy<Sequences> sequences;
readonly Lazy<SpriteCache> spriteCache;
public SpriteCache SpriteCache { get { return spriteCache.Value; } }
public SpriteCache SpriteCache => spriteCache.Value;
readonly Dictionary<string, UnitSequences> sequenceCache = new Dictionary<string, UnitSequences>();
@@ -80,7 +80,7 @@ namespace OpenRA.Graphics
return seq;
}
public IEnumerable<string> Images { get { return sequences.Value.Keys; } }
public IEnumerable<string> Images => sequences.Value.Keys;
public bool HasSequence(string unitName)
{

View File

@@ -32,7 +32,7 @@ namespace OpenRA.Graphics
return data;
}
public bool Buffered { get { return data != null || texture == null; } }
public bool Buffered => data != null || texture == null;
public Sheet(SheetType type, Size size)
{

View File

@@ -147,9 +147,9 @@ namespace OpenRA.Graphics
return rect;
}
public Sheet Current { get { return current; } }
public TextureChannel CurrentChannel { get { return channel; } }
public IEnumerable<Sheet> AllSheets { get { return sheets; } }
public Sheet Current => current;
public TextureChannel CurrentChannel => channel;
public IEnumerable<Sheet> AllSheets => sheets;
public void Dispose()
{

View File

@@ -164,7 +164,7 @@ namespace OpenRA.Graphics
frames = new Cache<string, ISpriteFrame[]>(filename => FrameLoader.GetFrames(fileSystem, filename, loaders, out _));
}
public ISpriteFrame[] this[string filename] { get { return frames[filename]; } }
public ISpriteFrame[] this[string filename] => frames[filename];
}
public static class FrameLoader

View File

@@ -43,15 +43,15 @@ namespace OpenRA.Graphics
this.alpha = alpha;
}
public WPos Pos { get { return pos + offset; } }
public WVec Offset { get { return offset; } }
public PaletteReference Palette { get { return palette; } }
public int ZOffset { get { return zOffset; } }
public bool IsDecoration { get { return isDecoration; } }
public WPos Pos => pos + offset;
public WVec Offset => offset;
public PaletteReference Palette => palette;
public int ZOffset => zOffset;
public bool IsDecoration => isDecoration;
public float Alpha { get { return alpha; } }
public float3 Tint { get { return tint; } }
public TintModifiers TintModifiers { get { return tintModifiers; } }
public float Alpha => alpha;
public float3 Tint => tint;
public TintModifiers TintModifiers => tintModifiers;
public IPalettedRenderable WithPalette(PaletteReference newPalette) { return new SpriteRenderable(sprite, pos, offset, zOffset, newPalette, scale, alpha, tint, tintModifiers, isDecoration); }
public IRenderable WithZOffset(int newOffset) { return new SpriteRenderable(sprite, pos, offset, newOffset, palette, scale, alpha, tint, tintModifiers, isDecoration); }

View File

@@ -30,9 +30,9 @@ namespace OpenRA.Graphics
this.markerSize = markerSize;
}
public WPos Pos { get { return waypoints.First(); } }
public int ZOffset { get { return 0; } }
public bool IsDecoration { get { return true; } }
public WPos Pos => waypoints.First();
public int ZOffset => 0;
public bool IsDecoration => true;
public IRenderable WithZOffset(int newOffset) { return new TargetLineRenderable(waypoints, color); }
public IRenderable OffsetBy(WVec vec) { return new TargetLineRenderable(waypoints.Select(w => w + vec), color); }

View File

@@ -35,12 +35,12 @@ namespace OpenRA.Graphics
}
// Does not exist in the world, so a world positions don't make sense
public WPos Pos { get { return effectiveWorldPos; } }
public WVec Offset { get { return WVec.Zero; } }
public bool IsDecoration { get { return true; } }
public WPos Pos => effectiveWorldPos;
public WVec Offset => WVec.Zero;
public bool IsDecoration => true;
public PaletteReference Palette { get { return palette; } }
public int ZOffset { get { return zOffset; } }
public PaletteReference Palette => palette;
public int ZOffset => zOffset;
public IPalettedRenderable WithPalette(PaletteReference newPalette) { return new UISpriteRenderable(sprite, effectiveWorldPos, screenPos, zOffset, newPalette, scale, alpha); }
public IRenderable WithZOffset(int newOffset) { return this; }

View File

@@ -51,11 +51,11 @@ namespace OpenRA.Graphics
// Viewport geometry (world-px)
public int2 CenterLocation { get; private set; }
public WPos CenterPosition { get { return worldRenderer.ProjectedPosition(CenterLocation); } }
public WPos CenterPosition => worldRenderer.ProjectedPosition(CenterLocation);
public Rectangle Rectangle { get { return new Rectangle(TopLeft, new Size(viewportSize.X, viewportSize.Y)); } }
public int2 TopLeft { get { return CenterLocation - viewportSize / 2; } }
public int2 BottomRight { get { return CenterLocation + viewportSize / 2; } }
public Rectangle Rectangle => new Rectangle(TopLeft, new Size(viewportSize.X, viewportSize.Y));
public int2 TopLeft => CenterLocation - viewportSize / 2;
public int2 BottomRight => CenterLocation + viewportSize / 2;
int2 viewportSize;
ProjectedCellRegion cells;
bool cellsDirty = true;
@@ -75,10 +75,7 @@ namespace OpenRA.Graphics
public float Zoom
{
get
{
return zoom;
}
get => zoom;
private set
{
@@ -89,7 +86,7 @@ namespace OpenRA.Graphics
}
}
public float MinZoom { get { return minZoom; } }
public float MinZoom => minZoom;
public void AdjustZoom(float dz)
{