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

@@ -37,7 +37,7 @@ namespace OpenRA
public class ActorInitializer : IActorInitializer
{
public readonly Actor Self;
public World World { get { return Self.World; } }
public World World => Self.World;
internal TypeDictionary Dict;
@@ -150,7 +150,7 @@ namespace OpenRA
protected ValueActorInit(T value) { this.value = value; }
public virtual T Value { get { return value; } }
public virtual T Value => value;
public virtual void Initialize(MiniYaml yaml)
{

View File

@@ -27,7 +27,7 @@ namespace OpenRA
public string Type;
Lazy<TypeDictionary> initDict;
internal TypeDictionary InitDict { get { return initDict.Value; } }
internal TypeDictionary InitDict => initDict.Value;
public ActorReference(string type)
: this(type, new Dictionary<string, MiniYaml>()) { }

View File

@@ -64,10 +64,7 @@ namespace OpenRA
/// <summary>Gets or sets the <see cref="CellLayer"/> using cell coordinates</summary>
public T this[CPos cell]
{
get
{
return entries[Index(cell)];
}
get => entries[Index(cell)];
set
{
@@ -80,10 +77,7 @@ namespace OpenRA
/// <summary>Gets or sets the layer contents using raw map coordinates (not CPos!)</summary>
public T this[MPos uv]
{
get
{
return entries[Index(uv)];
}
get => entries[Index(uv)];
set
{

View File

@@ -97,10 +97,7 @@ namespace OpenRA
return uv.U >= mapTopLeft.U && uv.U <= mapBottomRight.U && uv.V >= mapTopLeft.V && uv.V <= mapBottomRight.V;
}
public MapCoordsRegion MapCoords
{
get { return new MapCoordsRegion(mapTopLeft, mapBottomRight); }
}
public MapCoordsRegion MapCoords => new MapCoordsRegion(mapTopLeft, mapBottomRight);
public CellRegionEnumerator GetEnumerator()
{
@@ -161,8 +158,8 @@ namespace OpenRA
v = r.mapTopLeft.V;
}
public CPos Current { get { return current; } }
object IEnumerator.Current { get { return Current; } }
public CPos Current => current;
object IEnumerator.Current => Current;
public void Dispose() { }
}
}

View File

@@ -902,15 +902,9 @@ namespace OpenRA
/// <summary>
/// The size of the map Height step in world units
/// </summary>
public WDist CellHeightStep
{
get
{
// RectangularIsometric defines 1024 units along the diagonal axis,
// giving a half-tile height step of sqrt(2) * 512
return new WDist(Grid.Type == MapGridType.RectangularIsometric ? 724 : 512);
}
}
/// RectangularIsometric defines 1024 units along the diagonal axis,
/// giving a half-tile height step of sqrt(2) * 512
public WDist CellHeightStep => new WDist(Grid.Type == MapGridType.RectangularIsometric ? 724 : 512);
public CPos CellContaining(WPos pos)
{

View File

@@ -335,10 +335,7 @@ namespace OpenRA
return initialUid;
}
public MapPreview this[string key]
{
get { return previews[key]; }
}
public MapPreview this[string key] => previews[key];
public IEnumerator<MapPreview> GetEnumerator()
{

View File

@@ -53,8 +53,8 @@ namespace OpenRA
current = new MPos(r.topLeft.U - 1, r.topLeft.V);
}
public MPos Current { get { return current; } }
object IEnumerator.Current { get { return Current; } }
public MPos Current => current;
object IEnumerator.Current => Current;
public void Dispose() { }
}
@@ -82,7 +82,7 @@ namespace OpenRA
return GetEnumerator();
}
public MPos TopLeft { get { return topLeft; } }
public MPos BottomRight { get { return bottomRight; } }
public MPos TopLeft => topLeft;
public MPos BottomRight => bottomRight;
}
}

View File

