Use read-only autoimplemented property when possible
This commit is contained in:
committed by
atlimit8
parent
79f321cb44
commit
7eb64ea6fc
@@ -65,9 +65,9 @@ namespace OpenRA
|
||||
public int Generation;
|
||||
public Actor ReplacedByActor;
|
||||
|
||||
public IEffectiveOwner EffectiveOwner { get; private set; }
|
||||
public IOccupySpace OccupiesSpace { get; private set; }
|
||||
public ITargetable[] Targetables { get; private set; }
|
||||
public IEffectiveOwner EffectiveOwner { get; }
|
||||
public IOccupySpace OccupiesSpace { get; }
|
||||
public ITargetable[] Targetables { get; }
|
||||
|
||||
public bool IsIdle => CurrentActivity == null;
|
||||
public bool IsDead => Disposed || (health != null && health.IsDead);
|
||||
@@ -102,7 +102,7 @@ namespace OpenRA
|
||||
/// <summary>Read-only version of conditionCache that is passed to IConditionConsumers.</summary>
|
||||
readonly IReadOnlyDictionary<string, int> readOnlyConditionCache;
|
||||
|
||||
internal SyncHash[] SyncHashes { get; private set; }
|
||||
internal SyncHash[] SyncHashes { get; }
|
||||
|
||||
readonly IFacing facing;
|
||||
readonly IHealth health;
|
||||
|
||||
@@ -26,11 +26,11 @@ namespace OpenRA.FileFormats
|
||||
{
|
||||
static readonly byte[] Signature = { 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a };
|
||||
|
||||
public int Width { get; private set; }
|
||||
public int Height { get; private set; }
|
||||
public Color[] Palette { get; private set; }
|
||||
public byte[] Data { get; private set; }
|
||||
public SpriteFrameType Type { get; private set; }
|
||||
public int Width { get; }
|
||||
public int Height { get; }
|
||||
public Color[] Palette { get; }
|
||||
public byte[] Data { get; }
|
||||
public SpriteFrameType Type { get; }
|
||||
public Dictionary<string, string> EmbeddedData = new Dictionary<string, string>();
|
||||
|
||||
public int PixelStride => Type == SpriteFrameType.Indexed8 ? 1 : Type == SpriteFrameType.Rgb24 ? 3 : 4;
|
||||
|
||||
@@ -142,7 +142,7 @@ namespace OpenRA.FileSystem
|
||||
sealed class ZipFolder : IReadOnlyPackage
|
||||
{
|
||||
public string Name => path;
|
||||
public ReadOnlyZipFile Parent { get; private set; }
|
||||
public ReadOnlyZipFile Parent { get; }
|
||||
readonly string path;
|
||||
|
||||
public ZipFolder(ReadOnlyZipFile parent, string path)
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace OpenRA
|
||||
/// <summary>Gets the game's duration, from the time the game started until the replay recording stopped.</summary>
|
||||
public TimeSpan Duration => EndTimeUtc > StartTimeUtc ? EndTimeUtc - StartTimeUtc : TimeSpan.Zero;
|
||||
|
||||
public IList<Player> Players { get; private set; }
|
||||
public IList<Player> Players { get; }
|
||||
public HashSet<int> DisabledSpawnPoints = new HashSet<int>();
|
||||
public MapPreview MapPreview => Game.ModData.MapCache[MapUid];
|
||||
public IEnumerable<Player> HumanPlayers { get { return Players.Where(p => p.IsHuman); } }
|
||||
|
||||
@@ -17,8 +17,8 @@ namespace OpenRA.Graphics
|
||||
{
|
||||
public sealed class HardwarePalette : IDisposable
|
||||
{
|
||||
public ITexture Texture { get; private set; }
|
||||
public ITexture ColorShifts { get; private set; }
|
||||
public ITexture Texture { get; }
|
||||
public ITexture ColorShifts { get; }
|
||||
|
||||
public int Height { get; private set; }
|
||||
readonly Dictionary<string, ImmutablePalette> palettes = new Dictionary<string, ImmutablePalette>();
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace OpenRA.Graphics
|
||||
{
|
||||
public sealed class SpriteFont : IDisposable
|
||||
{
|
||||
public int TopOffset { get; private set; }
|
||||
public int TopOffset { get; }
|
||||
readonly int size;
|
||||
readonly SheetBuilder builder;
|
||||
readonly IFont font;
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace OpenRA.Graphics
|
||||
public readonly Size TileSize;
|
||||
public readonly int TileScale;
|
||||
public readonly World World;
|
||||
public Viewport Viewport { get; private set; }
|
||||
public Viewport Viewport { get; }
|
||||
public readonly ITerrainLighting TerrainLighting;
|
||||
|
||||
public event Action PaletteInvalidated = null;
|
||||
|
||||
@@ -121,7 +121,7 @@ namespace OpenRA
|
||||
new WVec(256, 256, 0), // bottom right - index 5
|
||||
};
|
||||
|
||||
public CellRamp[] Ramps { get; private set; }
|
||||
public CellRamp[] Ramps { get; }
|
||||
|
||||
internal readonly CVec[][] TilesByDistance;
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace OpenRA
|
||||
public readonly IVideoLoader[] VideoLoaders;
|
||||
public readonly HotkeyManager Hotkeys;
|
||||
public readonly Translation Translation;
|
||||
public ILoadScreen LoadScreen { get; private set; }
|
||||
public ILoadScreen LoadScreen { get; }
|
||||
public CursorProvider CursorProvider { get; private set; }
|
||||
public FS ModFiles;
|
||||
public IReadOnlyFileSystem DefaultFileSystem => ModFiles;
|
||||
@@ -152,7 +152,7 @@ namespace OpenRA
|
||||
CursorProvider = new CursorProvider(this);
|
||||
}
|
||||
|
||||
public IEnumerable<string> Languages { get; private set; }
|
||||
public IEnumerable<string> Languages { get; }
|
||||
|
||||
public Map PrepareMap(string uid)
|
||||
{
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace OpenRA.Network
|
||||
public TickTime LastTickTime;
|
||||
|
||||
public bool GameStarted => NetFrameNumber != 0;
|
||||
public IConnection Connection { get; private set; }
|
||||
public IConnection Connection { get; }
|
||||
|
||||
internal int GameSaveLastFrame = -1;
|
||||
internal int GameSaveLastSyncFrame = -1;
|
||||
|
||||
@@ -77,7 +77,7 @@ namespace OpenRA
|
||||
// Players in mission maps must not leave the player view
|
||||
public bool Spectating => !inMissionMap && (spectating || WinState != WinState.Undefined);
|
||||
|
||||
public World World { get; private set; }
|
||||
public World World { get; }
|
||||
|
||||
readonly bool inMissionMap;
|
||||
readonly bool spectating;
|
||||
|
||||
@@ -24,24 +24,24 @@ namespace OpenRA
|
||||
{
|
||||
enum RenderType { None, World, UI }
|
||||
|
||||
public SpriteRenderer WorldSpriteRenderer { get; private set; }
|
||||
public RgbaSpriteRenderer WorldRgbaSpriteRenderer { get; private set; }
|
||||
public RgbaColorRenderer WorldRgbaColorRenderer { get; private set; }
|
||||
public ModelRenderer WorldModelRenderer { get; private set; }
|
||||
public RgbaColorRenderer RgbaColorRenderer { get; private set; }
|
||||
public SpriteRenderer SpriteRenderer { get; private set; }
|
||||
public RgbaSpriteRenderer RgbaSpriteRenderer { get; private set; }
|
||||
public SpriteRenderer WorldSpriteRenderer { get; }
|
||||
public RgbaSpriteRenderer WorldRgbaSpriteRenderer { get; }
|
||||
public RgbaColorRenderer WorldRgbaColorRenderer { get; }
|
||||
public ModelRenderer WorldModelRenderer { get; }
|
||||
public RgbaColorRenderer RgbaColorRenderer { get; }
|
||||
public SpriteRenderer SpriteRenderer { get; }
|
||||
public RgbaSpriteRenderer RgbaSpriteRenderer { get; }
|
||||
|
||||
public bool WindowHasInputFocus => Window.HasInputFocus;
|
||||
public bool WindowIsSuspended => Window.IsSuspended;
|
||||
|
||||
public IReadOnlyDictionary<string, SpriteFont> Fonts;
|
||||
|
||||
internal IPlatformWindow Window { get; private set; }
|
||||
internal IGraphicsContext Context { get; private set; }
|
||||
internal IPlatformWindow Window { get; }
|
||||
internal IGraphicsContext Context { get; }
|
||||
|
||||
internal int SheetSize { get; private set; }
|
||||
internal int TempBufferSize { get; private set; }
|
||||
internal int SheetSize { get; }
|
||||
internal int TempBufferSize { get; }
|
||||
|
||||
readonly IVertexBuffer<Vertex> tempBuffer;
|
||||
readonly Stack<Rectangle> scissorState = new Stack<Rectangle>();
|
||||
|
||||
@@ -129,8 +129,8 @@ namespace OpenRA.Scripting
|
||||
// Restrict the number of instructions that will be run per map function call
|
||||
const int MaxUserScriptInstructions = 1000000;
|
||||
|
||||
public World World { get; private set; }
|
||||
public WorldRenderer WorldRenderer { get; private set; }
|
||||
public World World { get; }
|
||||
public WorldRenderer WorldRenderer { get; }
|
||||
|
||||
readonly MemoryConstrainedLuaRuntime runtime;
|
||||
readonly LuaFunction tick;
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace OpenRA
|
||||
MusicInfo currentMusic;
|
||||
Dictionary<uint, ISound> currentSounds = new Dictionary<uint, ISound>();
|
||||
readonly Dictionary<string, ISound> currentNotifications = new Dictionary<string, ISound>();
|
||||
public bool DummyEngine { get; private set; }
|
||||
public bool DummyEngine { get; }
|
||||
|
||||
public Sound(IPlatform platform, SoundSettings soundSettings)
|
||||
{
|
||||
|
||||
@@ -31,8 +31,8 @@ namespace OpenRA.Support
|
||||
|
||||
class BenchmarkPoint
|
||||
{
|
||||
public int Tick { get; private set; }
|
||||
public double Value { get; private set; }
|
||||
public int Tick { get; }
|
||||
public double Value { get; }
|
||||
|
||||
public BenchmarkPoint(int tick, double value)
|
||||
{
|
||||
|
||||
@@ -176,7 +176,7 @@ namespace OpenRA
|
||||
}
|
||||
}
|
||||
|
||||
public bool RulesContainTemporaryBlocker { get; private set; }
|
||||
public bool RulesContainTemporaryBlocker { get; }
|
||||
|
||||
bool wasLoadingGameSave;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user