Use read-only autoimplemented property when possible
This commit is contained in:
committed by
atlimit8
parent
79f321cb44
commit
7eb64ea6fc
@@ -22,7 +22,7 @@ namespace OpenRA.Mods.Common.Commands
|
||||
|
||||
public class ChatCommands : INotifyChat
|
||||
{
|
||||
public Dictionary<string, IChatCommand> Commands { get; private set; }
|
||||
public Dictionary<string, IChatCommand> Commands { get; }
|
||||
|
||||
public ChatCommands()
|
||||
{
|
||||
|
||||
@@ -176,7 +176,7 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
|
||||
class CopyPasteEditorAction : IEditorAction
|
||||
{
|
||||
public string Text { get; private set; }
|
||||
public string Text { get; }
|
||||
|
||||
readonly MapCopyFilters copyFilters;
|
||||
readonly Dictionary<CPos, (TerrainTile Tile, ResourceTile Resource, byte Height)> tiles;
|
||||
@@ -270,10 +270,10 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
|
||||
class UndoCopyPaste
|
||||
{
|
||||
public CPos Cell { get; private set; }
|
||||
public TerrainTile MapTile { get; private set; }
|
||||
public ResourceTile ResourceTile { get; private set; }
|
||||
public byte Height { get; private set; }
|
||||
public CPos Cell { get; }
|
||||
public TerrainTile MapTile { get; }
|
||||
public ResourceTile ResourceTile { get; }
|
||||
public byte Height { get; }
|
||||
|
||||
public UndoCopyPaste(CPos cell, TerrainTile mapTile, ResourceTile resourceTile, byte height)
|
||||
{
|
||||
|
||||
@@ -110,7 +110,7 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
|
||||
class RemoveActorAction : IEditorAction
|
||||
{
|
||||
public string Text { get; private set; }
|
||||
public string Text { get; }
|
||||
|
||||
readonly EditorActorLayer editorActorLayer;
|
||||
readonly EditorActorPreview actor;
|
||||
@@ -141,7 +141,7 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
|
||||
class RemoveResourceAction : IEditorAction
|
||||
{
|
||||
public string Text { get; private set; }
|
||||
public string Text { get; }
|
||||
|
||||
readonly IResourceLayer resourceLayer;
|
||||
readonly CPos cell;
|
||||
|
||||
@@ -153,7 +153,7 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
|
||||
class PaintTileEditorAction : IEditorAction
|
||||
{
|
||||
public string Text { get; private set; }
|
||||
public string Text { get; }
|
||||
|
||||
readonly ushort template;
|
||||
readonly Map map;
|
||||
@@ -222,7 +222,7 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
|
||||
class FloodFillEditorAction : IEditorAction
|
||||
{
|
||||
public string Text { get; private set; }
|
||||
public string Text { get; }
|
||||
|
||||
readonly ushort template;
|
||||
readonly Map map;
|
||||
@@ -357,9 +357,9 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
|
||||
class UndoTile
|
||||
{
|
||||
public CPos Cell { get; private set; }
|
||||
public TerrainTile MapTile { get; private set; }
|
||||
public byte Height { get; private set; }
|
||||
public CPos Cell { get; }
|
||||
public TerrainTile MapTile { get; }
|
||||
public byte Height { get; }
|
||||
|
||||
public UndoTile(CPos cell, TerrainTile mapTile, byte height)
|
||||
{
|
||||
|
||||
@@ -110,7 +110,7 @@ namespace OpenRA.Mods.Common.FileFormats
|
||||
|
||||
public class IniSection : IEnumerable<KeyValuePair<string, string>>
|
||||
{
|
||||
public string Name { get; private set; }
|
||||
public string Name { get; }
|
||||
readonly Dictionary<string, string> values = new Dictionary<string, string>();
|
||||
|
||||
public IniSection(string name)
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace OpenRA.Mods.Common.FileSystem
|
||||
}
|
||||
}
|
||||
|
||||
public string Name { get; private set; }
|
||||
public string Name { get; }
|
||||
public IEnumerable<string> Contents => index.Keys;
|
||||
|
||||
readonly Dictionary<string, Entry> index = new Dictionary<string, Entry>();
|
||||
|
||||
@@ -132,20 +132,20 @@ namespace OpenRA.Mods.Common.Graphics
|
||||
|
||||
protected readonly ISpriteSequenceLoader Loader;
|
||||
|
||||
public string Name { get; private set; }
|
||||
public string Name { get; }
|
||||
public int Start { get; private set; }
|
||||
public int Length { get; private set; }
|
||||
public int Stride { get; private set; }
|
||||
public int Facings { get; private set; }
|
||||
public int Tick { get; private set; }
|
||||
public int ZOffset { get; private set; }
|
||||
public float ZRamp { get; private set; }
|
||||
public int ShadowStart { get; private set; }
|
||||
public int ShadowZOffset { get; private set; }
|
||||
public int Facings { get; }
|
||||
public int Tick { get; }
|
||||
public int ZOffset { get; }
|
||||
public float ZRamp { get; }
|
||||
public int ShadowStart { get; }
|
||||
public int ShadowZOffset { get; }
|
||||
public int[] Frames { get; private set; }
|
||||
public Rectangle Bounds { get; private set; }
|
||||
public bool IgnoreWorldTint { get; private set; }
|
||||
public float Scale { get; private set; }
|
||||
public bool IgnoreWorldTint { get; }
|
||||
public float Scale { get; }
|
||||
|
||||
public readonly uint[] EmbeddedPalette;
|
||||
|
||||
|
||||
@@ -26,8 +26,8 @@ namespace OpenRA.Mods.Common.Orders
|
||||
this.cursor = cursor;
|
||||
}
|
||||
|
||||
public string OrderID { get; private set; }
|
||||
public int OrderPriority { get; private set; }
|
||||
public string OrderID { get; }
|
||||
public int OrderPriority { get; }
|
||||
public bool TargetOverridesSelection(Actor self, in Target target, List<Actor> actorsAt, CPos xy, TargetModifiers modifiers) { return true; }
|
||||
|
||||
public bool CanTarget(Actor self, in Target target, ref TargetModifiers modifiers, ref string cursor)
|
||||
|
||||
@@ -29,8 +29,8 @@ namespace OpenRA.Mods.Common.Orders
|
||||
this.targetAllyUnits = targetAllyUnits;
|
||||
}
|
||||
|
||||
public string OrderID { get; private set; }
|
||||
public int OrderPriority { get; private set; }
|
||||
public string OrderID { get; }
|
||||
public int OrderPriority { get; }
|
||||
public bool? ForceAttack = null;
|
||||
public bool TargetOverridesSelection(Actor self, in Target target, List<Actor> actorsAt, CPos xy, TargetModifiers modifiers) { return true; }
|
||||
|
||||
|
||||
@@ -47,11 +47,11 @@ namespace OpenRA.Mods.Common.SpriteLoaders
|
||||
{
|
||||
class DdsFrame : ISpriteFrame
|
||||
{
|
||||
public SpriteFrameType Type { get; private set; }
|
||||
public Size Size { get; private set; }
|
||||
public SpriteFrameType Type { get; }
|
||||
public Size Size { get; }
|
||||
public Size FrameSize => Size;
|
||||
public float2 Offset => float2.Zero;
|
||||
public byte[] Data { get; private set; }
|
||||
public byte[] Data { get; }
|
||||
public bool DisableExportPadding => false;
|
||||
|
||||
public DdsFrame(Stream stream)
|
||||
@@ -71,7 +71,7 @@ namespace OpenRA.Mods.Common.SpriteLoaders
|
||||
}
|
||||
}
|
||||
|
||||
public IReadOnlyList<ISpriteFrame> Frames { get; private set; }
|
||||
public IReadOnlyList<ISpriteFrame> Frames { get; }
|
||||
|
||||
public DdsSprite(Stream stream)
|
||||
{
|
||||
|
||||
@@ -21,9 +21,9 @@ namespace OpenRA.Mods.Common.SpriteLoaders
|
||||
class ShpTSFrame : ISpriteFrame
|
||||
{
|
||||
public SpriteFrameType Type => SpriteFrameType.Indexed8;
|
||||
public Size Size { get; private set; }
|
||||
public Size FrameSize { get; private set; }
|
||||
public float2 Offset { get; private set; }
|
||||
public Size Size { get; }
|
||||
public Size FrameSize { get; }
|
||||
public float2 Offset { get; }
|
||||
public byte[] Data { get; set; }
|
||||
public bool DisableExportPadding => false;
|
||||
|
||||
|
||||
@@ -70,11 +70,11 @@ namespace OpenRA.Mods.Common.SpriteLoaders
|
||||
{
|
||||
public class TgaFrame : ISpriteFrame
|
||||
{
|
||||
public SpriteFrameType Type { get; private set; }
|
||||
public Size Size { get; private set; }
|
||||
public Size FrameSize { get; private set; }
|
||||
public float2 Offset { get; private set; }
|
||||
public byte[] Data { get; private set; }
|
||||
public SpriteFrameType Type { get; }
|
||||
public Size Size { get; }
|
||||
public Size FrameSize { get; }
|
||||
public float2 Offset { get; }
|
||||
public byte[] Data { get; }
|
||||
public bool DisableExportPadding => false;
|
||||
|
||||
public TgaFrame()
|
||||
@@ -106,7 +106,7 @@ namespace OpenRA.Mods.Common.SpriteLoaders
|
||||
}
|
||||
}
|
||||
|
||||
public IReadOnlyList<ISpriteFrame> Frames { get; private set; }
|
||||
public IReadOnlyList<ISpriteFrame> Frames { get; }
|
||||
|
||||
public TgaSprite(Stream stream)
|
||||
{
|
||||
|
||||
@@ -426,7 +426,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
}
|
||||
|
||||
public string OrderID { get; private set; }
|
||||
public int OrderPriority { get; private set; }
|
||||
public int OrderPriority { get; }
|
||||
public bool TargetOverridesSelection(Actor self, in Target target, List<Actor> actorsAt, CPos xy, TargetModifiers modifiers) { return true; }
|
||||
|
||||
bool CanTargetActor(Actor self, in Target target, ref TargetModifiers modifiers, ref string cursor)
|
||||
|
||||
@@ -279,7 +279,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
readonly CPos[] transitOnlyCells;
|
||||
|
||||
public CPos TopLeft => topLeft;
|
||||
public WPos CenterPosition { get; private set; }
|
||||
public WPos CenterPosition { get; }
|
||||
|
||||
public Building(ActorInitializer init, BuildingInfo info)
|
||||
{
|
||||
|
||||
@@ -79,7 +79,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
}
|
||||
|
||||
public int HP => hp;
|
||||
public int MaxHP { get; private set; }
|
||||
public int MaxHP { get; }
|
||||
|
||||
public bool IsDead => hp <= 0;
|
||||
public bool RemoveOnDeath = true;
|
||||
|
||||
@@ -651,7 +651,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public bool Started { get; private set; }
|
||||
public int Slowdown { get; private set; }
|
||||
public bool Infinite { get; set; }
|
||||
public int BuildPaletteOrder { get; private set; }
|
||||
public int BuildPaletteOrder { get; }
|
||||
|
||||
readonly ActorInfo ai;
|
||||
readonly BuildableInfo bi;
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
RallyPoint rp;
|
||||
|
||||
public string Faction { get; private set; }
|
||||
public string Faction { get; }
|
||||
|
||||
public Production(ActorInitializer init, ProductionInfo info)
|
||||
: base(info)
|
||||
|
||||
@@ -177,9 +177,9 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
class Arrow
|
||||
{
|
||||
public Sprite Sprite { get; private set; }
|
||||
public double EndAngle { get; private set; }
|
||||
public WAngle Direction { get; private set; }
|
||||
public Sprite Sprite { get; }
|
||||
public double EndAngle { get; }
|
||||
public WAngle Direction { get; }
|
||||
|
||||
public Arrow(Sprite sprite, double endAngle, WAngle direction)
|
||||
{
|
||||
|
||||
@@ -185,8 +185,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
readonly HashSet<Actor> removeActorPosition = new HashSet<Actor>();
|
||||
readonly Predicate<Actor> actorShouldBeRemoved;
|
||||
|
||||
public WDist LargestActorRadius { get; private set; }
|
||||
public WDist LargestBlockingActorRadius { get; private set; }
|
||||
public WDist LargestActorRadius { get; }
|
||||
public WDist LargestBlockingActorRadius { get; }
|
||||
|
||||
public ActorMap(World world, ActorMapInfo info)
|
||||
{
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public class ControlGroups : IControlGroups, ITick, IGameSaveTraitData
|
||||
{
|
||||
readonly World world;
|
||||
public string[] Groups { get; private set; }
|
||||
public string[] Groups { get; }
|
||||
|
||||
readonly List<Actor>[] controlGroups;
|
||||
|
||||
|
||||
@@ -161,15 +161,15 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
}
|
||||
|
||||
public string Text { get; private set; }
|
||||
public string Text { get; }
|
||||
|
||||
public EditorActionStatus Status { get; set; }
|
||||
}
|
||||
|
||||
public class EditorActionContainer
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public IEditorAction Action { get; private set; }
|
||||
public int Id { get; }
|
||||
public IEditorAction Action { get; }
|
||||
public EditorActionStatus Status { get; set; }
|
||||
|
||||
public EditorActionContainer(int id, IEditorAction action)
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public string ID { get; set; }
|
||||
public PlayerReference Owner { get; set; }
|
||||
public SubCell SubCell { get; private set; }
|
||||
public SubCell SubCell { get; }
|
||||
public bool Selected { get; set; }
|
||||
public Color RadarColor { get; private set; }
|
||||
readonly RadarColorFromTerrainInfo terrainRadarColorInfo;
|
||||
|
||||
@@ -446,7 +446,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
|
||||
class EditActorEditorAction : IEditorAction
|
||||
{
|
||||
public string Text { get; private set; }
|
||||
public string Text { get; }
|
||||
|
||||
readonly IEnumerable<IEditActorHandle> handles;
|
||||
readonly EditorActorLayer editorActorLayer;
|
||||
|
||||
@@ -60,8 +60,8 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
PlayerRadarTerrain playerRadarTerrain;
|
||||
Player currentPlayer;
|
||||
|
||||
public string SoundUp { get; private set; }
|
||||
public string SoundDown { get; private set; }
|
||||
public string SoundUp { get; }
|
||||
public string SoundDown { get; }
|
||||
|
||||
[ObjectCreator.UseCtor]
|
||||
public RadarWidget(World world, WorldRenderer worldRenderer)
|
||||
|
||||
Reference in New Issue
Block a user