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

@@ -53,15 +53,15 @@ namespace OpenRA.Activities
Activity childActivity; Activity childActivity;
protected Activity ChildActivity protected Activity ChildActivity
{ {
get { return SkipDoneActivities(childActivity); } get => SkipDoneActivities(childActivity);
private set { childActivity = value; } private set => childActivity = value;
} }
Activity nextActivity; Activity nextActivity;
public Activity NextActivity public Activity NextActivity
{ {
get { return SkipDoneActivities(nextActivity); } get => SkipDoneActivities(nextActivity);
private set { nextActivity = value; } private set => nextActivity = value;
} }
internal static Activity SkipDoneActivities(Activity first) internal static Activity SkipDoneActivities(Activity first)
@@ -81,7 +81,7 @@ namespace OpenRA.Activities
public bool IsInterruptible { get; protected set; } public bool IsInterruptible { get; protected set; }
public bool ChildHasPriority { get; protected set; } public bool ChildHasPriority { get; protected set; }
public bool IsCanceling { get { return State == ActivityState.Canceling; } } public bool IsCanceling => State == ActivityState.Canceling;
bool finishing; bool finishing;
bool firstRunCompleted; bool firstRunCompleted;
bool lastRun; bool lastRun;

View File

@@ -48,8 +48,8 @@ namespace OpenRA
Activity currentActivity; Activity currentActivity;
public Activity CurrentActivity public Activity CurrentActivity
{ {
get { return Activity.SkipDoneActivities(currentActivity); } get => Activity.SkipDoneActivities(currentActivity);
private set { currentActivity = value; } private set => currentActivity = value;
} }
public int Generation; public int Generation;
@@ -59,19 +59,13 @@ namespace OpenRA
public IOccupySpace OccupiesSpace { get; private set; } public IOccupySpace OccupiesSpace { get; private set; }
public ITargetable[] Targetables { get; private set; } public ITargetable[] Targetables { get; private set; }
public bool IsIdle { get { return CurrentActivity == null; } } public bool IsIdle => CurrentActivity == null;
public bool IsDead { get { return Disposed || (health != null && health.IsDead); } } public bool IsDead => Disposed || (health != null && health.IsDead);
public CPos Location { get { return OccupiesSpace.TopLeft; } } public CPos Location => OccupiesSpace.TopLeft;
public WPos CenterPosition { get { return OccupiesSpace.CenterPosition; } } public WPos CenterPosition => OccupiesSpace.CenterPosition;
public WRot Orientation public WRot Orientation => facing != null ? facing.Orientation : WRot.None;
{
get
{
return facing != null ? facing.Orientation : WRot.None;
}
}
/// <summary>Value used to represent an invalid token.</summary> /// <summary>Value used to represent an invalid token.</summary>
public static readonly int InvalidConditionToken = -1; public static readonly int InvalidConditionToken = -1;
@@ -615,8 +609,8 @@ namespace OpenRA
public LuaValue this[LuaRuntime runtime, LuaValue keyValue] public LuaValue this[LuaRuntime runtime, LuaValue keyValue]
{ {
get { return luaInterface.Value[runtime, keyValue]; } get => luaInterface.Value[runtime, keyValue];
set { luaInterface.Value[runtime, keyValue] = value; } set => luaInterface.Value[runtime, keyValue] = value;
} }
public LuaValue Equals(LuaRuntime runtime, LuaValue left, LuaValue right) public LuaValue Equals(LuaRuntime runtime, LuaValue left, LuaValue right)

View File

@@ -25,13 +25,13 @@ namespace OpenRA
public readonly int Bits; public readonly int Bits;
// X is padded to MSB, so bit shift does the correct sign extension // X is padded to MSB, so bit shift does the correct sign extension
public int X { get { return Bits >> 20; } } public int X => Bits >> 20;
// Align Y with a short, cast, then shift the rest of the way // Align Y with a short, cast, then shift the rest of the way
// The signed short bit shift does the correct sign extension // The signed short bit shift does the correct sign extension
public int Y { get { return ((short)(Bits >> 4)) >> 4; } } public int Y => ((short)(Bits >> 4)) >> 4;
public byte Layer { get { return (byte)Bits; } } public byte Layer => (byte)Bits;
public CPos(int bits) { Bits = bits; } public CPos(int bits) { Bits = bits; }
public CPos(int x, int y) public CPos(int x, int y)
@@ -136,10 +136,7 @@ namespace OpenRA
} }
} }
set set => throw new LuaException("CPos is read-only. Use CPos.New to create a new value");
{
throw new LuaException("CPos is read-only. Use CPos.New to create a new value");
}
} }
#endregion #endregion

View File

@@ -42,8 +42,8 @@ namespace OpenRA
public CVec Sign() { return new CVec(Math.Sign(X), Math.Sign(Y)); } public CVec Sign() { return new CVec(Math.Sign(X), Math.Sign(Y)); }
public CVec Abs() { return new CVec(Math.Abs(X), Math.Abs(Y)); } public CVec Abs() { return new CVec(Math.Abs(X), Math.Abs(Y)); }
public int LengthSquared { get { return X * X + Y * Y; } } public int LengthSquared => X * X + Y * Y;
public int Length { get { return Exts.ISqrt(LengthSquared); } } public int Length => Exts.ISqrt(LengthSquared);
public CVec Clamp(Rectangle r) public CVec Clamp(Rectangle r)
{ {
@@ -114,10 +114,7 @@ namespace OpenRA
} }
} }
set set => throw new LuaException("CVec is read-only. Use CVec.New to create a new value");
{
throw new LuaException("CVec is read-only. Use CVec.New to create a new value");
}
} }
#endregion #endregion

View File

@@ -290,10 +290,10 @@ namespace OpenRA
} }
} }
public ExternalMod this[string key] { get { return mods[key]; } } public ExternalMod this[string key] => mods[key];
public int Count { get { return mods.Count; } } public int Count => mods.Count;
public ICollection<string> Keys { get { return mods.Keys; } } public ICollection<string> Keys => mods.Keys;
public ICollection<ExternalMod> Values { get { return mods.Values; } } public ICollection<ExternalMod> Values => mods.Values;
public bool ContainsKey(string key) { return mods.ContainsKey(key); } public bool ContainsKey(string key) { return mods.ContainsKey(key); }
public IEnumerator<KeyValuePair<string, ExternalMod>> GetEnumerator() { return mods.GetEnumerator(); } public IEnumerator<KeyValuePair<string, ExternalMod>> GetEnumerator() { return mods.GetEnumerator(); }
public bool TryGetValue(string key, out ExternalMod value) { return mods.TryGetValue(key, out value); } public bool TryGetValue(string key, out ExternalMod value) { return mods.TryGetValue(key, out value); }

View File

@@ -651,7 +651,7 @@ namespace OpenRA
{ {
public static readonly SerializeAttribute Default = new SerializeAttribute(true); public static readonly SerializeAttribute Default = new SerializeAttribute(true);
public bool IsDefault { get { return this == Default; } } public bool IsDefault => this == Default;
public readonly bool Serialize; public readonly bool Serialize;
public string YamlName; public string YamlName;

View File

@@ -33,7 +33,7 @@ namespace OpenRA.FileFormats
public SpriteFrameType Type { get; private set; } public SpriteFrameType Type { get; private set; }
public Dictionary<string, string> EmbeddedData = new Dictionary<string, string>(); public Dictionary<string, string> EmbeddedData = new Dictionary<string, string>();
public int PixelStride { get { return Type == SpriteFrameType.Indexed8 ? 1 : Type == SpriteFrameType.Rgb24 ? 3 : 4; } } public int PixelStride => Type == SpriteFrameType.Indexed8 ? 1 : Type == SpriteFrameType.Rgb24 ? 3 : 4;
public Png(Stream s) public Png(Stream s)
{ {

View File

@@ -28,7 +28,7 @@ namespace OpenRA.FileSystem
public class FileSystem : IReadOnlyFileSystem public class FileSystem : IReadOnlyFileSystem
{ {
public IEnumerable<IReadOnlyPackage> MountedPackages { get { return mountedPackages.Keys; } } public IEnumerable<IReadOnlyPackage> MountedPackages => mountedPackages.Keys;
readonly Dictionary<IReadOnlyPackage, int> mountedPackages = new Dictionary<IReadOnlyPackage, int>(); readonly Dictionary<IReadOnlyPackage, int> mountedPackages = new Dictionary<IReadOnlyPackage, int>();
readonly Dictionary<string, IReadOnlyPackage> explicitMounts = new Dictionary<string, IReadOnlyPackage>(); readonly Dictionary<string, IReadOnlyPackage> explicitMounts = new Dictionary<string, IReadOnlyPackage>();
readonly string modID; readonly string modID;

View File

@@ -27,7 +27,7 @@ namespace OpenRA.FileSystem
Directory.CreateDirectory(path); Directory.CreateDirectory(path);
} }
public string Name { get { return path; } } public string Name => path;
public IEnumerable<string> Contents public IEnumerable<string> Contents
{ {

View File

@@ -141,7 +141,7 @@ namespace OpenRA.FileSystem
sealed class ZipFolder : IReadOnlyPackage sealed class ZipFolder : IReadOnlyPackage
{ {
public string Name { get { return path; } } public string Name => path;
public ReadOnlyZipFile Parent { get; private set; } public ReadOnlyZipFile Parent { get; private set; }
readonly string path; readonly string path;

View File

@@ -99,16 +99,16 @@ namespace OpenRA
// More accurate replacement for Environment.TickCount // More accurate replacement for Environment.TickCount
static Stopwatch stopwatch = Stopwatch.StartNew(); static Stopwatch stopwatch = Stopwatch.StartNew();
public static long RunTime { get { return stopwatch.ElapsedMilliseconds; } } public static long RunTime => stopwatch.ElapsedMilliseconds;
public static int RenderFrame = 0; public static int RenderFrame = 0;
public static int NetFrameNumber { get { return OrderManager.NetFrameNumber; } } public static int NetFrameNumber => OrderManager.NetFrameNumber;
public static int LocalTick { get { return OrderManager.LocalFrameNumber; } } public static int LocalTick => OrderManager.LocalFrameNumber;
public static event Action<ConnectionTarget> OnRemoteDirectConnect = _ => { }; public static event Action<ConnectionTarget> OnRemoteDirectConnect = _ => { };
public static event Action<OrderManager> ConnectionStateChanged = _ => { }; public static event Action<OrderManager> ConnectionStateChanged = _ => { };
static ConnectionState lastConnectionState = ConnectionState.PreConnecting; static ConnectionState lastConnectionState = ConnectionState.PreConnecting;
public static int LocalClientId { get { return OrderManager.Connection.LocalClientId; } } public static int LocalClientId => OrderManager.Connection.LocalClientId;
public static void RemoteDirectConnect(ConnectionTarget endpoint) public static void RemoteDirectConnect(ConnectionTarget endpoint)
{ {

View File

@@ -33,12 +33,13 @@ namespace OpenRA
public DateTime EndTimeUtc; public DateTime EndTimeUtc;
/// <summary>Gets the game's duration, from the time the game started until the replay recording stopped.</summary> /// <summary>Gets the game's duration, from the time the game started until the replay recording stopped.</summary>
public TimeSpan Duration { get { return EndTimeUtc > StartTimeUtc ? EndTimeUtc - StartTimeUtc : TimeSpan.Zero; } } public TimeSpan Duration => EndTimeUtc > StartTimeUtc ? EndTimeUtc - StartTimeUtc : TimeSpan.Zero;
public IList<Player> Players { get; private set; } public IList<Player> Players { get; private set; }
public HashSet<int> DisabledSpawnPoints = new HashSet<int>(); public HashSet<int> DisabledSpawnPoints = new HashSet<int>();
public MapPreview MapPreview { get { return Game.ModData.MapCache[MapUid]; } } public MapPreview MapPreview => Game.ModData.MapCache[MapUid];
public IEnumerable<Player> HumanPlayers { get { return Players.Where(p => p.IsHuman); } } public IEnumerable<Player> HumanPlayers { get { return Players.Where(p => p.IsHuman); } }
public bool IsSinglePlayer { get { return HumanPlayers.Count() == 1; } } public bool IsSinglePlayer => HumanPlayers.Count() == 1;
readonly Dictionary<OpenRA.Player, Player> playersByRuntime; readonly Dictionary<OpenRA.Player, Player> playersByRuntime;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -164,7 +164,7 @@ namespace OpenRA.Graphics
frames = new Cache<string, ISpriteFrame[]>(filename => FrameLoader.GetFrames(fileSystem, filename, loaders, out _)); 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 public static class FrameLoader

View File

@@ -43,15 +43,15 @@ namespace OpenRA.Graphics
this.alpha = alpha; this.alpha = alpha;
} }
public WPos Pos { get { return pos + offset; } } public WPos Pos => pos + offset;
public WVec Offset { get { return offset; } } public WVec Offset => offset;
public PaletteReference Palette { get { return palette; } } public PaletteReference Palette => palette;
public int ZOffset { get { return zOffset; } } public int ZOffset => zOffset;
public bool IsDecoration { get { return isDecoration; } } public bool IsDecoration => isDecoration;
public float Alpha { get { return alpha; } } public float Alpha => alpha;
public float3 Tint { get { return tint; } } public float3 Tint => tint;
public TintModifiers TintModifiers { get { return tintModifiers; } } public TintModifiers TintModifiers => tintModifiers;
public IPalettedRenderable WithPalette(PaletteReference newPalette) { return new SpriteRenderable(sprite, pos, offset, zOffset, newPalette, scale, alpha, tint, tintModifiers, isDecoration); } 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); } 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; this.markerSize = markerSize;
} }
public WPos Pos { get { return waypoints.First(); } } public WPos Pos => waypoints.First();
public int ZOffset { get { return 0; } } public int ZOffset => 0;
public bool IsDecoration { get { return true; } } public bool IsDecoration => true;
public IRenderable WithZOffset(int newOffset) { return new TargetLineRenderable(waypoints, color); } public IRenderable WithZOffset(int newOffset) { return new TargetLineRenderable(waypoints, color); }
public IRenderable OffsetBy(WVec vec) { return new TargetLineRenderable(waypoints.Select(w => w + vec), 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 // Does not exist in the world, so a world positions don't make sense
public WPos Pos { get { return effectiveWorldPos; } } public WPos Pos => effectiveWorldPos;
public WVec Offset { get { return WVec.Zero; } } public WVec Offset => WVec.Zero;
public bool IsDecoration { get { return true; } } public bool IsDecoration => true;
public PaletteReference Palette { get { return palette; } } public PaletteReference Palette => palette;
public int ZOffset { get { return zOffset; } } public int ZOffset => zOffset;
public IPalettedRenderable WithPalette(PaletteReference newPalette) { return new UISpriteRenderable(sprite, effectiveWorldPos, screenPos, zOffset, newPalette, scale, alpha); } public IPalettedRenderable WithPalette(PaletteReference newPalette) { return new UISpriteRenderable(sprite, effectiveWorldPos, screenPos, zOffset, newPalette, scale, alpha); }
public IRenderable WithZOffset(int newOffset) { return this; } public IRenderable WithZOffset(int newOffset) { return this; }

View File

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

View File

@@ -96,14 +96,8 @@ namespace OpenRA
return null; return null;
} }
public HotkeyReference this[string name] public HotkeyReference this[string name] => new HotkeyReference(GetHotkeyReference(name));
{
get
{
return new HotkeyReference(GetHotkeyReference(name));
}
}
public IEnumerable<HotkeyDefinition> Definitions { get { return definitions.Values; } } public IEnumerable<HotkeyDefinition> Definitions => definitions.Values;
} }
} }