@@ -84,7 +84,7 @@ namespace OpenRA
public MapVisibility Visibility;
Lazy<Ruleset> rules;
public Ruleset Rules { get { return rules != null ? rules.Value : null; } }
public Ruleset Rules => rules != null ? rules.Value : null;
public bool InvalidCustomRules { get; private set; }
public bool DefinesUnsafeCustomRules { get; private set; }
public bool RulesLoaded { get; private set; }
@@ -138,23 +138,24 @@ namespace OpenRA
volatile InnerData innerData;
public string Title { get { return innerData.Title; } }
public string[] Categories { get { return innerData.Categories; } }
public string Author { get { return innerData.Author; } }
public string TileSet { get { return innerData.TileSet; } }
public MapPlayers Players { get { return innerData.Players; } }
public int PlayerCount { get { return innerData.PlayerCount; } }
public CPos[] SpawnPoints { get { return innerData.SpawnPoints; } }
public MapGridType GridType { get { return innerData.GridType; } }
public Rectangle Bounds { get { return innerData.Bounds; } }
public Png Preview { get { return innerData.Preview; } }
public MapStatus Status { get { return innerData.Status; } }
public MapClassification Class { get { return innerData.Class; } }
public MapVisibility Visibility { get { return innerData.Visibility; } }
public string Title => innerData.Title;
public string[] Categories => innerData.Categories;
public string Author => innerData.Author;
public string TileSet => innerData.TileSet;
public MapPlayers Players => innerData.Players;
public int PlayerCount => innerData.PlayerCount;
public CPos[] SpawnPoints => innerData.SpawnPoints;
public MapGridType GridType => innerData.GridType;
public Rectangle Bounds => innerData.Bounds;
public Png Preview => innerData.Preview;
public MapStatus Status => innerData.Status;
public MapClassification Class => innerData.Class;
public MapVisibility Visibility => innerData.Visibility;
public Ruleset Rules => innerData.Rules;
public bool InvalidCustomRules => innerData.InvalidCustomRules;
public bool RulesLoaded => innerData.RulesLoaded;
public Ruleset Rules { get { return innerData.Rules; } }
public bool InvalidCustomRules { get { return innerData.InvalidCustomRules; } }
public bool RulesLoaded { get { return innerData.RulesLoaded; } }
public bool DefinesUnsafeCustomRules
{
get

View File

@@ -15,7 +15,7 @@ namespace OpenRA
{
public sealed class ProjectedCellLayer<T> : CellLayerBase<T>
{
public int MaxIndex { get { return Size.Width * Size.Height; } }
public int MaxIndex => Size.Width * Size.Height;
public ProjectedCellLayer(Map map)
: base(map) { }
@@ -36,29 +36,17 @@ namespace OpenRA
public T this[int index]
{
get
{
return entries[index];
}
get => entries[index];
set
{
entries[index] = value;
}
set => entries[index] = value;
}
/// <summary>Gets or sets the layer contents using projected map coordinates.</summary>
public T this[PPos uv]
{
get
{
return entries[Index(uv)];
}
get => entries[Index(uv)];
set
{
entries[Index(uv)] = value;
}
set => entries[Index(uv)] = value;
}
public bool Contains(PPos uv)

View File

@@ -59,7 +59,7 @@ namespace OpenRA
/// this does not validate whether individual map cells are actually
/// projected inside the region.
/// </summary>
public MapCoordsRegion CandidateMapCoords { get { return new MapCoordsRegion(mapTopLeft, mapBottomRight); } }
public MapCoordsRegion CandidateMapCoords => new MapCoordsRegion(mapTopLeft, mapBottomRight);
public ProjectedCellRegionEnumerator GetEnumerator()
{
@@ -119,8 +119,8 @@ namespace OpenRA
v = r.TopLeft.V;
}
public PPos Current { get { return current; } }
object IEnumerator.Current { get { return Current; } }
public PPos Current => current;
object IEnumerator.Current => Current;
public void Dispose() { }
}
}