Use read-only autoimplemented property when possible

This commit is contained in:
Eduardo Cáceres
2022-05-02 13:06:21 +02:00
committed by atlimit8
parent 79f321cb44
commit 7eb64ea6fc
52 changed files with 113 additions and 113 deletions

View File

@@ -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()
{

View File

@@ -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)
{

View File

@@ -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;

View File

@@ -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)
{

View File

@@ -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)

View File

@@ -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>();

View File

@@ -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;

View File

@@ -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)

View File

@@ -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; }

View File

@@ -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)
{

View File

@@ -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;

View File

@@ -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)
{

View File

@@ -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)

View File

@@ -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)
{

View File

@@ -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;

View File

@@ -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;

View File

@@ -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)

View File

@@ -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)
{

View File

@@ -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)
{

View File

@@ -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;

View File

@@ -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)

View File

@@ -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;

View File

@@ -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;

View File

@@ -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)