View File

@@ -53,20 +53,8 @@ namespace OpenRA
public class MouseButtonPreference public class MouseButtonPreference
{ {
public MouseButton Action public MouseButton Action => Game.Settings.Game.UseClassicMouseStyle ? MouseButton.Left : MouseButton.Right;
{
get
{
return Game.Settings.Game.UseClassicMouseStyle ? MouseButton.Left : MouseButton.Right;
}
}
public MouseButton Cancel public MouseButton Cancel => Game.Settings.Game.UseClassicMouseStyle ? MouseButton.Right : MouseButton.Left;
{
get
{
return Game.Settings.Game.UseClassicMouseStyle ? MouseButton.Right : MouseButton.Left;
}
}
} }
} }

View File

@@ -99,10 +99,10 @@ namespace OpenRA
return ret; return ret;
} }
public Manifest this[string key] { get { return mods[key]; } } public Manifest this[string key] => mods[key];
public int Count { get { return mods.Count; } } public int Count => mods.Count;
public ICollection<string> Keys { get { return mods.Keys; } } public ICollection<string> Keys => mods.Keys;
public ICollection<Manifest> Values { get { return mods.Values; } } public ICollection<Manifest> Values => mods.Values;
public bool ContainsKey(string key) { return mods.ContainsKey(key); } public bool ContainsKey(string key) { return mods.ContainsKey(key); }
public IEnumerator<KeyValuePair<string, Manifest>> GetEnumerator() { return mods.GetEnumerator(); } public IEnumerator<KeyValuePair<string, Manifest>> GetEnumerator() { return mods.GetEnumerator(); }
public bool TryGetValue(string key, out Manifest value) { return mods.TryGetValue(key, out value); } public bool TryGetValue(string key, out Manifest value) { return mods.TryGetValue(key, out value); }

View File

@@ -24,11 +24,11 @@ namespace OpenRA
const int AuthKeySize = 2048; const int AuthKeySize = 2048;
public enum LinkState { Uninitialized, GeneratingKeys, Unlinked, CheckingLink, ConnectionFailed, Linked } public enum LinkState { Uninitialized, GeneratingKeys, Unlinked, CheckingLink, ConnectionFailed, Linked }
public LinkState State { get { return innerState; } } public LinkState State => innerState;
public string Fingerprint { get { return innerFingerprint; } } public string Fingerprint => innerFingerprint;
public string PublicKey { get { return innerPublicKey; } } public string PublicKey => innerPublicKey;
public PlayerProfile ProfileData { get { return innerData; } } public PlayerProfile ProfileData => innerData;
volatile LinkState innerState; volatile LinkState innerState;
volatile PlayerProfile innerData; volatile PlayerProfile innerData;

View File

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

View File

@@ -27,7 +27,7 @@ namespace OpenRA
public string Type; public string Type;
Lazy<TypeDictionary> initDict; Lazy<TypeDictionary> initDict;
internal TypeDictionary InitDict { get { return initDict.Value; } } internal TypeDictionary InitDict => initDict.Value;
public ActorReference(string type) public ActorReference(string type)
: this(type, new Dictionary<string, MiniYaml>()) { } : 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> /// <summary>Gets or sets the <see cref="CellLayer"/> using cell coordinates</summary>
public T this[CPos cell] public T this[CPos cell]
{ {
get get => entries[Index(cell)];
{
return entries[Index(cell)];
}
set set
{ {
@@ -80,10 +77,7 @@ namespace OpenRA
/// <summary>Gets or sets the layer contents using raw map coordinates (not CPos!)</summary> /// <summary>Gets or sets the layer contents using raw map coordinates (not CPos!)</summary>
public T this[MPos uv] public T this[MPos uv]
{ {
get get => entries[Index(uv)];
{
return entries[Index(uv)];
}
set 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; return uv.U >= mapTopLeft.U && uv.U <= mapBottomRight.U && uv.V >= mapTopLeft.V && uv.V <= mapBottomRight.V;
} }
public MapCoordsRegion MapCoords public MapCoordsRegion MapCoords => new MapCoordsRegion(mapTopLeft, mapBottomRight);
{
get { return new MapCoordsRegion(mapTopLeft, mapBottomRight); }
}
public CellRegionEnumerator GetEnumerator() public CellRegionEnumerator GetEnumerator()
{ {
@@ -161,8 +158,8 @@ namespace OpenRA
v = r.mapTopLeft.V; v = r.mapTopLeft.V;
} }
public CPos Current { get { return current; } } public CPos Current => current;
object IEnumerator.Current { get { return Current; } } object IEnumerator.Current => Current;
public void Dispose() { } public void Dispose() { }
} }
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -38,16 +38,16 @@ namespace OpenRA
public ILoadScreen LoadScreen { get; private set; } public ILoadScreen LoadScreen { get; private set; }
public CursorProvider CursorProvider { get; private set; } public CursorProvider CursorProvider { get; private set; }
public FS ModFiles; public FS ModFiles;
public IReadOnlyFileSystem DefaultFileSystem { get { return ModFiles; } } public IReadOnlyFileSystem DefaultFileSystem => ModFiles;
readonly Lazy<Ruleset> defaultRules; readonly Lazy<Ruleset> defaultRules;
public Ruleset DefaultRules { get { return defaultRules.Value; } } public Ruleset DefaultRules => defaultRules.Value;
readonly Lazy<IReadOnlyDictionary<string, ITerrainInfo>> defaultTerrainInfo; readonly Lazy<IReadOnlyDictionary<string, ITerrainInfo>> defaultTerrainInfo;
public IReadOnlyDictionary<string, ITerrainInfo> DefaultTerrainInfo { get { return defaultTerrainInfo.Value; } } public IReadOnlyDictionary<string, ITerrainInfo> DefaultTerrainInfo => defaultTerrainInfo.Value;
readonly Lazy<IReadOnlyDictionary<string, SequenceProvider>> defaultSequences; readonly Lazy<IReadOnlyDictionary<string, SequenceProvider>> defaultSequences;
public IReadOnlyDictionary<string, SequenceProvider> DefaultSequences { get { return defaultSequences.Value; } } public IReadOnlyDictionary<string, SequenceProvider> DefaultSequences => defaultSequences.Value;
public ModData(Manifest mod, InstalledMods mods, bool useLoadScreen = false) public ModData(Manifest mod, InstalledMods mods, bool useLoadScreen = false)
{ {
@@ -134,7 +134,7 @@ namespace OpenRA
LoadScreen.Display(); LoadScreen.Display();
} }
internal bool IsOnMainThread { get { return System.Threading.Thread.CurrentThread.ManagedThreadId == initialThreadId; } } internal bool IsOnMainThread => System.Threading.Thread.CurrentThread.ManagedThreadId == initialThreadId;
public void InitializeLoaders(IReadOnlyFileSystem fileSystem) public void InitializeLoaders(IReadOnlyFileSystem fileSystem)
{ {

View File

@@ -101,25 +101,13 @@ namespace OpenRA.Network
readonly List<ReceivedPacket> receivedPackets = new List<ReceivedPacket>(); readonly List<ReceivedPacket> receivedPackets = new List<ReceivedPacket>();
public ReplayRecorder Recorder { get; private set; } public ReplayRecorder Recorder { get; private set; }
public virtual int LocalClientId public virtual int LocalClientId => 1;
{
get { return 1; }
}
public virtual ConnectionState ConnectionState public virtual ConnectionState ConnectionState => ConnectionState.PreConnecting;
{
get { return ConnectionState.PreConnecting; }
}
public virtual IPEndPoint EndPoint public virtual IPEndPoint EndPoint => throw new NotSupportedException("An echo connection doesn't have an endpoint");
{
get { throw new NotSupportedException("An echo connection doesn't have an endpoint"); }
}
public virtual string ErrorMessage public virtual string ErrorMessage => null;
{
get { return null; }
}
public virtual void Send(int frame, List<byte[]> orders) public virtual void Send(int frame, List<byte[]> orders)
{ {
@@ -209,9 +197,9 @@ namespace OpenRA.Network
bool disposed; bool disposed;
string errorMessage; string errorMessage;
public override IPEndPoint EndPoint { get { return endpoint; } } public override IPEndPoint EndPoint => endpoint;
public override string ErrorMessage { get { return errorMessage; } } public override string ErrorMessage => errorMessage;
public NetworkConnection(ConnectionTarget target) public NetworkConnection(ConnectionTarget target)
{ {
@@ -325,8 +313,8 @@ namespace OpenRA.Network
} }
} }
public override int LocalClientId { get { return clientId; } } public override int LocalClientId => clientId;
public override ConnectionState ConnectionState { get { return connectionState; } } public override ConnectionState ConnectionState => connectionState;
public override void SendSync(int frame, byte[] syncData) public override void SendSync(int frame, byte[] syncData)
{ {

View File

@@ -135,7 +135,7 @@ namespace OpenRA.Network
/// <summary>The list of spawnpoints that are disabled for this game</summary> /// <summary>The list of spawnpoints that are disabled for this game</summary>
public readonly int[] DisabledSpawnPoints = { }; public readonly int[] DisabledSpawnPoints = { };
public string ModLabel { get { return "{0} ({1})".F(ModTitle, Version); } } public string ModLabel => "{0} ({1})".F(ModTitle, Version);
static object LoadClients(MiniYaml yaml) static object LoadClients(MiniYaml yaml)
{ {

View File

@@ -68,7 +68,7 @@ namespace OpenRA
public bool SuppressVisualFeedback; public bool SuppressVisualFeedback;
public ref readonly Target VisualFeedbackTarget => ref visualFeedbackTarget; public ref readonly Target VisualFeedbackTarget => ref visualFeedbackTarget;
public Player Player { get { return Subject != null ? Subject.Owner : null; } } public Player Player => Subject != null ? Subject.Owner : null;
readonly Target target; readonly Target target;
readonly Target visualFeedbackTarget; readonly Target visualFeedbackTarget;

View File

@@ -25,7 +25,7 @@ namespace OpenRA.Network
readonly FrameData frameData = new FrameData(); readonly FrameData frameData = new FrameData();
public Session LobbyInfo = new Session(); public Session LobbyInfo = new Session();
public Session.Client LocalClient { get { return LobbyInfo.ClientWithIndex(Connection.LocalClientId); } } public Session.Client LocalClient => LobbyInfo.ClientWithIndex(Connection.LocalClientId);
public World World; public World World;
public readonly ConnectionTarget Endpoint; public readonly ConnectionTarget Endpoint;
@@ -41,7 +41,7 @@ namespace OpenRA.Network
public long LastTickTime = Game.RunTime; public long LastTickTime = Game.RunTime;
public bool GameStarted { get { return NetFrameNumber != 0; } } public bool GameStarted => NetFrameNumber != 0;
public IConnection Connection { get; private set; } public IConnection Connection { get; private set; }
internal int GameSaveLastFrame = -1; internal int GameSaveLastFrame = -1;
@@ -170,10 +170,7 @@ namespace OpenRA.Network
syncForFrame.Add(frame, packet); syncForFrame.Add(frame, packet);
} }
public bool IsReadyForNextFrame public bool IsReadyForNextFrame => GameStarted && frameData.IsReadyForFrame(NetFrameNumber);
{
get { return GameStarted && frameData.IsReadyForFrame(NetFrameNumber); }
}
public IEnumerable<Session.Client> GetClientsNotReadyForNextFrame public IEnumerable<Session.Client> GetClientsNotReadyForNextFrame
{ {

View File

@@ -30,14 +30,12 @@ namespace OpenRA.Network
int ordersFrame; int ordersFrame;
Dictionary<int, int> lastClientsFrame = new Dictionary<int, int>(); Dictionary<int, int> lastClientsFrame = new Dictionary<int, int>();
public int LocalClientId { get { return -1; } } public int LocalClientId => -1;
public ConnectionState ConnectionState { get { return ConnectionState.Connected; } } public ConnectionState ConnectionState => ConnectionState.Connected;
public IPEndPoint EndPoint
{
get { throw new NotSupportedException("A replay connection doesn't have an endpoint"); }
}
public string ErrorMessage { get { return null; } } public IPEndPoint EndPoint => throw new NotSupportedException("A replay connection doesn't have an endpoint");
public string ErrorMessage => null;
public readonly int TickCount; public readonly int TickCount;
public readonly int FinalGameTick; public readonly int FinalGameTick;

View File

@@ -149,9 +149,9 @@ namespace OpenRA.Network
public string Bot; // Bot type, null for real clients public string Bot; // Bot type, null for real clients
public int BotControllerClientIndex; // who added the bot to the slot public int BotControllerClientIndex; // who added the bot to the slot
public bool IsAdmin; public bool IsAdmin;
public bool IsReady { get { return State == ClientState.Ready; } } public bool IsReady => State == ClientState.Ready;
public bool IsInvalid { get { return State == ClientState.Invalid; } } public bool IsInvalid => State == ClientState.Invalid;
public bool IsObserver { get { return Slot == null; } } public bool IsObserver => Slot == null;
// Linked to the online player database // Linked to the online player database
public string Fingerprint; public string Fingerprint;
@@ -215,7 +215,7 @@ namespace OpenRA.Network
public string PreferredValue; public string PreferredValue;
public bool IsLocked; public bool IsLocked;
public bool IsEnabled { get { return Value == "True"; } } public bool IsEnabled => Value == "True";
} }
public class Global public class Global

View File

@@ -28,14 +28,9 @@ namespace OpenRA.Network
static bool initialized; static bool initialized;
public static IPAddress ExternalIP { get; private set; } public static IPAddress ExternalIP { get; private set; }
public static UPnPStatus Status public static UPnPStatus Status =>
{ initialized ? natDevice != null ?
get
{
return initialized ? natDevice != null ?
UPnPStatus.Enabled : UPnPStatus.NotSupported : UPnPStatus.Disabled; UPnPStatus.Enabled : UPnPStatus.NotSupported : UPnPStatus.Disabled;
}
}
public static async Task DiscoverNatDevices(int timeout) public static async Task DiscoverNatDevices(int timeout)
{ {

View File

@@ -214,6 +214,6 @@ namespace OpenRA.Orders
} }
} }
public virtual bool ClearSelectionOnLeftClick { get { return true; } } public virtual bool ClearSelectionOnLeftClick => true;
} }
} }

View File

@@ -22,7 +22,7 @@ namespace OpenRA
public static class Platform public static class Platform
{ {
public static PlatformType CurrentPlatform { get { return currentPlatform.Value; } } public static PlatformType CurrentPlatform => currentPlatform.Value;
public static readonly Guid SessionGUID = Guid.NewGuid(); public static readonly Guid SessionGUID = Guid.NewGuid();
static Lazy<PlatformType> currentPlatform = Exts.Lazy(GetCurrentPlatform); static Lazy<PlatformType> currentPlatform = Exts.Lazy(GetCurrentPlatform);
@@ -77,7 +77,7 @@ namespace OpenRA
/// <summary> /// <summary>
/// Directory containing user-specific support files (settings, maps, replays, game data, etc). /// Directory containing user-specific support files (settings, maps, replays, game data, etc).
/// </summary> /// </summary>
public static string SupportDir { get { return GetSupportDir(SupportDirType.User); } } public static string SupportDir => GetSupportDir(SupportDirType.User);
public static string GetSupportDir(SupportDirType type) public static string GetSupportDir(SupportDirType type)
{ {

View File

@@ -77,14 +77,8 @@ namespace OpenRA
public WinState WinState = WinState.Undefined; public WinState WinState = WinState.Undefined;
public bool HasObjectives = false; public bool HasObjectives = false;
public bool Spectating
{
get
{
// Players in mission maps must not leave the player view // Players in mission maps must not leave the player view
return !inMissionMap && (spectating || WinState != WinState.Undefined); public bool Spectating => !inMissionMap && (spectating || WinState != WinState.Undefined);
}
}
public World World { get; private set; } public World World { get; private set; }
@@ -301,8 +295,8 @@ namespace OpenRA
public LuaValue this[LuaRuntime runtime, LuaValue keyValue] public LuaValue this[LuaRuntime runtime, LuaValue keyValue]
{ {
get { return luaInterface.Value[runtime, keyValue]; } get => luaInterface.Value[runtime, keyValue];
set { luaInterface.Value[runtime, keyValue] = value; } set => luaInterface.Value[runtime, keyValue] = value;
} }
public LuaValue Equals(LuaRuntime runtime, LuaValue left, LuaValue right) public LuaValue Equals(LuaRuntime runtime, LuaValue left, LuaValue right)

View File

@@ -101,7 +101,7 @@ namespace OpenRA.Primitives
public override bool Equals(object obj) { return obj is BitSet<T> && Equals((BitSet<T>)obj); } public override bool Equals(object obj) { return obj is BitSet<T> && Equals((BitSet<T>)obj); }
public override int GetHashCode() { return bits.GetHashCode(); } public override int GetHashCode() { return bits.GetHashCode(); }
public bool IsEmpty { get { return bits == 0; } } public bool IsEmpty => bits == 0;
public bool IsProperSubsetOf(BitSet<T> other) public bool IsProperSubsetOf(BitSet<T> other)
{ {

View File

@@ -31,18 +31,15 @@ namespace OpenRA.Primitives
public Cache(Func<T, U> loader) public Cache(Func<T, U> loader)
: this(loader, EqualityComparer<T>.Default) { } : this(loader, EqualityComparer<T>.Default) { }
public U this[T key] public U this[T key] => cache.GetOrAdd(key, loader);
{
get { return cache.GetOrAdd(key, loader); }
}
public bool ContainsKey(T key) { return cache.ContainsKey(key); } public bool ContainsKey(T key) { return cache.ContainsKey(key); }
public bool TryGetValue(T key, out U value) { return cache.TryGetValue(key, out value); } public bool TryGetValue(T key, out U value) { return cache.TryGetValue(key, out value); }
public int Count { get { return cache.Count; } } public int Count => cache.Count;
public void Clear() { cache.Clear(); } public void Clear() { cache.Clear(); }
public ICollection<T> Keys { get { return cache.Keys; } } public ICollection<T> Keys => cache.Keys;
public ICollection<U> Values { get { return cache.Values; } } public ICollection<U> Values => cache.Values;
public IEnumerator<KeyValuePair<T, U>> GetEnumerator() { return cache.GetEnumerator(); } public IEnumerator<KeyValuePair<T, U>> GetEnumerator() { return cache.GetEnumerator(); }
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { return GetEnumerator(); } System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { return GetEnumerator(); }
} }

View File

@@ -195,10 +195,10 @@ namespace OpenRA.Primitives
return hue; return hue;
} }
public byte A { get { return (byte)(argb >> 24); } } public byte A => (byte)(argb >> 24);
public byte R { get { return (byte)(argb >> 16); } } public byte R => (byte)(argb >> 16);
public byte G { get { return (byte)(argb >> 8); } } public byte G => (byte)(argb >> 8);
public byte B { get { return (byte)argb; } } public byte B => (byte)argb;
public bool Equals(Color other) public bool Equals(Color other)
{ {
@@ -226,146 +226,146 @@ namespace OpenRA.Primitives
return R.ToString("X2") + G.ToString("X2") + B.ToString("X2") + A.ToString("X2"); return R.ToString("X2") + G.ToString("X2") + B.ToString("X2") + A.ToString("X2");
} }
public static Color Transparent { get { return FromArgb(0x00FFFFFF); } } public static Color Transparent => FromArgb(0x00FFFFFF);
public static Color AliceBlue { get { return FromArgb(0xFFF0F8FF); } } public static Color AliceBlue => FromArgb(0xFFF0F8FF);
public static Color AntiqueWhite { get { return FromArgb(0xFFFAEBD7); } } public static Color AntiqueWhite => FromArgb(0xFFFAEBD7);
public static Color Aqua { get { return FromArgb(0xFF00FFFF); } } public static Color Aqua => FromArgb(0xFF00FFFF);
public static Color Aquamarine { get { return FromArgb(0xFF7FFFD4); } } public static Color Aquamarine => FromArgb(0xFF7FFFD4);
public static Color Azure { get { return FromArgb(0xFFF0FFFF); } } public static Color Azure => FromArgb(0xFFF0FFFF);
public static Color Beige { get { return FromArgb(0xFFF5F5DC); } } public static Color Beige => FromArgb(0xFFF5F5DC);
public static Color Bisque { get { return FromArgb(0xFFFFE4C4); } } public static Color Bisque => FromArgb(0xFFFFE4C4);
public static Color Black { get { return FromArgb(0xFF000000); } } public static Color Black => FromArgb(0xFF000000);
public static Color BlanchedAlmond { get { return FromArgb(0xFFFFEBCD); } } public static Color BlanchedAlmond => FromArgb(0xFFFFEBCD);
public static Color Blue { get { return FromArgb(0xFF0000FF); } } public static Color Blue => FromArgb(0xFF0000FF);
public static Color BlueViolet { get { return FromArgb(0xFF8A2BE2); } } public static Color BlueViolet => FromArgb(0xFF8A2BE2);
public static Color Brown { get { return FromArgb(0xFFA52A2A); } } public static Color Brown => FromArgb(0xFFA52A2A);
public static Color BurlyWood { get { return FromArgb(0xFFDEB887); } } public static Color BurlyWood => FromArgb(0xFFDEB887);
public static Color CadetBlue { get { return FromArgb(0xFF5F9EA0); } } public static Color CadetBlue => FromArgb(0xFF5F9EA0);
public static Color Chartreuse { get { return FromArgb(0xFF7FFF00); } } public static Color Chartreuse => FromArgb(0xFF7FFF00);
public static Color Chocolate { get { return FromArgb(0xFFD2691E); } } public static Color Chocolate => FromArgb(0xFFD2691E);
public static Color Coral { get { return FromArgb(0xFFFF7F50); } } public static Color Coral => FromArgb(0xFFFF7F50);
public static Color CornflowerBlue { get { return FromArgb(0xFF6495ED); } } public static Color CornflowerBlue => FromArgb(0xFF6495ED);
public static Color Cornsilk { get { return FromArgb(0xFFFFF8DC); } } public static Color Cornsilk => FromArgb(0xFFFFF8DC);
public static Color Crimson { get { return FromArgb(0xFFDC143C); } } public static Color Crimson => FromArgb(0xFFDC143C);
public static Color Cyan { get { return FromArgb(0xFF00FFFF); } } public static Color Cyan => FromArgb(0xFF00FFFF);
public static Color DarkBlue { get { return FromArgb(0xFF00008B); } } public static Color DarkBlue => FromArgb(0xFF00008B);
public static Color DarkCyan { get { return FromArgb(0xFF008B8B); } } public static Color DarkCyan => FromArgb(0xFF008B8B);
public static Color DarkGoldenrod { get { return FromArgb(0xFFB8860B); } } public static Color DarkGoldenrod => FromArgb(0xFFB8860B);
public static Color DarkGray { get { return FromArgb(0xFFA9A9A9); } } public static Color DarkGray => FromArgb(0xFFA9A9A9);
public static Color DarkGreen { get { return FromArgb(0xFF006400); } } public static Color DarkGreen => FromArgb(0xFF006400);
public static Color DarkKhaki { get { return FromArgb(0xFFBDB76B); } } public static Color DarkKhaki => FromArgb(0xFFBDB76B);
public static Color DarkMagenta { get { return FromArgb(0xFF8B008B); } } public static Color DarkMagenta => FromArgb(0xFF8B008B);
public static Color DarkOliveGreen { get { return FromArgb(0xFF556B2F); } } public static Color DarkOliveGreen => FromArgb(0xFF556B2F);
public static Color DarkOrange { get { return FromArgb(0xFFFF8C00); } } public static Color DarkOrange => FromArgb(0xFFFF8C00);
public static Color DarkOrchid { get { return FromArgb(0xFF9932CC); } } public static Color DarkOrchid => FromArgb(0xFF9932CC);
public static Color DarkRed { get { return FromArgb(0xFF8B0000); } } public static Color DarkRed => FromArgb(0xFF8B0000);
public static Color DarkSalmon { get { return FromArgb(0xFFE9967A); } } public static Color DarkSalmon => FromArgb(0xFFE9967A);
public static Color DarkSeaGreen { get { return FromArgb(0xFF8FBC8B); } } public static Color DarkSeaGreen => FromArgb(0xFF8FBC8B);
public static Color DarkSlateBlue { get { return FromArgb(0xFF483D8B); } } public static Color DarkSlateBlue => FromArgb(0xFF483D8B);
public static Color DarkSlateGray { get { return FromArgb(0xFF2F4F4F); } } public static Color DarkSlateGray => FromArgb(0xFF2F4F4F);
public static Color DarkTurquoise { get { return FromArgb(0xFF00CED1); } } public static Color DarkTurquoise => FromArgb(0xFF00CED1);
public static Color DarkViolet { get { return FromArgb(0xFF9400D3); } } public static Color DarkViolet => FromArgb(0xFF9400D3);
public static Color DeepPink { get { return FromArgb(0xFFFF1493); } } public static Color DeepPink => FromArgb(0xFFFF1493);
public static Color DeepSkyBlue { get { return FromArgb(0xFF00BFFF); } } public static Color DeepSkyBlue => FromArgb(0xFF00BFFF);
public static Color DimGray { get { return FromArgb(0xFF696969); } } public static Color DimGray => FromArgb(0xFF696969);
public static Color DodgerBlue { get { return FromArgb(0xFF1E90FF); } } public static Color DodgerBlue => FromArgb(0xFF1E90FF);
public static Color Firebrick { get { return FromArgb(0xFFB22222); } } public static Color Firebrick => FromArgb(0xFFB22222);
public static Color FloralWhite { get { return FromArgb(0xFFFFFAF0); } } public static Color FloralWhite => FromArgb(0xFFFFFAF0);
public static Color ForestGreen { get { return FromArgb(0xFF228B22); } } public static Color ForestGreen => FromArgb(0xFF228B22);
public static Color Fuchsia { get { return FromArgb(0xFFFF00FF); } } public static Color Fuchsia => FromArgb(0xFFFF00FF);
public static Color Gainsboro { get { return FromArgb(0xFFDCDCDC); } } public static Color Gainsboro => FromArgb(0xFFDCDCDC);
public static Color GhostWhite { get { return FromArgb(0xFFF8F8FF); } } public static Color GhostWhite => FromArgb(0xFFF8F8FF);
public static Color Gold { get { return FromArgb(0xFFFFD700); } } public static Color Gold => FromArgb(0xFFFFD700);
public static Color Goldenrod { get { return FromArgb(0xFFDAA520); } } public static Color Goldenrod => FromArgb(0xFFDAA520);
public static Color Gray { get { return FromArgb(0xFF808080); } } public static Color Gray => FromArgb(0xFF808080);
public static Color Green { get { return FromArgb(0xFF008000); } } public static Color Green => FromArgb(0xFF008000);
public static Color GreenYellow { get { return FromArgb(0xFFADFF2F); } } public static Color GreenYellow => FromArgb(0xFFADFF2F);
public static Color Honeydew { get { return FromArgb(0xFFF0FFF0); } } public static Color Honeydew => FromArgb(0xFFF0FFF0);
public static Color HotPink { get { return FromArgb(0xFFFF69B4); } } public static Color HotPink => FromArgb(0xFFFF69B4);
public static Color IndianRed { get { return FromArgb(0xFFCD5C5C); } } public static Color IndianRed => FromArgb(0xFFCD5C5C);
public static Color Indigo { get { return FromArgb(0xFF4B0082); } } public static Color Indigo => FromArgb(0xFF4B0082);
public static Color Ivory { get { return FromArgb(0xFFFFFFF0); } } public static Color Ivory => FromArgb(0xFFFFFFF0);
public static Color Khaki { get { return FromArgb(0xFFF0E68C); } } public static Color Khaki => FromArgb(0xFFF0E68C);
public static Color Lavender { get { return FromArgb(0xFFE6E6FA); } } public static Color Lavender => FromArgb(0xFFE6E6FA);
public static Color LavenderBlush { get { return FromArgb(0xFFFFF0F5); } } public static Color LavenderBlush => FromArgb(0xFFFFF0F5);
public static Color LawnGreen { get { return FromArgb(0xFF7CFC00); } } public static Color LawnGreen => FromArgb(0xFF7CFC00);
public static Color LemonChiffon { get { return FromArgb(0xFFFFFACD); } } public static Color LemonChiffon => FromArgb(0xFFFFFACD);
public static Color LightBlue { get { return FromArgb(0xFFADD8E6); } } public static Color LightBlue => FromArgb(0xFFADD8E6);
public static Color LightCoral { get { return FromArgb(0xFFF08080); } } public static Color LightCoral => FromArgb(0xFFF08080);
public static Color LightCyan { get { return FromArgb(0xFFE0FFFF); } } public static Color LightCyan => FromArgb(0xFFE0FFFF);
public static Color LightGoldenrodYellow { get { return FromArgb(0xFFFAFAD2); } } public static Color LightGoldenrodYellow => FromArgb(0xFFFAFAD2);
public static Color LightGray { get { return FromArgb(0xFFD3D3D3); } } public static Color LightGray => FromArgb(0xFFD3D3D3);
public static Color LightGreen { get { return FromArgb(0xFF90EE90); } } public static Color LightGreen => FromArgb(0xFF90EE90);
public static Color LightPink { get { return FromArgb(0xFFFFB6C1); } } public static Color LightPink => FromArgb(0xFFFFB6C1);
public static Color LightSalmon { get { return FromArgb(0xFFFFA07A); } } public static Color LightSalmon => FromArgb(0xFFFFA07A);
public static Color LightSeaGreen { get { return FromArgb(0xFF20B2AA); } } public static Color LightSeaGreen => FromArgb(0xFF20B2AA);
public static Color LightSkyBlue { get { return FromArgb(0xFF87CEFA); } } public static Color LightSkyBlue => FromArgb(0xFF87CEFA);
public static Color LightSlateGray { get { return FromArgb(0xFF778899); } } public static Color LightSlateGray => FromArgb(0xFF778899);
public static Color LightSteelBlue { get { return FromArgb(0xFFB0C4DE); } } public static Color LightSteelBlue => FromArgb(0xFFB0C4DE);
public static Color LightYellow { get { return FromArgb(0xFFFFFFE0); } } public static Color LightYellow => FromArgb(0xFFFFFFE0);
public static Color Lime { get { return FromArgb(0xFF00FF00); } } public static Color Lime => FromArgb(0xFF00FF00);
public static Color LimeGreen { get { return FromArgb(0xFF32CD32); } } public static Color LimeGreen => FromArgb(0xFF32CD32);
public static Color Linen { get { return FromArgb(0xFFFAF0E6); } } public static Color Linen => FromArgb(0xFFFAF0E6);
public static Color Magenta { get { return FromArgb(0xFFFF00FF); } } public static Color Magenta => FromArgb(0xFFFF00FF);
public static Color Maroon { get { return FromArgb(0xFF800000); } } public static Color Maroon => FromArgb(0xFF800000);
public static Color MediumAquamarine { get { return FromArgb(0xFF66CDAA); } } public static Color MediumAquamarine => FromArgb(0xFF66CDAA);
public static Color MediumBlue { get { return FromArgb(0xFF0000CD); } } public static Color MediumBlue => FromArgb(0xFF0000CD);
public static Color MediumOrchid { get { return FromArgb(0xFFBA55D3); } } public static Color MediumOrchid => FromArgb(0xFFBA55D3);
public static Color MediumPurple { get { return FromArgb(0xFF9370DB); } } public static Color MediumPurple => FromArgb(0xFF9370DB);
public static Color MediumSeaGreen { get { return FromArgb(0xFF3CB371); } } public static Color MediumSeaGreen => FromArgb(0xFF3CB371);
public static Color MediumSlateBlue { get { return FromArgb(0xFF7B68EE); } } public static Color MediumSlateBlue => FromArgb(0xFF7B68EE);
public static Color MediumSpringGreen { get { return FromArgb(0xFF00FA9A); } } public static Color MediumSpringGreen => FromArgb(0xFF00FA9A);
public static Color MediumTurquoise { get { return FromArgb(0xFF48D1CC); } } public static Color MediumTurquoise => FromArgb(0xFF48D1CC);
public static Color MediumVioletRed { get { return FromArgb(0xFFC71585); } } public static Color MediumVioletRed => FromArgb(0xFFC71585);
public static Color MidnightBlue { get { return FromArgb(0xFF191970); } } public static Color MidnightBlue => FromArgb(0xFF191970);
public static Color MintCream { get { return FromArgb(0xFFF5FFFA); } } public static Color MintCream => FromArgb(0xFFF5FFFA);
public static Color MistyRose { get { return FromArgb(0xFFFFE4E1); } } public static Color MistyRose => FromArgb(0xFFFFE4E1);
public static Color Moccasin { get { return FromArgb(0xFFFFE4B5); } } public static Color Moccasin => FromArgb(0xFFFFE4B5);
public static Color NavajoWhite { get { return FromArgb(0xFFFFDEAD); } } public static Color NavajoWhite => FromArgb(0xFFFFDEAD);
public static Color Navy { get { return FromArgb(0xFF000080); } } public static Color Navy => FromArgb(0xFF000080);
public static Color OldLace { get { return FromArgb(0xFFFDF5E6); } } public static Color OldLace => FromArgb(0xFFFDF5E6);
public static Color Olive { get { return FromArgb(0xFF808000); } } public static Color Olive => FromArgb(0xFF808000);
public static Color OliveDrab { get { return FromArgb(0xFF6B8E23); } } public static Color OliveDrab => FromArgb(0xFF6B8E23);
public static Color Orange { get { return FromArgb(0xFFFFA500); } } public static Color Orange => FromArgb(0xFFFFA500);
public static Color OrangeRed { get { return FromArgb(0xFFFF4500); } } public static Color OrangeRed => FromArgb(0xFFFF4500);
public static Color Orchid { get { return FromArgb(0xFFDA70D6); } } public static Color Orchid => FromArgb(0xFFDA70D6);
public static Color PaleGoldenrod { get { return FromArgb(0xFFEEE8AA); } } public static Color PaleGoldenrod => FromArgb(0xFFEEE8AA);
public static Color PaleGreen { get { return FromArgb(0xFF98FB98); } } public static Color PaleGreen => FromArgb(0xFF98FB98);
public static Color PaleTurquoise { get { return FromArgb(0xFFAFEEEE); } } public static Color PaleTurquoise => FromArgb(0xFFAFEEEE);
public static Color PaleVioletRed { get { return FromArgb(0xFFDB7093); } } public static Color PaleVioletRed => FromArgb(0xFFDB7093);
public static Color PapayaWhip { get { return FromArgb(0xFFFFEFD5); } } public static Color PapayaWhip => FromArgb(0xFFFFEFD5);
public static Color PeachPuff { get { return FromArgb(0xFFFFDAB9); } } public static Color PeachPuff => FromArgb(0xFFFFDAB9);
public static Color Peru { get { return FromArgb(0xFFCD853F); } } public static Color Peru => FromArgb(0xFFCD853F);
public static Color Pink { get { return FromArgb(0xFFFFC0CB); } } public static Color Pink => FromArgb(0xFFFFC0CB);
public static Color Plum { get { return FromArgb(0xFFDDA0DD); } } public static Color Plum => FromArgb(0xFFDDA0DD);
public static Color PowderBlue { get { return FromArgb(0xFFB0E0E6); } } public static Color PowderBlue => FromArgb(0xFFB0E0E6);
public static Color Purple { get { return FromArgb(0xFF800080); } } public static Color Purple => FromArgb(0xFF800080);
public static Color Red { get { return FromArgb(0xFFFF0000); } } public static Color Red => FromArgb(0xFFFF0000);
public static Color RosyBrown { get { return FromArgb(0xFFBC8F8F); } } public static Color RosyBrown => FromArgb(0xFFBC8F8F);
public static Color RoyalBlue { get { return FromArgb(0xFF4169E1); } } public static Color RoyalBlue => FromArgb(0xFF4169E1);
public static Color SaddleBrown { get { return FromArgb(0xFF8B4513); } } public static Color SaddleBrown => FromArgb(0xFF8B4513);
public static Color Salmon { get { return FromArgb(0xFFFA8072); } } public static Color Salmon => FromArgb(0xFFFA8072);
public static Color SandyBrown { get { return FromArgb(0xFFF4A460); } } public static Color SandyBrown => FromArgb(0xFFF4A460);
public static Color SeaGreen { get { return FromArgb(0xFF2E8B57); } } public static Color SeaGreen => FromArgb(0xFF2E8B57);
public static Color SeaShell { get { return FromArgb(0xFFFFF5EE); } } public static Color SeaShell => FromArgb(0xFFFFF5EE);
public static Color Sienna { get { return FromArgb(0xFFA0522D); } } public static Color Sienna => FromArgb(0xFFA0522D);
public static Color Silver { get { return FromArgb(0xFFC0C0C0); } } public static Color Silver => FromArgb(0xFFC0C0C0);
public static Color SkyBlue { get { return FromArgb(0xFF87CEEB); } } public static Color SkyBlue => FromArgb(0xFF87CEEB);
public static Color SlateBlue { get { return FromArgb(0xFF6A5ACD); } } public static Color SlateBlue => FromArgb(0xFF6A5ACD);
public static Color SlateGray { get { return FromArgb(0xFF708090); } } public static Color SlateGray => FromArgb(0xFF708090);
public static Color Snow { get { return FromArgb(0xFFFFFAFA); } } public static Color Snow => FromArgb(0xFFFFFAFA);
public static Color SpringGreen { get { return FromArgb(0xFF00FF7F); } } public static Color SpringGreen => FromArgb(0xFF00FF7F);
public static Color SteelBlue { get { return FromArgb(0xFF4682B4); } } public static Color SteelBlue => FromArgb(0xFF4682B4);
public static Color Tan { get { return FromArgb(0xFFD2B48C); } } public static Color Tan => FromArgb(0xFFD2B48C);
public static Color Teal { get { return FromArgb(0xFF008080); } } public static Color Teal => FromArgb(0xFF008080);
public static Color Thistle { get { return FromArgb(0xFFD8BFD8); } } public static Color Thistle => FromArgb(0xFFD8BFD8);
public static Color Tomato { get { return FromArgb(0xFFFF6347); } } public static Color Tomato => FromArgb(0xFFFF6347);
public static Color Turquoise { get { return FromArgb(0xFF40E0D0); } } public static Color Turquoise => FromArgb(0xFF40E0D0);
public static Color Violet { get { return FromArgb(0xFFEE82EE); } } public static Color Violet => FromArgb(0xFFEE82EE);
public static Color Wheat { get { return FromArgb(0xFFF5DEB3); } } public static Color Wheat => FromArgb(0xFFF5DEB3);
public static Color White { get { return FromArgb(0xFFFFFFFF); } } public static Color White => FromArgb(0xFFFFFFFF);
public static Color WhiteSmoke { get { return FromArgb(0xFFF5F5F5); } } public static Color WhiteSmoke => FromArgb(0xFFF5F5F5);
public static Color Yellow { get { return FromArgb(0xFFFFFF00); } } public static Color Yellow => FromArgb(0xFFFFFF00);
public static Color YellowGreen { get { return FromArgb(0xFF9ACD32); } } public static Color YellowGreen => FromArgb(0xFF9ACD32);
} }
} }

View File

@@ -32,16 +32,13 @@ namespace OpenRA.Primitives
public ConcurrentCache(Func<T, U> loader) public ConcurrentCache(Func<T, U> loader)
: this(loader, EqualityComparer<T>.Default) { } : this(loader, EqualityComparer<T>.Default) { }
public U this[T key] public U this[T key] => cache.GetOrAdd(key, loader);
{
get { return cache.GetOrAdd(key, loader); }
}
public bool ContainsKey(T key) { return cache.ContainsKey(key); } public bool ContainsKey(T key) { return cache.ContainsKey(key); }
public bool TryGetValue(T key, out U value) { return cache.TryGetValue(key, out value); } public bool TryGetValue(T key, out U value) { return cache.TryGetValue(key, out value); }
public int Count { get { return cache.Count; } } public int Count => cache.Count;
public ICollection<T> Keys { get { return cache.Keys; } } public ICollection<T> Keys => cache.Keys;
public ICollection<U> Values { get { return cache.Values; } } public ICollection<U> Values => cache.Values;
public IEnumerator<KeyValuePair<T, U>> GetEnumerator() { return cache.GetEnumerator(); } public IEnumerator<KeyValuePair<T, U>> GetEnumerator() { return cache.GetEnumerator(); }
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { return GetEnumerator(); } System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { return GetEnumerator(); }
} }

View File

@@ -88,7 +88,7 @@ namespace OpenRA.Primitives
} }
} }
public static long Mask { get { return allBits; } } public static long Mask => allBits;
} }
// Opitmized BitSet to be used only when guaranteed to be no more than 64 values. // Opitmized BitSet to be used only when guaranteed to be no more than 64 values.
@@ -124,7 +124,7 @@ namespace OpenRA.Primitives
public override bool Equals(object obj) { return obj is LongBitSet<T> && Equals((LongBitSet<T>)obj); } public override bool Equals(object obj) { return obj is LongBitSet<T> && Equals((LongBitSet<T>)obj); }
public override int GetHashCode() { return bits.GetHashCode(); } public override int GetHashCode() { return bits.GetHashCode(); }
public bool IsEmpty { get { return bits == 0; } } public bool IsEmpty => bits == 0;
public bool IsProperSubsetOf(LongBitSet<T> other) public bool IsProperSubsetOf(LongBitSet<T> other)
{ {

View File

@@ -108,30 +108,18 @@ namespace OpenRA.Primitives
throw new NotSupportedException(); throw new NotSupportedException();
} }
public override bool CanRead public override bool CanRead => Stream1.CanRead && Stream2.CanRead;
{
get { return Stream1.CanRead && Stream2.CanRead; }
}
public override bool CanSeek public override bool CanSeek => Stream1.CanSeek && Stream2.CanSeek;
{
get { return Stream1.CanSeek && Stream2.CanSeek; }
}
public override bool CanWrite public override bool CanWrite => false;
{
get { return false; }
}
public override long Length public override long Length => VirtualLength;
{
get { return VirtualLength; }
}
public override long Position public override long Position
{ {
get { return position; } get => position;
set { Seek(value, SeekOrigin.Begin); } set => Seek(value, SeekOrigin.Begin);
} }
} }
} }

View File

@@ -57,9 +57,6 @@ namespace OpenRA.Primitives
OnRemoveAt(this, index); OnRemoveAt(this, index);
} }
public IEnumerable ObservedItems public IEnumerable ObservedItems => Items;
{
get { return Items; }
}
} }
} }

View File

@@ -74,8 +74,8 @@ namespace OpenRA.Primitives
return innerDict.ContainsKey(key); return innerDict.ContainsKey(key);
} }
public ICollection<TKey> Keys { get { return innerDict.Keys; } } public ICollection<TKey> Keys => innerDict.Keys;
public ICollection<TValue> Values { get { return innerDict.Values; } } public ICollection<TValue> Values => innerDict.Values;
public bool TryGetValue(TKey key, out TValue value) public bool TryGetValue(TKey key, out TValue value)
{ {
@@ -84,8 +84,8 @@ namespace OpenRA.Primitives
public TValue this[TKey key] public TValue this[TKey key]
{ {
get { return innerDict[key]; } get => innerDict[key];
set { innerDict[key] = value; } set => innerDict[key] = value;
} }
public void Clear() public void Clear()
@@ -94,10 +94,7 @@ namespace OpenRA.Primitives
OnRefresh(this); OnRefresh(this);
} }
public int Count public int Count => innerDict.Count;
{
get { return innerDict.Count; }
}
public void Add(KeyValuePair<TKey, TValue> item) public void Add(KeyValuePair<TKey, TValue> item)
{ {
@@ -114,10 +111,7 @@ namespace OpenRA.Primitives
innerDict.CopyTo(array, arrayIndex); innerDict.CopyTo(array, arrayIndex);
} }
public bool IsReadOnly public bool IsReadOnly => innerDict.IsReadOnly;
{
get { return innerDict.IsReadOnly; }
}
public bool Remove(KeyValuePair<TKey, TValue> item) public bool Remove(KeyValuePair<TKey, TValue> item)
{ {
@@ -134,9 +128,6 @@ namespace OpenRA.Primitives
return innerDict.GetEnumerator(); return innerDict.GetEnumerator();
} }
public IEnumerable ObservedItems public IEnumerable ObservedItems => innerDict.Keys;
{
get { return innerDict.Keys; }
}
} }
} }

View File

@@ -66,7 +66,7 @@ namespace OpenRA.Primitives
OnRefresh(this); OnRefresh(this);
} }
public int Count { get { return innerList.Count; } } public int Count => innerList.Count;
public int IndexOf(T item) { return innerList.IndexOf(item); } public int IndexOf(T item) { return innerList.IndexOf(item); }
public bool Contains(T item) { return innerList.Contains(item); } public bool Contains(T item) { return innerList.Contains(item); }
@@ -78,10 +78,7 @@ namespace OpenRA.Primitives
public T this[int index] public T this[int index]
{ {
get get => innerList[index];
{
return innerList[index];
}
set set
{ {
@@ -106,14 +103,8 @@ namespace OpenRA.Primitives
return innerList.GetEnumerator(); return innerList.GetEnumerator();
} }
public IEnumerable ObservedItems public IEnumerable ObservedItems => innerList;
{
get { return innerList; }
}
public bool IsReadOnly public bool IsReadOnly => innerList.IsReadOnly;
{
get { return innerList.IsReadOnly; }
}
} }
} }

View File

@@ -46,16 +46,16 @@ namespace OpenRA.Primitives
{ } { }
/// <summary>Gets the value for the specified player. This is slower than specifying a player index.</summary> /// <summary>Gets the value for the specified player. This is slower than specifying a player index.</summary>
public T this[Player player] { get { return valueByPlayer[player]; } } public T this[Player player] => valueByPlayer[player];
/// <summary>Gets the value for the specified player index.</summary> /// <summary>Gets the value for the specified player index.</summary>
public T this[int playerIndex] { get { return valueByPlayerIndex[playerIndex]; } } public T this[int playerIndex] => valueByPlayerIndex[playerIndex];
public int Count { get { return valueByPlayerIndex.Length; } } public int Count => valueByPlayerIndex.Length;
public IEnumerator<T> GetEnumerator() { return ((IEnumerable<T>)valueByPlayerIndex).GetEnumerator(); } public IEnumerator<T> GetEnumerator() { return ((IEnumerable<T>)valueByPlayerIndex).GetEnumerator(); }
ICollection<Player> IReadOnlyDictionary<Player, T>.Keys { get { return valueByPlayer.Keys; } } ICollection<Player> IReadOnlyDictionary<Player, T>.Keys => valueByPlayer.Keys;
ICollection<T> IReadOnlyDictionary<Player, T>.Values { get { return valueByPlayer.Values; } } ICollection<T> IReadOnlyDictionary<Player, T>.Values => valueByPlayer.Values;
bool IReadOnlyDictionary<Player, T>.ContainsKey(Player key) { return valueByPlayer.ContainsKey(key); } bool IReadOnlyDictionary<Player, T>.ContainsKey(Player key) { return valueByPlayer.ContainsKey(key); }
bool IReadOnlyDictionary<Player, T>.TryGetValue(Player key, out T value) { return valueByPlayer.TryGetValue(key, out value); } bool IReadOnlyDictionary<Player, T>.TryGetValue(Player key, out T value) { return valueByPlayer.TryGetValue(key, out value); }
IEnumerator<KeyValuePair<Player, T>> IEnumerable<KeyValuePair<Player, T>>.GetEnumerator() { return valueByPlayer.GetEnumerator(); } IEnumerator<KeyValuePair<Player, T>> IEnumerable<KeyValuePair<Player, T>>.GetEnumerator() { return valueByPlayer.GetEnumerator(); }

View File

@@ -57,7 +57,8 @@ namespace OpenRA.Primitives
} }
} }
public bool IsEmpty { get { return BoundingRect.IsEmpty; } } public bool IsEmpty => BoundingRect.IsEmpty;
public bool Contains(int2 xy) public bool Contains(int2 xy)
{ {
return isRectangle ? BoundingRect.Contains(xy) : Vertices.PolygonContains(xy); return isRectangle ? BoundingRect.Contains(xy) : Vertices.PolygonContains(xy);

View File

@@ -59,7 +59,7 @@ namespace OpenRA.Primitives
} }
} }
public bool Empty { get { return level == 0; } } public bool Empty => level == 0;
T At(int level, int index) { return items[level][index]; } T At(int level, int index) { return items[level][index]; }
T Above(int level, int index) { return items[level - 1][index >> 1]; } T Above(int level, int index) { return items[level - 1][index >> 1]; }

View File

@@ -35,15 +35,16 @@ namespace OpenRA.Primitives
baseStream = stream; baseStream = stream;
} }
public sealed override bool CanSeek { get { return false; } } public sealed override bool CanSeek => false;
public sealed override bool CanRead { get { return true; } } public sealed override bool CanRead => true;
public sealed override bool CanWrite { get { return false; } } public sealed override bool CanWrite => false;
public override long Length => throw new NotSupportedException();
public override long Length { get { throw new NotSupportedException(); } }
public sealed override long Position public sealed override long Position
{ {
get { throw new NotSupportedException(); } get => throw new NotSupportedException();
set { throw new NotSupportedException(); } set => throw new NotSupportedException();
} }
public sealed override long Seek(long offset, SeekOrigin origin) { throw new NotSupportedException(); } public sealed override long Seek(long offset, SeekOrigin origin) { throw new NotSupportedException(); }

View File

@@ -73,13 +73,14 @@ namespace OpenRA
return dict.TryGetValue(key, out value); return dict.TryGetValue(key, out value);
} }
public int Count { get { return dict.Count; } } public int Count => dict.Count;
public TValue this[TKey key] { get { return dict[key]; } } public TValue this[TKey key] => dict[key];
public ICollection<TKey> Keys { get { return dict.Keys; } } public ICollection<TKey> Keys => dict.Keys;
public ICollection<TValue> Values => dict.Values;
public ICollection<TValue> Values { get { return dict.Values; } }
#endregion #endregion
#region IEnumerable implementation #region IEnumerable implementation

View File

@@ -72,9 +72,10 @@ namespace OpenRA
#endregion #endregion
#region IReadOnlyList implementation #region IReadOnlyList implementation
public int Count { get { return list.Count; } } public int Count => list.Count;
public T this[int index] => list[index];
public T this[int index] { get { return list[index]; } }
#endregion #endregion
} }
} }

View File

@@ -58,18 +58,18 @@ namespace OpenRA.Primitives
Height = size.Height; Height = size.Height;
} }
public int Left { get { return X; } } public int Left => X;
public int Right { get { return X + Width; } } public int Right => X + Width;
public int Top { get { return Y; } } public int Top => Y;
public int Bottom { get { return Y + Height; } } public int Bottom => Y + Height;
public bool IsEmpty { get { return X == 0 && Y == 0 && Width == 0 && Height == 0; } } public bool IsEmpty => X == 0 && Y == 0 && Width == 0 && Height == 0;
public int2 Location { get { return new int2(X, Y); } } public int2 Location => new int2(X, Y);
public Size Size { get { return new Size(Width, Height); } } public Size Size => new Size(Width, Height);
public int2 TopLeft { get { return Location; } } public int2 TopLeft => Location;
public int2 TopRight { get { return new int2(X + Width, Y); } } public int2 TopRight => new int2(X + Width, Y);
public int2 BottomLeft { get { return new int2(X, Y + Height); } } public int2 BottomLeft => new int2(X, Y + Height);
public int2 BottomRight { get { return new int2(X + Width, Y + Height); } } public int2 BottomRight => new int2(X + Width, Y + Height);
public bool Contains(int x, int y) public bool Contains(int x, int y)
{ {

View File

@@ -48,15 +48,16 @@ namespace OpenRA.Primitives
stream.Seek(BaseOffset, SeekOrigin.Begin); stream.Seek(BaseOffset, SeekOrigin.Begin);
} }
public override bool CanSeek { get { return true; } } public override bool CanSeek => true;
public override bool CanRead { get { return BaseStream.CanRead; } } public override bool CanRead => BaseStream.CanRead;
public override bool CanWrite { get { return BaseStream.CanWrite; } } public override bool CanWrite => BaseStream.CanWrite;
public override long Length => BaseCount;
public override long Length { get { return BaseCount; } }
public override long Position public override long Position
{ {
get { return BaseStream.Position - BaseOffset; } get => BaseStream.Position - BaseOffset;
set { BaseStream.Position = BaseOffset + value; } set => BaseStream.Position = BaseOffset + value;
} }
public override int ReadByte() public override int ReadByte()
@@ -105,18 +106,18 @@ namespace OpenRA.Primitives
public override void SetLength(long value) { throw new NotSupportedException(); } public override void SetLength(long value) { throw new NotSupportedException(); }
public override bool CanTimeout { get { return BaseStream.CanTimeout; } } public override bool CanTimeout => BaseStream.CanTimeout;
public override int ReadTimeout public override int ReadTimeout
{ {
get { return BaseStream.ReadTimeout; } get => BaseStream.ReadTimeout;
set { BaseStream.ReadTimeout = value; } set => BaseStream.ReadTimeout = value;
} }
public override int WriteTimeout public override int WriteTimeout
{ {
get { return BaseStream.WriteTimeout; } get => BaseStream.WriteTimeout;
set { BaseStream.WriteTimeout = value; } set => BaseStream.WriteTimeout = value;
} }
protected override void Dispose(bool disposing) protected override void Dispose(bool disposing)

View File

@@ -44,7 +44,7 @@ namespace OpenRA.Primitives
Height = height; Height = height;
} }
public bool IsEmpty { get { return Width == 0 && Height == 0; } } public bool IsEmpty => Width == 0 && Height == 0;
public bool Equals(Size other) public bool Equals(Size other)
{ {

View File

@@ -135,8 +135,8 @@ namespace OpenRA.Primitives
} }
} }
public IEnumerable<Rectangle> ItemBounds { get { return itemBounds.Values; } } public IEnumerable<Rectangle> ItemBounds => itemBounds.Values;
public IEnumerable<T> Items { get { return itemBounds.Keys; } } public IEnumerable<T> Items => itemBounds.Keys;
} }
} }

View File

@@ -93,8 +93,8 @@ namespace OpenRA
public static float2 Max(float2 a, float2 b) { return new float2(Math.Max(a.X, b.X), Math.Max(a.Y, b.Y)); } public static float2 Max(float2 a, float2 b) { return new float2(Math.Max(a.X, b.X), Math.Max(a.Y, b.Y)); }
public static float2 Min(float2 a, float2 b) { return new float2(Math.Min(a.X, b.X), Math.Min(a.Y, b.Y)); } public static float2 Min(float2 a, float2 b) { return new float2(Math.Min(a.X, b.X), Math.Min(a.Y, b.Y)); }
public float LengthSquared { get { return X * X + Y * Y; } } public float LengthSquared => X * X + Y * Y;
public float Length { get { return (float)Math.Sqrt(LengthSquared); } } public float Length => (float)Math.Sqrt(LengthSquared);
} }
public class EWMA public class EWMA

View File

@@ -20,7 +20,7 @@ namespace OpenRA
public readonly struct float3 : IEquatable<float3> public readonly struct float3 : IEquatable<float3>
{ {
public readonly float X, Y, Z; public readonly float X, Y, Z;
public float2 XY { get { return new float2(X, Y); } } public float2 XY => new float2(X, Y);
public float3(float x, float y, float z) { X = x; Y = y; Z = z; } public float3(float x, float y, float z) { X = x; Y = y; Z = z; }
public float3(float2 xy, float z) { X = xy.X; Y = xy.Y; Z = z; } public float3(float2 xy, float z) { X = xy.X; Y = xy.Y; Z = z; }

View File

@@ -43,8 +43,8 @@ namespace OpenRA
public int2 Sign() { return new int2(Math.Sign(X), Math.Sign(Y)); } public int2 Sign() { return new int2(Math.Sign(X), Math.Sign(Y)); }
public int2 Abs() { return new int2(Math.Abs(X), Math.Abs(Y)); } public int2 Abs() { return new int2(Math.Abs(X), Math.Abs(Y)); }
public int LengthSquared { get { return X * X + Y * Y; } } public int LengthSquared => X * X + Y * Y;
public int Length { get { return Exts.ISqrt(LengthSquared); } } public int Length => Exts.ISqrt(LengthSquared);
public int2 WithX(int newX) public int2 WithX(int newX)
{ {

View File

@@ -32,13 +32,7 @@ namespace OpenRA
public SpriteRenderer SpriteRenderer { get; private set; } public SpriteRenderer SpriteRenderer { get; private set; }
public RgbaSpriteRenderer RgbaSpriteRenderer { get; private set; } public RgbaSpriteRenderer RgbaSpriteRenderer { get; private set; }
public bool WindowHasInputFocus public bool WindowHasInputFocus => Window.HasInputFocus;
{
get
{
return Window.HasInputFocus;
}
}
public IReadOnlyDictionary<string, SpriteFont> Fonts; public IReadOnlyDictionary<string, SpriteFont> Fonts;
@@ -306,21 +300,18 @@ namespace OpenRA
CurrentBatchRenderer = null; CurrentBatchRenderer = null;
} }
public Size Resolution { get { return Window.EffectiveWindowSize; } } public Size Resolution => Window.EffectiveWindowSize;
public Size NativeResolution { get { return Window.NativeWindowSize; } } public Size NativeResolution => Window.NativeWindowSize;
public float WindowScale { get { return Window.EffectiveWindowScale; } } public float WindowScale => Window.EffectiveWindowScale;
public float NativeWindowScale { get { return Window.NativeWindowScale; } } public float NativeWindowScale => Window.NativeWindowScale;
public GLProfile GLProfile { get { return Window.GLProfile; } } public GLProfile GLProfile => Window.GLProfile;
public GLProfile[] SupportedGLProfiles { get { return Window.SupportedGLProfiles; } } public GLProfile[] SupportedGLProfiles => Window.SupportedGLProfiles;
public interface IBatchRenderer { void Flush(); } public interface IBatchRenderer { void Flush(); }
public IBatchRenderer CurrentBatchRenderer public IBatchRenderer CurrentBatchRenderer
{ {
get get => currentBatchRenderer;
{
return currentBatchRenderer;
}
set set
{ {
@@ -469,24 +460,15 @@ namespace OpenRA
return Window.SetClipboardText(text); return Window.SetClipboardText(text);
} }
public string GLVersion public string GLVersion => Context.GLVersion;
{
get { return Context.GLVersion; }
}
public IFont CreateFont(byte[] data) public IFont CreateFont(byte[] data)
{ {
return platform.CreateFont(data); return platform.CreateFont(data);
} }
public int DisplayCount public int DisplayCount => Window.DisplayCount;
{
get { return Window.DisplayCount; }
}
public int CurrentDisplay public int CurrentDisplay => Window.CurrentDisplay;
{
get { return Window.CurrentDisplay; }
}
} }
} }

View File

@@ -27,7 +27,7 @@ namespace OpenRA.Server
public int MostRecentFrame = 0; public int MostRecentFrame = 0;
public bool Validated; public bool Validated;
public long TimeSinceLastResponse { get { return Game.RunTime - lastReceivedTime; } } public long TimeSinceLastResponse => Game.RunTime - lastReceivedTime;
public bool TimeoutMessageShown = false; public bool TimeoutMessageShown = false;
long lastReceivedTime = 0; long lastReceivedTime = 0;

View File

@@ -78,8 +78,8 @@ namespace OpenRA.Server
public ServerState State public ServerState State
{ {
get { return internalState; } get => internalState;
protected set { internalState = value; } protected set => internalState = value;
} }
public static void SyncClientToPlayerReference(Session.Client c, PlayerReference pr) public static void SyncClientToPlayerReference(Session.Client c, PlayerReference pr)

View File

@@ -200,7 +200,7 @@ namespace OpenRA
Action onMusicComplete; Action onMusicComplete;
public bool MusicPlaying { get; private set; } public bool MusicPlaying { get; private set; }
public MusicInfo CurrentMusic { get { return currentMusic; } } public MusicInfo CurrentMusic => currentMusic;
public void PlayMusic(MusicInfo m) public void PlayMusic(MusicInfo m)
{ {
@@ -277,10 +277,7 @@ namespace OpenRA
float soundVolumeModifier = 1.0f; float soundVolumeModifier = 1.0f;
public float SoundVolumeModifier public float SoundVolumeModifier
{ {
get get => soundVolumeModifier;
{
return soundVolumeModifier;
}
set set
{ {
@@ -289,13 +286,11 @@ namespace OpenRA
} }
} }
float InternalSoundVolume { get { return SoundVolume * soundVolumeModifier; } } float InternalSoundVolume => SoundVolume * soundVolumeModifier;
public float SoundVolume public float SoundVolume
{ {
get get => Game.Settings.Sound.SoundVolume;
{
return Game.Settings.Sound.SoundVolume;
}
set set
{ {
@@ -306,10 +301,7 @@ namespace OpenRA
public float MusicVolume public float MusicVolume
{ {
get get => Game.Settings.Sound.MusicVolume;
{
return Game.Settings.Sound.MusicVolume;
}
set set
{ {
@@ -321,10 +313,7 @@ namespace OpenRA
public float VideoVolume public float VideoVolume
{ {
get get => Game.Settings.Sound.VideoVolume;
{
return Game.Settings.Sound.VideoVolume;
}
set set
{ {
@@ -334,15 +323,9 @@ namespace OpenRA
} }
} }
public float MusicSeekPosition public float MusicSeekPosition => music != null ? music.SeekPosition : 0;
{
get { return music != null ? music.SeekPosition : 0; }
}
public float VideoSeekPosition public float VideoSeekPosition => video != null ? video.SeekPosition : 0;
{
get { return video != null ? video.SeekPosition : 0; }
}
// Returns true if played successfully // Returns true if played successfully
public bool PlayPredefined(SoundType soundType, Ruleset ruleset, Player p, Actor voicedActor, string type, string definition, string variant, public bool PlayPredefined(SoundType soundType, Ruleset ruleset, Player p, Actor voicedActor, string type, string definition, string variant,

View File

@@ -18,7 +18,7 @@ namespace OpenRA
{ {
Dictionary<string, string> args = new Dictionary<string, string>(); Dictionary<string, string> args = new Dictionary<string, string>();
public static Arguments Empty { get { return new Arguments(); } } public static Arguments Empty => new Arguments();
public Arguments(params string[] src) public Arguments(params string[] src)
{ {

View File

@@ -74,7 +74,7 @@ namespace OpenRA.Support
Log.Write("perf", FormatString, ElapsedMs, Indentation + name); Log.Write("perf", FormatString, ElapsedMs, Indentation + name);
} }
float ElapsedMs { get { return 1000f * ticks / Stopwatch.Frequency; } } float ElapsedMs => 1000f * ticks / Stopwatch.Frequency;
public static void LogLongTick(long startStopwatchTicks, long endStopwatchTicks, string name, object item) public static void LogLongTick(long startStopwatchTicks, long endStopwatchTicks, string name, object item)
{ {
@@ -85,13 +85,7 @@ namespace OpenRA.Support
"[" + Game.LocalTick + "] " + name + ": " + label); "[" + Game.LocalTick + "] " + name + ": " + label);
} }
public static long LongTickThresholdInStopwatchTicks public static long LongTickThresholdInStopwatchTicks => (long)(Stopwatch.Frequency * Game.Settings.Debug.LongTickThresholdMs / 1000f);
{
get
{
return (long)(Stopwatch.Frequency * Game.Settings.Debug.LongTickThresholdMs / 1000f);
}
}
#region Formatting helpers #region Formatting helpers
static string GetHeader(string indentation, string label) static string GetHeader(string indentation, string label)

View File

@@ -24,7 +24,7 @@ namespace OpenRA.Support
public readonly string Expression; public readonly string Expression;
readonly HashSet<string> variables = new HashSet<string>(); readonly HashSet<string> variables = new HashSet<string>();
public IEnumerable<string> Variables { get { return variables; } } public IEnumerable<string> Variables => variables;
enum CharClass { Whitespace, Operator, Mixed, Id, Digit } enum CharClass { Whitespace, Operator, Mixed, Id, Digit }
@@ -323,16 +323,16 @@ namespace OpenRA.Support
public readonly TokenType Type; public readonly TokenType Type;
public readonly int Index; public readonly int Index;
public virtual string Symbol { get { return TokenTypeInfos[(int)Type].Symbol; } } public virtual string Symbol => TokenTypeInfos[(int)Type].Symbol;
public int Precedence { get { return (int)TokenTypeInfos[(int)Type].Precedence; } } public int Precedence => (int)TokenTypeInfos[(int)Type].Precedence;
public Sides OperandSides { get { return TokenTypeInfos[(int)Type].OperandSides; } } public Sides OperandSides => TokenTypeInfos[(int)Type].OperandSides;
public Associativity Associativity { get { return TokenTypeInfos[(int)Type].Associativity; } } public Associativity Associativity => TokenTypeInfos[(int)Type].Associativity;
public bool LeftOperand { get { return ((int)TokenTypeInfos[(int)Type].OperandSides & (int)Sides.Left) != 0; } } public bool LeftOperand => ((int)TokenTypeInfos[(int)Type].OperandSides & (int)Sides.Left) != 0;
public bool RightOperand { get { return ((int)TokenTypeInfos[(int)Type].OperandSides & (int)Sides.Right) != 0; } } public bool RightOperand => ((int)TokenTypeInfos[(int)Type].OperandSides & (int)Sides.Right) != 0;
public Grouping Opens { get { return TokenTypeInfos[(int)Type].Opens; } } public Grouping Opens => TokenTypeInfos[(int)Type].Opens;
public Grouping Closes { get { return TokenTypeInfos[(int)Type].Closes; } } public Grouping Closes => TokenTypeInfos[(int)Type].Closes;
public Token(TokenType type, int index) public Token(TokenType type, int index)
{ {
@@ -559,7 +559,7 @@ namespace OpenRA.Support
{ {
public readonly string Name; public readonly string Name;
public override string Symbol { get { return Name; } } public override string Symbol => Name;
public VariableToken(int index, string symbol) public VariableToken(int index, string symbol)
: base(TokenType.Variable, index) { Name = symbol; } : base(TokenType.Variable, index) { Name = symbol; }
@@ -570,7 +570,7 @@ namespace OpenRA.Support
public readonly int Value; public readonly int Value;
readonly string symbol; readonly string symbol;
public override string Symbol { get { return symbol; } } public override string Symbol => symbol;
public NumberToken(int index, string symbol) public NumberToken(int index, string symbol)
: base(TokenType.Number, index) : base(TokenType.Number, index)

View File

@@ -208,8 +208,8 @@ namespace OpenRA
public void Reset() { index = actors.BinarySearchMany(actor) - 1; } public void Reset() { index = actors.BinarySearchMany(actor) - 1; }
public bool MoveNext() { return ++index < actors.Count && actors[index].ActorID == actor; } public bool MoveNext() { return ++index < actors.Count && actors[index].ActorID == actor; }
public T Current { get { return traits[index]; } } public T Current => traits[index];
object System.Collections.IEnumerator.Current { get { return Current; } } object System.Collections.IEnumerator.Current => Current;
public void Dispose() { } public void Dispose() { }
} }
@@ -272,8 +272,8 @@ namespace OpenRA
public void Reset() { index = -1; } public void Reset() { index = -1; }
public bool MoveNext() { return ++index < actors.Count; } public bool MoveNext() { return ++index < actors.Count; }
public TraitPair<T> Current { get { return new TraitPair<T>(actors[index], traits[index]); } } public TraitPair<T> Current => new TraitPair<T>(actors[index], traits[index]);
object System.Collections.IEnumerator.Current { get { return Current; } } object System.Collections.IEnumerator.Current => Current;
public void Dispose() { } public void Dispose() { }
} }

View File

@@ -21,7 +21,8 @@ namespace OpenRA.Traits
{ {
readonly World world; readonly World world;
[Sync] [Sync]
public bool Paused { get { return world.Paused; } } public bool Paused => world.Paused;
public DebugPauseState(World world) { this.world = world; } public DebugPauseState(World world) { this.world = world; }
} }
} }

View File

@@ -43,7 +43,7 @@ namespace OpenRA.Traits
public Player Owner { get; private set; } public Player Owner { get; private set; }
public BitSet<TargetableType> TargetTypes { get; private set; } public BitSet<TargetableType> TargetTypes { get; private set; }
public IEnumerable<WPos> TargetablePositions { get { return targetablePositions; } } public IEnumerable<WPos> TargetablePositions => targetablePositions;
public ITooltipInfo TooltipInfo { get; private set; } public ITooltipInfo TooltipInfo { get; private set; }
public Player TooltipOwner { get; private set; } public Player TooltipOwner { get; private set; }
@@ -108,11 +108,11 @@ namespace OpenRA.Traits
UpdateVisibility(); UpdateVisibility();
} }
public uint ID { get { return actor.ActorID; } } public uint ID => actor.ActorID;
public bool IsValid { get { return Owner != null; } } public bool IsValid => Owner != null;
public ActorInfo Info { get { return actor.Info; } } public ActorInfo Info => actor.Info;
public Actor Actor { get { return !actor.IsDead ? actor : null; } } public Actor Actor => !actor.IsDead ? actor : null;
public Player Viewer { get { return viewer; } } public Player Viewer => viewer;
public void RefreshState() public void RefreshState()
{ {
@@ -198,7 +198,7 @@ namespace OpenRA.Traits
return Renderables; return Renderables;
} }
public bool HasRenderables { get { return !Shrouded && Renderables.Any(); } } public bool HasRenderables => !Shrouded && Renderables.Any();
public override string ToString() public override string ToString()
{ {

View File

@@ -104,10 +104,7 @@ namespace OpenRA.Traits
bool disabled; bool disabled;
public bool Disabled public bool Disabled
{ {
get get => disabled;
{
return disabled;
}
set set
{ {
@@ -119,7 +116,7 @@ namespace OpenRA.Traits
} }
bool fogEnabled; bool fogEnabled;
public bool FogEnabled { get { return !Disabled && fogEnabled; } } public bool FogEnabled => !Disabled && fogEnabled;
public bool ExploreMapEnabled { get; private set; } public bool ExploreMapEnabled { get; private set; }
public int Hash { get; private set; } public int Hash { get; private set; }

View File

@@ -88,8 +88,8 @@ namespace OpenRA.Traits
public static Target FromActor(Actor a) { return a != null ? new Target(a) : Invalid; } public static Target FromActor(Actor a) { return a != null ? new Target(a) : Invalid; }
public static Target FromFrozenActor(FrozenActor fa) { return new Target(fa); } public static Target FromFrozenActor(FrozenActor fa) { return new Target(fa); }
public Actor Actor { get { return actor; } } public Actor Actor => actor;
public FrozenActor FrozenActor { get { return frozen; } } public FrozenActor FrozenActor => frozen;
public TargetType Type public TargetType Type
{ {
@@ -225,10 +225,10 @@ namespace OpenRA.Traits
} }
// Expose internal state for serialization by the orders code *only* // Expose internal state for serialization by the orders code *only*
internal TargetType SerializableType { get { return type; } } internal TargetType SerializableType => type;
internal Actor SerializableActor { get { return actor; } } internal Actor SerializableActor => actor;
internal CPos? SerializableCell { get { return cell; } } internal CPos? SerializableCell => cell;
internal SubCell? SerializableSubCell { get { return subCell; } } internal SubCell? SerializableSubCell => subCell;
internal WPos SerializablePos { get { return terrainCenterPosition; } } internal WPos SerializablePos => terrainCenterPosition;
} }
} }

View File

@@ -15,7 +15,8 @@ namespace OpenRA.UtilityCommands
{ {
class ClearInvalidModRegistrationsCommand : IUtilityCommand class ClearInvalidModRegistrationsCommand : IUtilityCommand
{ {
string IUtilityCommand.Name { get { return "--clear-invalid-mod-registrations"; } } string IUtilityCommand.Name => "--clear-invalid-mod-registrations";
bool IUtilityCommand.ValidateArguments(string[] args) bool IUtilityCommand.ValidateArguments(string[] args)
{ {
return args.Length >= 2 && new string[] { "system", "user", "both" }.Contains(args[1]); return args.Length >= 2 && new string[] { "system", "user", "both" }.Contains(args[1]);

View File

@@ -15,7 +15,8 @@ namespace OpenRA.UtilityCommands
{ {
class RegisterModCommand : IUtilityCommand class RegisterModCommand : IUtilityCommand
{ {
string IUtilityCommand.Name { get { return "--register-mod"; } } string IUtilityCommand.Name => "--register-mod";
bool IUtilityCommand.ValidateArguments(string[] args) bool IUtilityCommand.ValidateArguments(string[] args)
{ {
return args.Length >= 3 && new string[] { "system", "user", "both" }.Contains(args[2]); return args.Length >= 3 && new string[] { "system", "user", "both" }.Contains(args[2]);

View File

@@ -15,7 +15,8 @@ namespace OpenRA.UtilityCommands
{ {
class UnregisterModCommand : IUtilityCommand class UnregisterModCommand : IUtilityCommand
{ {
string IUtilityCommand.Name { get { return "--unregister-mod"; } } string IUtilityCommand.Name => "--unregister-mod";
bool IUtilityCommand.ValidateArguments(string[] args) bool IUtilityCommand.ValidateArguments(string[] args)
{ {
return args.Length >= 2 && new string[] { "system", "user", "both" }.Contains(args[1]); return args.Length >= 2 && new string[] { "system", "user", "both" }.Contains(args[1]);

View File

@@ -22,7 +22,7 @@ namespace OpenRA
public struct WAngle : IScriptBindable, ILuaAdditionBinding, ILuaSubtractionBinding, ILuaEqualityBinding, IEquatable<WAngle> public struct WAngle : IScriptBindable, ILuaAdditionBinding, ILuaSubtractionBinding, ILuaEqualityBinding, IEquatable<WAngle>
{ {
public readonly int Angle; public readonly int Angle;
public int AngleSquared { get { return (int)Angle * Angle; } } public int AngleSquared => (int)Angle * Angle;
public WAngle(int a) public WAngle(int a)
{ {
@@ -46,7 +46,7 @@ namespace OpenRA
public bool Equals(WAngle other) { return other == this; } public bool Equals(WAngle other) { return other == this; }
public override bool Equals(object obj) { return obj is WAngle && Equals((WAngle)obj); } public override bool Equals(object obj) { return obj is WAngle && Equals((WAngle)obj); }
public int Facing { get { return Angle / 4; } } public int Facing => Angle / 4;
public int Sin() { return new WAngle(Angle - 256).Cos(); } public int Sin() { return new WAngle(Angle - 256).Cos(); }

View File

@@ -24,7 +24,7 @@ namespace OpenRA
public struct WDist : IComparable, IComparable<WDist>, IEquatable<WDist>, IScriptBindable, ILuaAdditionBinding, ILuaSubtractionBinding, ILuaEqualityBinding, ILuaTableBinding public struct WDist : IComparable, IComparable<WDist>, IEquatable<WDist>, IScriptBindable, ILuaAdditionBinding, ILuaSubtractionBinding, ILuaEqualityBinding, ILuaTableBinding
{ {
public readonly int Length; public readonly int Length;
public long LengthSquared { get { return (long)Length * Length; } } public long LengthSquared => (long)Length * Length;
public WDist(int r) { Length = r; } public WDist(int r) { Length = r; }
public static readonly WDist Zero = new WDist(0); public static readonly WDist Zero = new WDist(0);
@@ -148,10 +148,7 @@ namespace OpenRA
} }
} }
set set => throw new LuaException("WDist is read-only. Use WDist.New to create a new value");
{
throw new LuaException("WDist is read-only. Use WDist.New to create a new value");
}
} }
#endregion #endregion
} }

View File

@@ -129,10 +129,7 @@ namespace OpenRA
} }
} }
set set => throw new LuaException("WPos is read-only. Use WPos.New to create a new value");
{
throw new LuaException("WPos is read-only. Use WPos.New to create a new value");
}
} }
#endregion #endregion

View File

@@ -37,12 +37,12 @@ namespace OpenRA
public static bool operator !=(WVec me, WVec other) { return !(me == other); } public static bool operator !=(WVec me, WVec other) { return !(me == other); }
public static int Dot(WVec a, WVec b) { return a.X * b.X + a.Y * b.Y + a.Z * b.Z; } public static int Dot(WVec a, WVec b) { return a.X * b.X + a.Y * b.Y + a.Z * b.Z; }
public long LengthSquared { get { return (long)X * X + (long)Y * Y + (long)Z * Z; } } public long LengthSquared => (long)X * X + (long)Y * Y + (long)Z * Z;
public int Length { get { return (int)Exts.ISqrt(LengthSquared); } } public int Length => (int)Exts.ISqrt(LengthSquared);
public long HorizontalLengthSquared { get { return (long)X * X + (long)Y * Y; } } public long HorizontalLengthSquared => (long)X * X + (long)Y * Y;
public int HorizontalLength { get { return (int)Exts.ISqrt(HorizontalLengthSquared); } } public int HorizontalLength => (int)Exts.ISqrt(HorizontalLengthSquared);
public long VerticalLengthSquared { get { return (long)Z * Z; } } public long VerticalLengthSquared => (long)Z * Z;
public int VerticalLength { get { return (int)Exts.ISqrt(VerticalLengthSquared); } } public int VerticalLength => (int)Exts.ISqrt(VerticalLengthSquared);
public WVec Rotate(in WRot rot) public WVec Rotate(in WRot rot)
{ {
@@ -151,10 +151,7 @@ namespace OpenRA
} }
} }
set set => throw new LuaException("WVec is read-only. Use WVec.New to create a new value");
{
throw new LuaException("WVec is read-only. Use WVec.New to create a new value");
}
} }
#endregion #endregion

View File

@@ -224,7 +224,7 @@ namespace OpenRA.Widgets
} }
} }
public virtual int2 ChildOrigin { get { return RenderOrigin; } } public virtual int2 ChildOrigin => RenderOrigin;
public virtual Rectangle RenderBounds public virtual Rectangle RenderBounds
{ {
@@ -279,7 +279,7 @@ namespace OpenRA.Widgets
args.Remove("widget"); args.Remove("widget");
} }
public virtual Rectangle EventBounds { get { return RenderBounds; } } public virtual Rectangle EventBounds => RenderBounds;
public virtual bool EventBoundsContains(int2 location) public virtual bool EventBoundsContains(int2 location)
{ {
@@ -295,8 +295,8 @@ namespace OpenRA.Widgets
return false; return false;
} }
public bool HasMouseFocus { get { return Ui.MouseFocusWidget == this; } } public bool HasMouseFocus => Ui.MouseFocusWidget == this;
public bool HasKeyboardFocus { get { return Ui.KeyboardFocusWidget == this; } } public bool HasKeyboardFocus => Ui.KeyboardFocusWidget == this;
public virtual bool TakeMouseFocus(MouseInput mi) public virtual bool TakeMouseFocus(MouseInput mi)
{ {

View File

@@ -39,7 +39,7 @@ namespace OpenRA
public int Timestep; public int Timestep;
internal readonly OrderManager OrderManager; internal readonly OrderManager OrderManager;
public Session LobbyInfo { get { return OrderManager.LobbyInfo; } } public Session LobbyInfo => OrderManager.LobbyInfo;
public readonly MersenneTwister SharedRandom; public readonly MersenneTwister SharedRandom;
public readonly MersenneTwister LocalRandom; public readonly MersenneTwister LocalRandom;
@@ -79,10 +79,7 @@ namespace OpenRA
Player renderPlayer; Player renderPlayer;
public Player RenderPlayer public Player RenderPlayer
{ {
get get => renderPlayer;
{
return renderPlayer;
}
set set
{ {
@@ -103,20 +100,11 @@ namespace OpenRA
public bool ShroudObscures(WPos pos) { return RenderPlayer != null && !RenderPlayer.Shroud.IsExplored(pos); } public bool ShroudObscures(WPos pos) { return RenderPlayer != null && !RenderPlayer.Shroud.IsExplored(pos); }
public bool ShroudObscures(PPos uv) { return RenderPlayer != null && !RenderPlayer.Shroud.IsExplored(uv); } public bool ShroudObscures(PPos uv) { return RenderPlayer != null && !RenderPlayer.Shroud.IsExplored(uv); }
public bool IsReplay public bool IsReplay => OrderManager.Connection is ReplayConnection;
{
get { return OrderManager.Connection is ReplayConnection; }
}
public bool IsLoadingGameSave public bool IsLoadingGameSave => OrderManager.NetFrameNumber <= OrderManager.GameSaveLastFrame;
{
get { return OrderManager.NetFrameNumber <= OrderManager.GameSaveLastFrame; }
}
public int GameSaveLoadingPercentage public int GameSaveLoadingPercentage => OrderManager.NetFrameNumber * 100 / OrderManager.GameSaveLastFrame;
{
get { return OrderManager.NetFrameNumber * 100 / OrderManager.GameSaveLastFrame; }
}
void SetLocalPlayer(Player localPlayer) void SetLocalPlayer(Player localPlayer)
{ {
@@ -153,10 +141,7 @@ namespace OpenRA
IOrderGenerator orderGenerator; IOrderGenerator orderGenerator;
public IOrderGenerator OrderGenerator public IOrderGenerator OrderGenerator
{ {
get get => orderGenerator;
{
return orderGenerator;
}
set set
{ {
@@ -452,10 +437,10 @@ namespace OpenRA
ScreenMap.TickRender(); ScreenMap.TickRender();
} }
public IEnumerable<Actor> Actors { get { return actors.Values; } } public IEnumerable<Actor> Actors => actors.Values;
public IEnumerable<IEffect> Effects { get { return effects; } } public IEnumerable<IEffect> Effects => effects;
public IEnumerable<IEffect> UnpartitionedEffects { get { return unpartitionedEffects; } } public IEnumerable<IEffect> UnpartitionedEffects => unpartitionedEffects;
public IEnumerable<ISync> SyncedEffects { get { return syncedEffects; } } public IEnumerable<ISync> SyncedEffects => syncedEffects;
public Actor GetActorById(uint actorId) public Actor GetActorById(uint actorId)
{ {

View File

@@ -49,10 +49,10 @@ namespace OpenRA.Mods.Cnc.AudioLoaders
public sealed class AudFormat : ISoundFormat public sealed class AudFormat : ISoundFormat
{ {
public int Channels { get { return channels; } } public int Channels => channels;
public int SampleBits { get { return sampleBits; } } public int SampleBits => sampleBits;
public int SampleRate { get { return sampleRate; } } public int SampleRate => sampleRate;
public float LengthInSeconds { get { return AudReader.SoundLength(sourceStream); } } public float LengthInSeconds => AudReader.SoundLength(sourceStream);
public Stream GetPCMInputStream() { return audStreamFactory(); } public Stream GetPCMInputStream() { return audStreamFactory(); }
public void Dispose() { sourceStream.Dispose(); } public void Dispose() { sourceStream.Dispose(); }

View File

@@ -38,10 +38,10 @@ namespace OpenRA.Mods.Cnc.AudioLoaders
public sealed class VocFormat : ISoundFormat public sealed class VocFormat : ISoundFormat
{ {
public int SampleBits { get { return 8; } } public int SampleBits => 8;
public int Channels { get { return 1; } } public int Channels => 1;
public int SampleRate { get; private set; } public int SampleRate { get; private set; }
public float LengthInSeconds { get { return (float)totalSamples / SampleRate; } } public float LengthInSeconds => (float)totalSamples / SampleRate;
public Stream GetPCMInputStream() { return new VocStream(new VocFormat(this)); } public Stream GetPCMInputStream() { return new VocStream(new VocFormat(this)); }
public void Dispose() { stream.Dispose(); } public void Dispose() { stream.Dispose(); }
@@ -289,7 +289,7 @@ namespace OpenRA.Mods.Cnc.AudioLoaders
currentBlockEnded = true; currentBlockEnded = true;
} }
bool EndOfData { get { return currentBlockEnded && samplesLeftInBlock == 0; } } bool EndOfData => currentBlockEnded && samplesLeftInBlock == 0;
int FillBuffer(int maxSamples) int FillBuffer(int maxSamples)
{ {
@@ -358,15 +358,16 @@ namespace OpenRA.Mods.Cnc.AudioLoaders
this.format = format; this.format = format;
} }
public override bool CanRead { get { return format.samplePosition < format.totalSamples; } } public override bool CanRead => format.samplePosition < format.totalSamples;
public override bool CanSeek { get { return false; } } public override bool CanSeek => false;
public override bool CanWrite { get { return false; } } public override bool CanWrite => false;
public override long Length => format.totalSamples;
public override long Length { get { return format.totalSamples; } }
public override long Position public override long Position
{ {
get { return format.samplePosition; } get => format.samplePosition;
set { throw new NotImplementedException(); } set => throw new NotImplementedException();
} }
public override int Read(byte[] buffer, int offset, int count) public override int Read(byte[] buffer, int offset, int count)

View File

@@ -101,10 +101,7 @@ namespace OpenRA.Mods.Cnc.FileFormats
this.dataSize = dataSize; this.dataSize = dataSize;
} }
public override long Length public override long Length => outputSize;
{
get { return outputSize; }
}
protected override bool BufferData(Stream baseStream, Queue<byte> data) protected override bool BufferData(Stream baseStream, Queue<byte> data)
{ {

View File

@@ -18,10 +18,10 @@ namespace OpenRA.Mods.Cnc.FileFormats
{ {
public class VqaReader : IVideo public class VqaReader : IVideo
{ {
public ushort Frames { get { return frames; } } public ushort Frames => frames;
public byte Framerate { get { return framerate; } } public byte Framerate => framerate;
public ushort Width { get { return width; } } public ushort Width => width;
public ushort Height { get { return height; } } public ushort Height => height;
readonly ushort frames; readonly ushort frames;
readonly byte framerate; readonly byte framerate;
@@ -65,12 +65,12 @@ namespace OpenRA.Mods.Cnc.FileFormats
byte[] audioData; // audio for this frame: 22050Hz 16bit mono pcm, uncompressed. byte[] audioData; // audio for this frame: 22050Hz 16bit mono pcm, uncompressed.
bool hasAudio; bool hasAudio;
public byte[] AudioData { get { return audioData; } } public byte[] AudioData => audioData;
public int CurrentFrame { get { return currentFrame; } } public int CurrentFrame => currentFrame;
public int SampleRate { get { return sampleRate; } } public int SampleRate => sampleRate;
public int SampleBits { get { return sampleBits; } } public int SampleBits => sampleBits;
public int AudioChannels { get { return audioChannels; } } public int AudioChannels => audioChannels;
public bool HasAudio { get { return hasAudio; } } public bool HasAudio => hasAudio;
public VqaReader(Stream stream) public VqaReader(Stream stream)
{ {
@@ -513,7 +513,7 @@ namespace OpenRA.Mods.Cnc.FileFormats
} }
} }
bool IsHqVqa { get { return (videoFlags & 0x10) == 16; } } bool IsHqVqa => (videoFlags & 0x10) == 16;
void WriteBlock(int blockNumber, int count, ref int x, ref int y) void WriteBlock(int blockNumber, int count, ref int x, ref int y)
{ {

View File

@@ -23,7 +23,7 @@ namespace OpenRA.Mods.Cnc.FileSystem
sealed class BigFile : IReadOnlyPackage sealed class BigFile : IReadOnlyPackage
{ {
public string Name { get; private set; } public string Name { get; private set; }
public IEnumerable<string> Contents { get { return index.Keys; } } public IEnumerable<string> Contents => index.Keys;
readonly Dictionary<string, Entry> index = new Dictionary<string, Entry>(); readonly Dictionary<string, Entry> index = new Dictionary<string, Entry>();
readonly Stream s; readonly Stream s;

View File

@@ -25,7 +25,7 @@ namespace OpenRA.Mods.Cnc.FileSystem
public sealed class MixFile : IReadOnlyPackage public sealed class MixFile : IReadOnlyPackage
{ {
public string Name { get; private set; } public string Name { get; private set; }
public IEnumerable<string> Contents { get { return index.Keys; } } public IEnumerable<string> Contents => index.Keys;
readonly Dictionary<string, PackageEntry> index; readonly Dictionary<string, PackageEntry> index;
readonly long dataStart; readonly long dataStart;

View File

@@ -30,7 +30,7 @@ namespace OpenRA.Mods.Cnc.FileSystem
sealed class PakFile : IReadOnlyPackage sealed class PakFile : IReadOnlyPackage
{ {
public string Name { get; private set; } public string Name { get; private set; }
public IEnumerable<string> Contents { get { return index.Keys; } } public IEnumerable<string> Contents => index.Keys;
readonly Dictionary<string, Entry> index = new Dictionary<string, Entry>(); readonly Dictionary<string, Entry> index = new Dictionary<string, Entry>();
readonly Stream stream; readonly Stream stream;

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