Fixed fields missing the readonly modifier

This commit is contained in:
penev92
2022-01-20 00:43:58 +02:00
committed by Paul Chote
parent f83e27d647
commit bf332b6619
96 changed files with 173 additions and 169 deletions

View File

@@ -22,7 +22,7 @@ namespace OpenRA.Activities
IsInterruptible = interruptible; IsInterruptible = interruptible;
} }
Action a; readonly Action a;
public override bool Tick(Actor self) public override bool Tick(Actor self)
{ {

View File

@@ -17,8 +17,8 @@ namespace OpenRA.Effects
{ {
public class AsyncAction : IEffect public class AsyncAction : IEffect
{ {
Action a; readonly Action a;
IAsyncResult ar; readonly IAsyncResult ar;
public AsyncAction(IAsyncResult ar, Action a) public AsyncAction(IAsyncResult ar, Action a)
{ {

View File

@@ -17,7 +17,7 @@ namespace OpenRA.Effects
{ {
public class DelayedAction : IEffect public class DelayedAction : IEffect
{ {
Action a; readonly Action a;
int delay; int delay;
public DelayedAction(int delay, Action a) public DelayedAction(int delay, Action a)

View File

@@ -119,7 +119,7 @@ namespace OpenRA
} }
// More accurate replacement for Environment.TickCount // More accurate replacement for Environment.TickCount
static Stopwatch stopwatch = Stopwatch.StartNew(); static readonly Stopwatch stopwatch = Stopwatch.StartNew();
public static long RunTime => stopwatch.ElapsedMilliseconds; public static long RunTime => stopwatch.ElapsedMilliseconds;
public static int RenderFrame = 0; public static int RenderFrame = 0;

View File

@@ -35,7 +35,7 @@ namespace OpenRA.Graphics
Cursor cursor; Cursor cursor;
bool isLocked = false; bool isLocked = false;
int2 lockedPosition; int2 lockedPosition;
bool hardwareCursorsDisabled = false; readonly bool hardwareCursorsDisabled = false;
bool hardwareCursorsDoubled = false; bool hardwareCursorsDoubled = false;
public CursorManager(CursorProvider cursorProvider) public CursorManager(CursorProvider cursorProvider)

View File

@@ -42,7 +42,7 @@ namespace OpenRA.Graphics
class ReadOnlyPalette : IPalette class ReadOnlyPalette : IPalette
{ {
IPalette palette; readonly IPalette palette;
public ReadOnlyPalette(IPalette palette) { this.palette = palette; } public ReadOnlyPalette(IPalette palette) { this.palette = palette; }
public uint this[int index] => palette[index]; public uint this[int index] => palette[index];

View File

@@ -25,7 +25,7 @@ namespace OpenRA
public class ActorReference : IEnumerable public class ActorReference : IEnumerable
{ {
public string Type; public string Type;
Lazy<TypeDictionary> initDict; readonly Lazy<TypeDictionary> initDict;
internal TypeDictionary InitDict => initDict.Value; internal TypeDictionary InitDict => initDict.Value;

View File

@@ -34,8 +34,8 @@ namespace OpenRA
readonly SheetBuilder sheetBuilder; readonly SheetBuilder sheetBuilder;
Thread previewLoaderThread; Thread previewLoaderThread;
bool previewLoaderThreadShutDown = true; bool previewLoaderThreadShutDown = true;
object syncRoot = new object(); readonly object syncRoot = new object();
Queue<MapPreview> generateMinimap = new Queue<MapPreview>(); readonly Queue<MapPreview> generateMinimap = new Queue<MapPreview>();
public Dictionary<string, string> StringPool { get; } = new Dictionary<string, string>(); public Dictionary<string, string> StringPool { get; } = new Dictionary<string, string>();

View File

@@ -128,7 +128,7 @@ namespace OpenRA
} }
// HACK: Only update the loading screen if we're in the main thread. // HACK: Only update the loading screen if we're in the main thread.
int initialThreadId; readonly int initialThreadId;
internal void HandleLoadingProgress() internal void HandleLoadingProgress()
{ {
if (LoadScreen != null && IsOnMainThread) if (LoadScreen != null && IsOnMainThread)

View File

@@ -23,7 +23,7 @@ namespace OpenRA.Network
public ReplayMetadata Metadata; public ReplayMetadata Metadata;
BinaryWriter writer; BinaryWriter writer;
Func<string> chooseFilename; readonly Func<string> chooseFilename;
MemoryStream preStartBuffer = new MemoryStream(); MemoryStream preStartBuffer = new MemoryStream();
static bool IsGameStart(byte[] data) static bool IsGameStart(byte[] data)

View File

@@ -22,7 +22,7 @@ namespace OpenRA.Network
class SyncReport class SyncReport
{ {
const int NumSyncReports = 5; const int NumSyncReports = 5;
static Cache<Type, TypeInfo> typeInfoCache = new Cache<Type, TypeInfo>(t => new TypeInfo(t)); static readonly Cache<Type, TypeInfo> typeInfoCache = new Cache<Type, TypeInfo>(t => new TypeInfo(t));
readonly OrderManager orderManager; readonly OrderManager orderManager;
@@ -154,9 +154,9 @@ namespace OpenRA.Network
public int Frame; public int Frame;
public int SyncedRandom; public int SyncedRandom;
public int TotalCount; public int TotalCount;
public List<TraitReport> Traits = new List<TraitReport>(); public readonly List<TraitReport> Traits = new List<TraitReport>();
public List<EffectReport> Effects = new List<EffectReport>(); public readonly List<EffectReport> Effects = new List<EffectReport>();
public List<OrderManager.ClientOrder> Orders = new List<OrderManager.ClientOrder>(); public readonly List<OrderManager.ClientOrder> Orders = new List<OrderManager.ClientOrder>();
} }
struct TraitReport struct TraitReport

View File

@@ -25,7 +25,7 @@ namespace OpenRA
public static PlatformType CurrentPlatform => 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 readonly Lazy<PlatformType> currentPlatform = Exts.Lazy(GetCurrentPlatform);
static bool engineDirAccessed; static bool engineDirAccessed;
static string engineDir; static string engineDir;

View File

@@ -21,8 +21,8 @@ namespace OpenRA.Primitives
this.onFinalize = onFinalize; this.onFinalize = onFinalize;
} }
Action onDispose; readonly Action onDispose;
Action onFinalize; readonly Action onFinalize;
bool disposed; bool disposed;
public void Dispose() public void Dispose()

View File

@@ -77,7 +77,7 @@ namespace OpenRA.Server
ReplayRecorder recorder; ReplayRecorder recorder;
GameInformation gameInfo; GameInformation gameInfo;
readonly List<GameInformation.Player> worldPlayers = new List<GameInformation.Player>(); readonly List<GameInformation.Player> worldPlayers = new List<GameInformation.Player>();
Stopwatch pingUpdated = Stopwatch.StartNew(); readonly Stopwatch pingUpdated = Stopwatch.StartNew();
public ServerState State public ServerState State
{ {

View File

@@ -16,7 +16,7 @@ namespace OpenRA
{ {
public class Arguments public class Arguments
{ {
Dictionary<string, string> args = new Dictionary<string, string>(); readonly Dictionary<string, string> args = new Dictionary<string, string>();
public static Arguments Empty => new Arguments(); public static Arguments Empty => new Arguments();

View File

@@ -18,7 +18,7 @@ namespace OpenRA.Support
{ {
public readonly Color C; public readonly Color C;
public readonly string Name; public readonly string Name;
double[] samples = new double[100]; readonly double[] samples = new double[100];
public double Val = 0.0; public double Val = 0.0;
int head = 1, tail = 0; int head = 1, tail = 0;
public bool HasNormalTick = true; public bool HasNormalTick = true;

View File

@@ -31,7 +31,7 @@ namespace OpenRA.Support
List<PerfTimer> children; List<PerfTimer> children;
long ticks; long ticks;
static ThreadLocal<PerfTimer> parentThreadLocal = new ThreadLocal<PerfTimer>(); static readonly ThreadLocal<PerfTimer> parentThreadLocal = new ThreadLocal<PerfTimer>();
public PerfTimer(string name, float thresholdMs = 0) public PerfTimer(string name, float thresholdMs = 0)
{ {

View File

@@ -29,7 +29,7 @@ namespace OpenRA.Traits
{ {
readonly ScreenShakerInfo info; readonly ScreenShakerInfo info;
WorldRenderer worldRenderer; WorldRenderer worldRenderer;
List<ShakeEffect> shakeEffects = new List<ShakeEffect>(); readonly List<ShakeEffect> shakeEffects = new List<ShakeEffect>();
int ticks = 0; int ticks = 0;
public ScreenShaker(ScreenShakerInfo info) public ScreenShaker(ScreenShakerInfo info)

View File

@@ -370,7 +370,7 @@ namespace OpenRA
public int WorldTick { get; private set; } public int WorldTick { get; private set; }
Dictionary<int, MiniYaml> gameSaveTraitData = new Dictionary<int, MiniYaml>(); readonly Dictionary<int, MiniYaml> gameSaveTraitData = new Dictionary<int, MiniYaml>();
internal void AddGameSaveTraitData(int traitIndex, MiniYaml yaml) internal void AddGameSaveTraitData(int traitIndex, MiniYaml yaml)
{ {
gameSaveTraitData[traitIndex] = yaml; gameSaveTraitData[traitIndex] = yaml;

View File

@@ -27,9 +27,9 @@ namespace OpenRA.Mods.Cnc.Activities
readonly bool killOnFailure; readonly bool killOnFailure;
readonly BitSet<DamageType> killDamageTypes; readonly BitSet<DamageType> killDamageTypes;
CPos destination; CPos destination;
bool killCargo; readonly bool killCargo;
bool screenFlash; readonly bool screenFlash;
string sound; readonly string sound;
public Teleport(Actor teleporter, CPos destination, int? maximumDistance, public Teleport(Actor teleporter, CPos destination, int? maximumDistance,
bool killCargo, bool screenFlash, string sound, bool interruptable = true, bool killCargo, bool screenFlash, string sound, bool interruptable = true,

View File

@@ -130,7 +130,7 @@ namespace OpenRA.Mods.Cnc.FileFormats
return i; return i;
} }
uint[] lookupMfromP = readonly uint[] lookupMfromP =
{ {
0x243f6a88, 0x85a308d3, 0x13198a2e, 0x03707344, 0x243f6a88, 0x85a308d3, 0x13198a2e, 0x03707344,
0xa4093822, 0x299f31d0, 0x082efa98, 0xec4e6c89, 0xa4093822, 0x299f31d0, 0x082efa98, 0xec4e6c89,
@@ -139,7 +139,7 @@ namespace OpenRA.Mods.Cnc.FileFormats
0x9216d5d9, 0x8979fb1b 0x9216d5d9, 0x8979fb1b
}; };
uint[,] lookupMfromS = readonly uint[,] lookupMfromS =
{ {
{ {
0xd1310ba6, 0x98dfb5ac, 0x2ffd72db, 0xd01adfb7, 0xd1310ba6, 0x98dfb5ac, 0x2ffd72db, 0xd01adfb7,

View File

@@ -22,18 +22,18 @@ namespace OpenRA.Mods.Cnc.FileFormats
class PublicKey class PublicKey
{ {
public uint[] KeyOne = new uint[64]; public readonly uint[] KeyOne = new uint[64];
public uint[] KeyTwo = new uint[64]; public readonly uint[] KeyTwo = new uint[64];
public uint Len; public uint Len;
} }
PublicKey pubkey = new PublicKey(); readonly PublicKey pubkey = new PublicKey();
uint[] globOne = new uint[64]; readonly uint[] globOne = new uint[64];
uint globOneBitLen, globOneLenXTwo; uint globOneBitLen, globOneLenXTwo;
uint[] globTwo = new uint[130]; readonly uint[] globTwo = new uint[130];
uint[] globOneHigh = new uint[4]; readonly uint[] globOneHigh = new uint[4];
uint[] globOneHighInv = new uint[4]; readonly uint[] globOneHighInv = new uint[4];
uint globOneHighBitLen; uint globOneHighBitLen;
uint globOneHighInvLow, globOneHighInvHigh; uint globOneHighInvLow, globOneHighInvHigh;

View File

@@ -45,21 +45,21 @@ namespace OpenRA.Mods.Cnc.FileFormats
// Stores a list of subpixels, referenced by the VPTZ chunk // Stores a list of subpixels, referenced by the VPTZ chunk
byte[] cbf; byte[] cbf;
byte[] cbp; readonly byte[] cbp;
byte[] cbfBuffer; readonly byte[] cbfBuffer;
bool cbpIsCompressed; bool cbpIsCompressed;
// Buffer for loading file subchunks, the maximum chunk size of a file is not defined // Buffer for loading file subchunks, the maximum chunk size of a file is not defined
// and the header definition for the size of the biggest chunks (color data) isn't accurate. // and the header definition for the size of the biggest chunks (color data) isn't accurate.
// But 256k is large enough for all TS videos(< 200k). // But 256k is large enough for all TS videos(< 200k).
byte[] fileBuffer = new byte[256000]; readonly byte[] fileBuffer = new byte[256000];
int maxCbfzSize = 256000; readonly int maxCbfzSize = 256000;
int vtprSize = 0; int vtprSize = 0;
int currentChunkBuffer = 0; int currentChunkBuffer = 0;
int chunkBufferOffset = 0; int chunkBufferOffset = 0;
// Top half contains block info, bottom half contains references to cbf array // Top half contains block info, bottom half contains references to cbf array
byte[] origData; readonly byte[] origData;
public VqaVideo(Stream stream, bool useFramePadding) public VqaVideo(Stream stream, bool useFramePadding)
{ {

View File

@@ -38,7 +38,7 @@ namespace OpenRA.Mods.Cnc.FileFormats
public readonly uint LimbCount; public readonly uint LimbCount;
public VxlLimb[] Limbs; public VxlLimb[] Limbs;
uint bodySize; readonly uint bodySize;
static void ReadVoxelData(Stream s, VxlLimb l) static void ReadVoxelData(Stream s, VxlLimb l)
{ {

View File

@@ -105,7 +105,7 @@ namespace OpenRA.Mods.Cnc.FileSystem
} }
} }
static Dictionary<uint, string> names = new Dictionary<uint, string>(); static readonly Dictionary<uint, string> names = new Dictionary<uint, string>();
public static void AddStandardName(string s) public static void AddStandardName(string s)
{ {

View File

@@ -19,7 +19,7 @@ namespace OpenRA.Mods.Cnc.Graphics
{ {
class TeslaZapRenderable : IPalettedRenderable, IFinalizedRenderable class TeslaZapRenderable : IPalettedRenderable, IFinalizedRenderable
{ {
static int[][] steps = new[] static readonly int[][] steps = new[]
{ {
new int[] { 8, 8, 4, 4, 0 }, new int[] { 8, 8, 4, 4, 0 },
new int[] { -8, -8, -4, -4, 0 }, new int[] { -8, -8, -4, -4, 0 },
@@ -40,8 +40,8 @@ namespace OpenRA.Mods.Cnc.Graphics
readonly string brightSequence; readonly string brightSequence;
readonly int brightZaps, dimZaps; readonly int brightZaps, dimZaps;
WPos cachedPos; readonly WPos cachedPos;
WVec cachedLength; readonly WVec cachedLength;
IEnumerable<IFinalizedRenderable> cache; IEnumerable<IFinalizedRenderable> cache;
public TeslaZapRenderable(WPos pos, int zOffset, in WVec length, string image, string brightSequence, int brightZaps, string dimSequence, int dimZaps, string palette) public TeslaZapRenderable(WPos pos, int zOffset, in WVec length, string image, string brightSequence, int brightZaps, string dimSequence, int dimZaps, string palette)

View File

@@ -87,11 +87,11 @@ namespace OpenRA.Mods.Cnc.SpriteLoaders
public uint FileOffset; public uint FileOffset;
public Format Format; public Format Format;
public uint RefOffset; public readonly uint RefOffset;
public Format RefFormat; public readonly Format RefFormat;
public ImageHeader RefImage; public ImageHeader RefImage;
ShpTDSprite reader; readonly ShpTDSprite reader;
// Used by ShpWriter // Used by ShpWriter
public ImageHeader() { } public ImageHeader() { }

View File

@@ -56,7 +56,7 @@ namespace OpenRA.Mods.Cnc.Traits
int idleTicks = 0; int idleTicks = 0;
PopupState state = PopupState.Open; PopupState state = PopupState.Open;
bool skippedMakeAnimation; readonly bool skippedMakeAnimation;
public AttackPopupTurreted(ActorInitializer init, AttackPopupTurretedInfo info) public AttackPopupTurreted(ActorInitializer init, AttackPopupTurretedInfo info)
: base(init.Self, info) : base(init.Self, info)

View File

@@ -73,7 +73,7 @@ namespace OpenRA.Mods.Cnc.Traits
int conditionToken = Actor.InvalidConditionToken; int conditionToken = Actor.InvalidConditionToken;
Actor chronosphere; Actor chronosphere;
int duration; readonly int duration;
bool returnOriginal; bool returnOriginal;
bool selling; bool selling;
@@ -81,7 +81,7 @@ namespace OpenRA.Mods.Cnc.Traits
int returnTicks = 0; int returnTicks = 0;
[Sync] [Sync]
CPos origin; readonly CPos origin;
[Sync] [Sync]
bool triggered; bool triggered;

View File

@@ -40,7 +40,7 @@ namespace OpenRA.Mods.Cnc.Traits.Render
readonly IFacing facing; readonly IFacing facing;
WAngle cachedFacing; WAngle cachedFacing;
Dictionary<Actor, IActorPreview[]> previews = new Dictionary<Actor, IActorPreview[]>(); readonly Dictionary<Actor, IActorPreview[]> previews = new Dictionary<Actor, IActorPreview[]>();
public WithCargo(Actor self, WithCargoInfo info) public WithCargo(Actor self, WithCargoInfo info)
{ {

View File

@@ -51,7 +51,8 @@ namespace OpenRA.Mods.Cnc.Traits.Render
readonly ModelAnimation modelAnimation; readonly ModelAnimation modelAnimation;
readonly RenderVoxels rv; readonly RenderVoxels rv;
uint tick, frame, frames; uint tick, frame;
readonly uint frames;
public WithVoxelWalkerBody(Actor self, WithVoxelWalkerBodyInfo info) public WithVoxelWalkerBody(Actor self, WithVoxelWalkerBodyInfo info)
{ {

View File

@@ -42,7 +42,7 @@ namespace OpenRA.Mods.Cnc.UtilityCommands
} }
// Mapping from RA95 overlay index to type string // Mapping from RA95 overlay index to type string
static string[] redAlertOverlayNames = static readonly string[] redAlertOverlayNames =
{ {
"sbag", "cycl", "brik", "fenc", "wood", "sbag", "cycl", "brik", "fenc", "wood",
"gold01", "gold02", "gold03", "gold04", "gold01", "gold02", "gold03", "gold04",
@@ -51,7 +51,7 @@ namespace OpenRA.Mods.Cnc.UtilityCommands
"fpls", "wcrate", "scrate", "barb", "sbag", "fpls", "wcrate", "scrate", "barb", "sbag",
}; };
static Dictionary<string, (byte Type, byte Index)> overlayResourceMapping = new Dictionary<string, (byte, byte)>() static readonly Dictionary<string, (byte Type, byte Index)> overlayResourceMapping = new Dictionary<string, (byte, byte)>()
{ {
// RA ore & crystals // RA ore & crystals
{ "gold01", (1, 0) }, { "gold01", (1, 0) },
@@ -81,7 +81,7 @@ namespace OpenRA.Mods.Cnc.UtilityCommands
Map.Tiles[new CPos(i, j)] = new TerrainTile(types[i, j], ms.ReadUInt8()); Map.Tiles[new CPos(i, j)] = new TerrainTile(types[i, j], ms.ReadUInt8());
} }
static string[] overlayActors = new string[] static readonly string[] overlayActors = new string[]
{ {
// Fences // Fences
"sbag", "cycl", "brik", "fenc", "wood", "sbag", "cycl", "brik", "fenc", "wood",

View File

@@ -39,7 +39,7 @@ namespace OpenRA.Mods.Cnc.UtilityCommands
} }
} }
static Dictionary<string, (byte Type, byte Index)> overlayResourceMapping = new Dictionary<string, (byte, byte)>() static readonly Dictionary<string, (byte Type, byte Index)> overlayResourceMapping = new Dictionary<string, (byte, byte)>()
{ {
// Tiberium // Tiberium
{ "ti1", (1, 0) }, { "ti1", (1, 0) },
@@ -69,7 +69,7 @@ namespace OpenRA.Mods.Cnc.UtilityCommands
} }
} }
static string[] overlayActors = new string[] static readonly string[] overlayActors = new string[]
{ {
// Fences // Fences
"sbag", "cycl", "brik", "fenc", "wood", "sbag", "cycl", "brik", "fenc", "wood",

View File

@@ -21,7 +21,7 @@ namespace OpenRA.Mods.Common.Activities
readonly Aircraft aircraft; readonly Aircraft aircraft;
readonly FallsToEarthInfo info; readonly FallsToEarthInfo info;
int acceleration; readonly int acceleration;
int spin; int spin;
public FallToEarth(Actor self, FallsToEarthInfo info) public FallToEarth(Actor self, FallsToEarthInfo info)

View File

@@ -22,7 +22,7 @@ namespace OpenRA.Mods.Common.Activities
readonly INotifyIdle[] tickIdles; readonly INotifyIdle[] tickIdles;
readonly bool idleTurn; readonly bool idleTurn;
int remainingTicks; int remainingTicks;
bool isIdleTurner; readonly bool isIdleTurner;
public FlyIdle(Actor self, int ticks = -1, bool idleTurn = true) public FlyIdle(Actor self, int ticks = -1, bool idleTurn = true)
{ {

View File

@@ -21,10 +21,11 @@ namespace OpenRA.Mods.Common.Activities
{ {
readonly IPositionable positionable; readonly IPositionable positionable;
readonly IDisabledTrait disableable; readonly IDisabledTrait disableable;
WPos start, end; readonly WPos start;
int length; readonly WPos end;
readonly int length;
int ticks = 0; int ticks = 0;
WAngle? desiredFacing; readonly WAngle? desiredFacing;
public Drag(Actor self, WPos start, WPos end, int length, WAngle? facing = null) public Drag(Actor self, WPos start, WPos end, int length, WAngle? facing = null)
{ {

View File

@@ -49,7 +49,7 @@ namespace OpenRA.Mods.Common.Activities
int waitTicksRemaining; int waitTicksRemaining;
// To work around queued activity issues while minimizing changes to legacy behaviour // To work around queued activity issues while minimizing changes to legacy behaviour
bool evaluateNearestMovableCell; readonly bool evaluateNearestMovableCell;
// Scriptable move order // Scriptable move order
// Ignores lane bias and nearby units // Ignores lane bias and nearby units

View File

@@ -111,7 +111,7 @@ namespace OpenRA.Mods.Common.Activities
return TickChild(self); return TickChild(self);
} }
List<CPos> searchCells = new List<CPos>(); readonly List<CPos> searchCells = new List<CPos>();
int searchCellsTick = -1; int searchCellsTick = -1;
List<CPos> CalculatePathToTarget(Actor self, BlockedByActor check) List<CPos> CalculatePathToTarget(Actor self, BlockedByActor check)

View File

@@ -21,7 +21,7 @@ namespace OpenRA.Mods.Common.Activities
readonly IHealth health; readonly IHealth health;
readonly SellableInfo sellableInfo; readonly SellableInfo sellableInfo;
readonly PlayerResources playerResources; readonly PlayerResources playerResources;
bool showTicks; readonly bool showTicks;
public Sell(Actor self, bool showTicks) public Sell(Actor self, bool showTicks)
{ {

View File

@@ -16,7 +16,7 @@ namespace OpenRA.Mods.Common.Activities
{ {
public class SimpleTeleport : Activity public class SimpleTeleport : Activity
{ {
CPos destination; readonly CPos destination;
public SimpleTeleport(CPos destination) { this.destination = destination; } public SimpleTeleport(CPos destination) { this.destination = destination; }

View File

@@ -36,7 +36,7 @@ namespace OpenRA.Mods.Common.Activities
public class WaitFor : Activity public class WaitFor : Activity
{ {
Func<bool> f; readonly Func<bool> f;
public WaitFor(Func<bool> f) { this.f = f; } public WaitFor(Func<bool> f) { this.f = f; }
public WaitFor(Func<bool> f, bool interruptible) public WaitFor(Func<bool> f, bool interruptible)

View File

@@ -18,8 +18,8 @@ namespace OpenRA.Mods.Common.Effects
{ {
public class ContrailFader : IEffect public class ContrailFader : IEffect
{ {
WPos pos; readonly WPos pos;
ContrailRenderable trail; readonly ContrailRenderable trail;
int ticks; int ticks;
public ContrailFader(WPos pos, ContrailRenderable trail) public ContrailFader(WPos pos, ContrailRenderable trail)

View File

@@ -24,7 +24,7 @@ namespace OpenRA.Mods.Common.Effects
readonly SpriteFont font; readonly SpriteFont font;
readonly string text; readonly string text;
Color color; readonly Color color;
int remaining; int remaining;
WPos pos; WPos pos;

View File

@@ -24,7 +24,7 @@ namespace OpenRA.Mods.Common.Effects
readonly Animation flag; readonly Animation flag;
readonly Animation circles; readonly Animation circles;
List<WPos> targetLineNodes = new List<WPos> { }; readonly List<WPos> targetLineNodes = new List<WPos> { };
List<CPos> cachedLocations; List<CPos> cachedLocations;
public RallyPointIndicator(Actor building, RallyPoint rp) public RallyPointIndicator(Actor building, RallyPoint rp)

View File

@@ -25,7 +25,7 @@ namespace OpenRA.Mods.Common.FileFormats
public static readonly int MAXBITS = 13; // maximum code length public static readonly int MAXBITS = 13; // maximum code length
public static readonly int MAXWIN = 4096; // maximum window size public static readonly int MAXWIN = 4096; // maximum window size
static byte[] litlen = static readonly byte[] litlen =
{ {
11, 124, 8, 7, 28, 7, 188, 13, 76, 4, 11, 124, 8, 7, 28, 7, 188, 13, 76, 4,
10, 8, 12, 10, 12, 10, 8, 23, 8, 9, 10, 8, 12, 10, 12, 10, 8, 23, 8, 9,
@@ -40,28 +40,28 @@ namespace OpenRA.Mods.Common.FileFormats
}; };
// bit lengths of length codes 0..15 // bit lengths of length codes 0..15
static byte[] lenlen = { 2, 35, 36, 53, 38, 23 }; static readonly byte[] lenlen = { 2, 35, 36, 53, 38, 23 };
// bit lengths of distance codes 0..63 // bit lengths of distance codes 0..63
static byte[] distlen = { 2, 20, 53, 230, 247, 151, 248 }; static readonly byte[] distlen = { 2, 20, 53, 230, 247, 151, 248 };
// base for length codes // base for length codes
static short[] lengthbase = static readonly short[] lengthbase =
{ {
3, 2, 4, 5, 6, 7, 8, 9, 10, 12, 3, 2, 4, 5, 6, 7, 8, 9, 10, 12,
16, 24, 40, 72, 136, 264 16, 24, 40, 72, 136, 264
}; };
// extra bits for length codes // extra bits for length codes
static byte[] extra = static readonly byte[] extra =
{ {
0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2,
3, 4, 5, 6, 7, 8 3, 4, 5, 6, 7, 8
}; };
static Huffman litcode = new Huffman(litlen, litlen.Length, 256); static readonly Huffman litcode = new Huffman(litlen, litlen.Length, 256);
static Huffman lencode = new Huffman(lenlen, lenlen.Length, 16); static readonly Huffman lencode = new Huffman(lenlen, lenlen.Length, 16);
static Huffman distcode = new Huffman(distlen, distlen.Length, 64); static readonly Huffman distcode = new Huffman(distlen, distlen.Length, 64);
/// <summary>PKWare Compression Library stream.</summary> /// <summary>PKWare Compression Library stream.</summary>
/// <param name="input">Compressed input stream.</param> /// <param name="input">Compressed input stream.</param>

View File

@@ -19,7 +19,7 @@ namespace OpenRA.Mods.Common.FileFormats
{ {
public class IniFile public class IniFile
{ {
Dictionary<string, IniSection> sections = new Dictionary<string, IniSection>(); readonly Dictionary<string, IniSection> sections = new Dictionary<string, IniSection>();
public IniFile(Stream s) public IniFile(Stream s)
{ {
@@ -49,7 +49,7 @@ namespace OpenRA.Mods.Common.FileFormats
} }
} }
Regex sectionPattern = new Regex(@"^\[([^]]*)\]"); readonly Regex sectionPattern = new Regex(@"^\[([^]]*)\]");
IniSection ProcessSection(string line) IniSection ProcessSection(string line)
{ {
@@ -111,7 +111,7 @@ namespace OpenRA.Mods.Common.FileFormats
public class IniSection : IEnumerable<KeyValuePair<string, string>> public class IniSection : IEnumerable<KeyValuePair<string, string>>
{ {
public string Name { get; private set; } public string Name { get; private set; }
Dictionary<string, string> values = new Dictionary<string, string>(); readonly Dictionary<string, string> values = new Dictionary<string, string>();
public IniSection(string name) public IniSection(string name)
{ {

View File

@@ -30,7 +30,7 @@ namespace OpenRA.Mods.Common.Graphics
readonly WDist width; readonly WDist width;
int next; int next;
int length; int length;
int skip; readonly int skip;
public ContrailRenderable(World world, Color color, WDist width, int length, int skip, int zOffset) public ContrailRenderable(World world, Color color, WDist width, int length, int skip, int zOffset)
: this(world, new WPos[length], width, 0, 0, skip, color, zOffset) { } : this(world, new WPos[length], width, 0, 0, skip, color, zOffset) { }

View File

@@ -18,7 +18,7 @@ namespace OpenRA.Mods.Common.Orders
{ {
public abstract class GlobalButtonOrderGenerator<T> : OrderGenerator public abstract class GlobalButtonOrderGenerator<T> : OrderGenerator
{ {
string order; readonly string order;
public GlobalButtonOrderGenerator(string order) public GlobalButtonOrderGenerator(string order)
{ {

View File

@@ -124,7 +124,7 @@ namespace OpenRA.Mods.Common.Projectiles
readonly float3 shadowColor; readonly float3 shadowColor;
readonly float shadowAlpha; readonly float shadowAlpha;
ContrailRenderable contrail; readonly ContrailRenderable contrail;
[Sync] [Sync]
WPos pos, lastPos, target, source; WPos pos, lastPos, target, source;

View File

@@ -189,16 +189,16 @@ namespace OpenRA.Mods.Common.Projectiles
int ticks; int ticks;
int ticksToNextSmoke; int ticksToNextSmoke;
ContrailRenderable contrail; readonly ContrailRenderable contrail;
string trailPalette; readonly string trailPalette;
States state; States state;
bool targetPassedBy; bool targetPassedBy;
bool lockOn; readonly bool lockOn;
bool allowPassBy; // TODO: use this also with high minimum launch angle settings bool allowPassBy; // TODO: use this also with high minimum launch angle settings
WPos targetPosition; WPos targetPosition;
WVec offset; readonly WVec offset;
WVec tarVel; WVec tarVel;
WVec predVel; WVec predVel;
@@ -210,7 +210,7 @@ namespace OpenRA.Mods.Common.Projectiles
int speed; int speed;
int loopRadius; int loopRadius;
WDist distanceCovered; WDist distanceCovered;
WDist rangeLimit; readonly WDist rangeLimit;
WAngle renderFacing; WAngle renderFacing;

View File

@@ -18,7 +18,7 @@ namespace OpenRA.Mods.Common.Scripting
[ScriptPropertyGroup("Combat")] [ScriptPropertyGroup("Combat")]
public class GuardProperties : ScriptActorProperties, Requires<GuardInfo>, Requires<IMoveInfo> public class GuardProperties : ScriptActorProperties, Requires<GuardInfo>, Requires<IMoveInfo>
{ {
Guard guard; readonly Guard guard;
public GuardProperties(ScriptContext context, Actor self) public GuardProperties(ScriptContext context, Actor self)
: base(context, self) : base(context, self)
{ {

View File

@@ -19,7 +19,7 @@ namespace OpenRA.Mods.Common.Scripting
[ScriptPropertyGroup("General")] [ScriptPropertyGroup("General")]
public class HealthProperties : ScriptActorProperties, Requires<IHealthInfo> public class HealthProperties : ScriptActorProperties, Requires<IHealthInfo>
{ {
IHealth health; readonly IHealth health;
public HealthProperties(ScriptContext context, Actor self) public HealthProperties(ScriptContext context, Actor self)
: base(context, self) : base(context, self)
{ {

View File

@@ -78,12 +78,12 @@ namespace OpenRA.Mods.Common.Traits
public class AttackGarrisoned : AttackFollow, INotifyPassengerEntered, INotifyPassengerExited, IRender public class AttackGarrisoned : AttackFollow, INotifyPassengerEntered, INotifyPassengerExited, IRender
{ {
public new readonly AttackGarrisonedInfo Info; public new readonly AttackGarrisonedInfo Info;
Lazy<BodyOrientation> coords; readonly Lazy<BodyOrientation> coords;
List<Armament> armaments; readonly List<Armament> armaments;
List<AnimationWithOffset> muzzles; readonly List<AnimationWithOffset> muzzles;
Dictionary<Actor, IFacing> paxFacing; readonly Dictionary<Actor, IFacing> paxFacing;
Dictionary<Actor, IPositionable> paxPos; readonly Dictionary<Actor, IPositionable> paxPos;
Dictionary<Actor, RenderSprites> paxRender; readonly Dictionary<Actor, RenderSprites> paxRender;
public AttackGarrisoned(Actor self, AttackGarrisonedInfo info) public AttackGarrisoned(Actor self, AttackGarrisonedInfo info)
: base(self, info) : base(self, info)

View File

@@ -154,7 +154,7 @@ namespace OpenRA.Mods.Common.Traits
CPos initialBaseCenter; CPos initialBaseCenter;
CPos defenseCenter; CPos defenseCenter;
List<BaseBuilderQueueManager> builders = new List<BaseBuilderQueueManager>(); readonly List<BaseBuilderQueueManager> builders = new List<BaseBuilderQueueManager>();
public BaseBuilderBotModule(Actor self, BaseBuilderBotModuleInfo info) public BaseBuilderBotModule(Actor self, BaseBuilderBotModuleInfo info)
: base(info) : base(info)

View File

@@ -53,7 +53,7 @@ namespace OpenRA.Mods.Common.Traits
int minCaptureDelayTicks; int minCaptureDelayTicks;
// Units that the bot already knows about and has given a capture order. Any unit not on this list needs to be given a new order. // Units that the bot already knows about and has given a capture order. Any unit not on this list needs to be given a new order.
List<Actor> activeCapturers = new List<Actor>(); readonly List<Actor> activeCapturers = new List<Actor>();
public CaptureManagerBotModule(Actor self, CaptureManagerBotModuleInfo info) public CaptureManagerBotModule(Actor self, CaptureManagerBotModuleInfo info)
: base(info) : base(info)

View File

@@ -26,7 +26,7 @@ namespace OpenRA.Mods.Common.Traits
class CapturableProgressBar : ConditionalTrait<CapturableProgressBarInfo>, ISelectionBar, ICaptureProgressWatcher class CapturableProgressBar : ConditionalTrait<CapturableProgressBarInfo>, ISelectionBar, ICaptureProgressWatcher
{ {
Dictionary<Actor, (int Current, int Total)> progress = new Dictionary<Actor, (int, int)>(); readonly Dictionary<Actor, (int Current, int Total)> progress = new Dictionary<Actor, (int, int)>();
public CapturableProgressBar(Actor self, CapturableProgressBarInfo info) public CapturableProgressBar(Actor self, CapturableProgressBarInfo info)
: base(info) { } : base(info) { }

View File

@@ -27,8 +27,8 @@ namespace OpenRA.Mods.Common.Traits
class CapturableProgressBlink : ConditionalTrait<CapturableProgressBlinkInfo>, ITick, ICaptureProgressWatcher class CapturableProgressBlink : ConditionalTrait<CapturableProgressBlinkInfo>, ITick, ICaptureProgressWatcher
{ {
List<Player> captorOwners = new List<Player>(); readonly List<Player> captorOwners = new List<Player>();
HashSet<Actor> captors = new HashSet<Actor>(); readonly HashSet<Actor> captors = new HashSet<Actor>();
int tick = 0; int tick = 0;
public CapturableProgressBlink(CapturableProgressBlinkInfo info) public CapturableProgressBlink(CapturableProgressBlinkInfo info)

View File

@@ -77,7 +77,7 @@ namespace OpenRA.Mods.Common.Traits
int beingCapturedToken = Actor.InvalidConditionToken; int beingCapturedToken = Actor.InvalidConditionToken;
bool enteringCurrentTarget; bool enteringCurrentTarget;
HashSet<Actor> currentCaptors = new HashSet<Actor>(); readonly HashSet<Actor> currentCaptors = new HashSet<Actor>();
public bool BeingCaptured { get; private set; } public bool BeingCaptured { get; private set; }

View File

@@ -104,7 +104,7 @@ namespace OpenRA.Mods.Common.Traits
int reservedWeight = 0; int reservedWeight = 0;
Aircraft aircraft; Aircraft aircraft;
int loadingToken = Actor.InvalidConditionToken; int loadingToken = Actor.InvalidConditionToken;
Stack<int> loadedTokens = new Stack<int>(); readonly Stack<int> loadedTokens = new Stack<int>();
bool takeOffAfterLoad; bool takeOffAfterLoad;
bool initialised; bool initialised;

View File

@@ -27,7 +27,7 @@ namespace OpenRA.Mods.Common.Traits
class SupportPowerCrateAction : CrateAction class SupportPowerCrateAction : CrateAction
{ {
SupportPowerCrateActionInfo info; readonly SupportPowerCrateActionInfo info;
public SupportPowerCrateAction(Actor self, SupportPowerCrateActionInfo info) public SupportPowerCrateAction(Actor self, SupportPowerCrateActionInfo info)
: base(self, info) : base(self, info)
{ {

View File

@@ -46,8 +46,8 @@ namespace OpenRA.Mods.Common.Traits
} }
} }
List<DemolishAction> actions = new List<DemolishAction>(); readonly List<DemolishAction> actions = new List<DemolishAction>();
List<DemolishAction> removeActions = new List<DemolishAction>(); readonly List<DemolishAction> removeActions = new List<DemolishAction>();
public Demolishable(DemolishableInfo info) public Demolishable(DemolishableInfo info)
: base(info) { } : base(info) { }

View File

@@ -102,7 +102,7 @@ namespace OpenRA.Mods.Common.Traits
class EngineerRepairOrderTargeter : UnitOrderTargeter class EngineerRepairOrderTargeter : UnitOrderTargeter
{ {
EngineerRepairInfo info; readonly EngineerRepairInfo info;
public EngineerRepairOrderTargeter(EngineerRepairInfo info) public EngineerRepairOrderTargeter(EngineerRepairInfo info)
: base("EngineerRepair", 6, info.Cursor, true, true) : base("EngineerRepair", 6, info.Cursor, true, true)

View File

@@ -31,7 +31,7 @@ namespace OpenRA.Mods.Common.Traits
public class ExperienceTrickler : PausableConditionalTrait<ExperienceTricklerInfo>, ITick, ISync public class ExperienceTrickler : PausableConditionalTrait<ExperienceTricklerInfo>, ITick, ISync
{ {
readonly ExperienceTricklerInfo info; readonly ExperienceTricklerInfo info;
GainsExperience gainsExperience; readonly GainsExperience gainsExperience;
[Sync] [Sync]
int ticks; int ticks;

View File

@@ -38,7 +38,7 @@ namespace OpenRA.Mods.Common.Traits
class GivesBounty : ConditionalTrait<GivesBountyInfo>, INotifyKilled, INotifyPassengerEntered, INotifyPassengerExited class GivesBounty : ConditionalTrait<GivesBountyInfo>, INotifyKilled, INotifyPassengerEntered, INotifyPassengerExited
{ {
Dictionary<Actor, GivesBounty[]> passengerBounties = new Dictionary<Actor, GivesBounty[]>(); readonly Dictionary<Actor, GivesBounty[]> passengerBounties = new Dictionary<Actor, GivesBounty[]>();
public GivesBounty(GivesBountyInfo info) public GivesBounty(GivesBountyInfo info)
: base(info) { } : base(info) { }

View File

@@ -649,7 +649,7 @@ namespace OpenRA.Mods.Common.Traits
CPos cell; CPos cell;
SubCell subCell; SubCell subCell;
WPos pos; WPos pos;
int delay; readonly int delay;
public ReturnToCellActivity(Actor self, int delay = 0, bool recalculateSubCell = false) public ReturnToCellActivity(Actor self, int delay = 0, bool recalculateSubCell = false)
{ {

View File

@@ -22,9 +22,9 @@ namespace OpenRA.Mods.Common.Traits
public class CloakPaletteEffect : IPaletteModifier, ITick public class CloakPaletteEffect : IPaletteModifier, ITick
{ {
float t = 0; float t = 0;
string paletteName = "cloak"; readonly string paletteName = "cloak";
Color[] colors = readonly Color[] colors =
{ {
Color.FromArgb(55, 205, 205, 220), Color.FromArgb(55, 205, 205, 220),
Color.FromArgb(120, 205, 205, 230), Color.FromArgb(120, 205, 205, 230),

View File

@@ -118,7 +118,7 @@ namespace OpenRA.Mods.Common.Traits
readonly string[] prerequisites; readonly string[] prerequisites;
readonly ITechTreeElement watcher; readonly ITechTreeElement watcher;
bool hasPrerequisites; bool hasPrerequisites;
int limit; readonly int limit;
bool hidden; bool hidden;
bool initialized = false; bool initialized = false;

View File

@@ -83,7 +83,7 @@ namespace OpenRA.Mods.Common.Traits
readonly string initialPlug; readonly string initialPlug;
int conditionToken = Actor.InvalidConditionToken; int conditionToken = Actor.InvalidConditionToken;
Dictionary<string, bool> plugTypesAvailability = null; readonly Dictionary<string, bool> plugTypesAvailability = null;
string active; string active;

View File

@@ -48,7 +48,7 @@ namespace OpenRA.Mods.Common.Traits.Render
readonly Sprite sprite; readonly Sprite sprite;
readonly VeteranProductionIconOverlayInfo info; readonly VeteranProductionIconOverlayInfo info;
Dictionary<ActorInfo, bool> overlayActive = new Dictionary<ActorInfo, bool>(); readonly Dictionary<ActorInfo, bool> overlayActive = new Dictionary<ActorInfo, bool>();
public VeteranProductionIconOverlay(ActorInitializer init, VeteranProductionIconOverlayInfo info) public VeteranProductionIconOverlay(ActorInitializer init, VeteranProductionIconOverlayInfo info)
{ {

View File

@@ -34,7 +34,7 @@ namespace OpenRA.Mods.Common.Traits.Sound
class AmbientSound : ConditionalTrait<AmbientSoundInfo>, ITick, INotifyRemovedFromWorld class AmbientSound : ConditionalTrait<AmbientSoundInfo>, ITick, INotifyRemovedFromWorld
{ {
readonly bool loop; readonly bool loop;
HashSet<ISound> currentSounds = new HashSet<ISound>(); readonly HashSet<ISound> currentSounds = new HashSet<ISound>();
WPos cachedPosition; WPos cachedPosition;
int delay; int delay;

View File

@@ -38,7 +38,7 @@ namespace OpenRA.Mods.Common.Traits
bool activated; bool activated;
bool dragStarted; bool dragStarted;
Arrow currentArrow; Arrow currentArrow;
MouseAttachmentWidget mouseAttachment; readonly MouseAttachmentWidget mouseAttachment;
public SelectDirectionalTarget(World world, string order, SupportPowerManager manager, string cursor, public SelectDirectionalTarget(World world, string order, SupportPowerManager manager, string cursor,
string directionArrowAnimation, string directionArrowPalette) string directionArrowAnimation, string directionArrowPalette)

View File

@@ -48,16 +48,16 @@ namespace OpenRA.Mods.Common.Traits
class ThrowsParticle : ITick class ThrowsParticle : ITick
{ {
WVec pos; WVec pos;
WVec initialPos; readonly WVec initialPos;
WVec finalPos; readonly WVec finalPos;
WAngle angle; readonly WAngle angle;
int tick = 0; int tick = 0;
int length; readonly int length;
WAngle facing; WAngle facing;
WAngle rotation; WAngle rotation;
int direction; readonly int direction;
public ThrowsParticle(ActorInitializer init, ThrowsParticleInfo info) public ThrowsParticle(ActorInitializer init, ThrowsParticleInfo info)
{ {

View File

@@ -31,7 +31,7 @@ namespace OpenRA.Mods.Common.Traits
class StartGameNotification : IWorldLoaded, INotifyGameLoaded, INotifyGameSaved class StartGameNotification : IWorldLoaded, INotifyGameLoaded, INotifyGameSaved
{ {
StartGameNotificationInfo info; readonly StartGameNotificationInfo info;
public StartGameNotification(StartGameNotificationInfo info) public StartGameNotification(StartGameNotificationInfo info)
{ {
this.info = info; this.info = info;

View File

@@ -331,7 +331,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
} }
// TODO: fix this -- will have bitrotted pretty badly. // TODO: fix this -- will have bitrotted pretty badly.
static Dictionary<string, Color> namedColorMapping = new Dictionary<string, Color>() static readonly Dictionary<string, Color> namedColorMapping = new Dictionary<string, Color>()
{ {
{ "gold", Color.FromArgb(246, 214, 121) }, { "gold", Color.FromArgb(246, 214, 121) },
{ "blue", Color.FromArgb(226, 230, 246) }, { "blue", Color.FromArgb(226, 230, 246) },

View File

@@ -16,7 +16,7 @@ namespace OpenRA.Mods.Common.Widgets
{ {
public class GridLayout : ILayout public class GridLayout : ILayout
{ {
ScrollPanelWidget widget; readonly ScrollPanelWidget widget;
int2 pos; int2 pos;
public GridLayout(ScrollPanelWidget w) { widget = w; } public GridLayout(ScrollPanelWidget w) { widget = w; }

View File

@@ -28,7 +28,7 @@ namespace OpenRA.Mods.Common.Widgets
public string TooltipText; public string TooltipText;
Lazy<TooltipContainerWidget> tooltipContainer; readonly Lazy<TooltipContainerWidget> tooltipContainer;
public Func<string> GetTooltipText; public Func<string> GetTooltipText;
public ImageWidget() public ImageWidget()

View File

@@ -15,7 +15,7 @@ namespace OpenRA.Mods.Common.Widgets
{ {
public class ListLayout : ILayout public class ListLayout : ILayout
{ {
ScrollPanelWidget widget; readonly ScrollPanelWidget widget;
public ListLayout(ScrollPanelWidget w) { widget = w; } public ListLayout(ScrollPanelWidget w) { widget = w; }

View File

@@ -34,12 +34,12 @@ namespace OpenRA.Mods.Common.Widgets.Logic
readonly World world; readonly World world;
readonly ModData modData; readonly ModData modData;
Widget panel; readonly Widget panel;
TextFieldWidget filenameInput; readonly TextFieldWidget filenameInput;
SliderWidget frameSlider; readonly SliderWidget frameSlider;
ScrollPanelWidget assetList; readonly ScrollPanelWidget assetList;
ScrollItemWidget template; readonly ScrollItemWidget template;
IReadOnlyPackage assetSource = null; IReadOnlyPackage assetSource = null;
bool animateFrames = false; bool animateFrames = false;
@@ -385,7 +385,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
currentFrame = currentSprites.Length - 1; currentFrame = currentSprites.Length - 1;
} }
Dictionary<string, bool> assetVisByName = new Dictionary<string, bool>(); readonly Dictionary<string, bool> assetVisByName = new Dictionary<string, bool>();
bool FilterAsset(string filename) bool FilterAsset(string filename)
{ {

View File

@@ -17,8 +17,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
{ {
public class ConnectionLogic : ChromeLogic public class ConnectionLogic : ChromeLogic
{ {
Action onConnect, onAbort; readonly Action onConnect;
Action<string> onRetry; readonly Action onAbort;
readonly Action<string> onRetry;
void ConnectionStateChanged(OrderManager om, string password, NetworkConnection connection) void ConnectionStateChanged(OrderManager om, string password, NetworkConnection connection)
{ {
@@ -81,7 +82,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
public class ConnectionFailedLogic : ChromeLogic public class ConnectionFailedLogic : ChromeLogic
{ {
PasswordFieldWidget passwordField; readonly PasswordFieldWidget passwordField;
bool passwordOffsetAdjusted; bool passwordOffsetAdjusted;
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]

View File

@@ -22,8 +22,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
readonly ScrollPanelWidget scrollPanel; readonly ScrollPanelWidget scrollPanel;
readonly LabelWidget template; readonly LabelWidget template;
bool showModTab; readonly bool showModTab;
bool showEngineTab; readonly bool showEngineTab;
bool isShowingModTab; bool isShowingModTab;
readonly IEnumerable<string> modLines; readonly IEnumerable<string> modLines;
readonly IEnumerable<string> engineLines; readonly IEnumerable<string> engineLines;

View File

@@ -18,7 +18,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
{ {
public class NewMapLogic : ChromeLogic public class NewMapLogic : ChromeLogic
{ {
Widget panel; readonly Widget panel;
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public NewMapLogic(Action onExit, Action<string> onSelect, Widget widget, World world, ModData modData) public NewMapLogic(Action onExit, Action<string> onSelect, Widget widget, World world, ModData modData)

View File

@@ -27,7 +27,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
readonly Action<bool> hideMenu; readonly Action<bool> hideMenu;
readonly IObjectivesPanel iop; readonly IObjectivesPanel iop;
IngameInfoPanel activePanel; IngameInfoPanel activePanel;
bool hasError; readonly bool hasError;
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public GameInfoLogic(Widget widget, ModData modData, World world, IngameInfoPanel initialPanel, Action<bool> hideMenu) public GameInfoLogic(Widget widget, ModData modData, World world, IngameInfoPanel initialPanel, Action<bool> hideMenu)

View File

@@ -18,7 +18,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic.Ingame
[ChromeLogicArgsHotkeys("CycleStatusBarsKey")] [ChromeLogicArgsHotkeys("CycleStatusBarsKey")]
public class CycleStatusBarsHotkeyLogic : SingleHotkeyBaseLogic public class CycleStatusBarsHotkeyLogic : SingleHotkeyBaseLogic
{ {
StatusBarsType[] options = { StatusBarsType.Standard, StatusBarsType.DamageShow, StatusBarsType.AlwaysShow }; readonly StatusBarsType[] options = { StatusBarsType.Standard, StatusBarsType.DamageShow, StatusBarsType.AlwaysShow };
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public CycleStatusBarsHotkeyLogic(Widget widget, ModData modData, Dictionary<string, MiniYaml> logicArgs) public CycleStatusBarsHotkeyLogic(Widget widget, ModData modData, Dictionary<string, MiniYaml> logicArgs)

View File

@@ -33,7 +33,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
readonly WorldRenderer worldRenderer; readonly WorldRenderer worldRenderer;
readonly MenuPaletteEffect mpe; readonly MenuPaletteEffect mpe;
readonly bool isSinglePlayer; readonly bool isSinglePlayer;
bool hasError; readonly bool hasError;
bool leaving; bool leaving;
bool hideMenu; bool hideMenu;

View File

@@ -33,7 +33,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
readonly World world; readonly World world;
CameraOption selected; CameraOption selected;
LabelWidget shroudLabel; readonly LabelWidget shroudLabel;
class CameraOption class CameraOption
{ {

View File

@@ -25,9 +25,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
{ {
class SlotDropDownOption class SlotDropDownOption
{ {
public string Title; public readonly string Title;
public string Order; public readonly string Order;
public Func<bool> Selected; public readonly Func<bool> Selected;
public SlotDropDownOption(string title, string order, Func<bool> selected) public SlotDropDownOption(string title, string order, Func<bool> selected)
{ {

View File

@@ -24,13 +24,13 @@ namespace OpenRA.Mods.Common.Widgets.Logic
MapClassification currentTab; MapClassification currentTab;
Dictionary<MapClassification, ScrollPanelWidget> scrollpanels = new Dictionary<MapClassification, ScrollPanelWidget>(); readonly Dictionary<MapClassification, ScrollPanelWidget> scrollpanels = new Dictionary<MapClassification, ScrollPanelWidget>();
Dictionary<MapClassification, MapPreview[]> tabMaps = new Dictionary<MapClassification, MapPreview[]>(); readonly Dictionary<MapClassification, MapPreview[]> tabMaps = new Dictionary<MapClassification, MapPreview[]>();
string[] visibleMaps; string[] visibleMaps;
string selectedUid; string selectedUid;
Action<string> onSelect; readonly Action<string> onSelect;
string category; string category;
string mapFilter; string mapFilter;

View File

@@ -17,7 +17,7 @@ namespace OpenRA.Mods.Common.Widgets
{ {
public class LogicKeyListenerWidget : Widget public class LogicKeyListenerWidget : Widget
{ {
List<Func<KeyInput, bool>> handlers = new List<Func<KeyInput, bool>>(); readonly List<Func<KeyInput, bool>> handlers = new List<Func<KeyInput, bool>>();
public override bool HandleKeyPress(KeyInput e) public override bool HandleKeyPress(KeyInput e)
{ {

View File

@@ -29,7 +29,7 @@ namespace OpenRA.Mods.Common.Widgets
public int IconHeight = 24; public int IconHeight = 24;
public int IconSpacing = 1; public int IconSpacing = 1;
float2 iconSize; readonly float2 iconSize;
public int MinWidth = 240; public int MinWidth = 240;
public ArmyUnit TooltipUnit { get; private set; } public ArmyUnit TooltipUnit { get; private set; }

View File

@@ -39,12 +39,12 @@ namespace OpenRA.Mods.Common.Widgets
public ProductionIcon TooltipIcon { get; private set; } public ProductionIcon TooltipIcon { get; private set; }
public Func<ProductionIcon> GetTooltipIcon; public Func<ProductionIcon> GetTooltipIcon;
Dictionary<ProductionQueue, Animation> clocks; readonly Dictionary<ProductionQueue, Animation> clocks;
readonly Lazy<TooltipContainerWidget> tooltipContainer; readonly Lazy<TooltipContainerWidget> tooltipContainer;
readonly List<ProductionIcon> productionIcons = new List<ProductionIcon>(); readonly List<ProductionIcon> productionIcons = new List<ProductionIcon>();
readonly List<Rectangle> productionIconsBounds = new List<Rectangle>(); readonly List<Rectangle> productionIconsBounds = new List<Rectangle>();
float2 iconSize; readonly float2 iconSize;
int lastIconIdx; int lastIconIdx;
public int MinWidth = 240; public int MinWidth = 240;
int currentTooltipToken; int currentTooltipToken;

View File

@@ -92,7 +92,7 @@ namespace OpenRA.Mods.Common.Widgets
public int IconRowOffset = 0; public int IconRowOffset = 0;
public int MaxIconRowOffset = int.MaxValue; public int MaxIconRowOffset = int.MaxValue;
Lazy<TooltipContainerWidget> tooltipContainer; readonly Lazy<TooltipContainerWidget> tooltipContainer;
ProductionQueue currentQueue; ProductionQueue currentQueue;
HotkeyReference[] hotkeys; HotkeyReference[] hotkeys;
@@ -111,7 +111,8 @@ namespace OpenRA.Mods.Common.Widgets
public override Rectangle EventBounds => eventBounds; public override Rectangle EventBounds => eventBounds;
Dictionary<Rectangle, ProductionIcon> icons = new Dictionary<Rectangle, ProductionIcon>(); Dictionary<Rectangle, ProductionIcon> icons = new Dictionary<Rectangle, ProductionIcon>();
Animation cantBuild, clock; readonly Animation cantBuild;
readonly Animation clock;
Rectangle eventBounds = Rectangle.Empty; Rectangle eventBounds = Rectangle.Empty;
readonly WorldRenderer worldRenderer; readonly WorldRenderer worldRenderer;

View File

@@ -96,7 +96,7 @@ namespace OpenRA.Mods.Common.Widgets
SpriteFont font; SpriteFont font;
Rectangle leftButtonRect; Rectangle leftButtonRect;
Rectangle rightButtonRect; Rectangle rightButtonRect;
Lazy<ProductionPaletteWidget> paletteWidget; readonly Lazy<ProductionPaletteWidget> paletteWidget;
string queueGroup; string queueGroup;
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]

View File

@@ -21,7 +21,7 @@ namespace OpenRA.Mods.Common.Widgets
{ {
public readonly string TooltipTemplate; public readonly string TooltipTemplate;
public readonly string TooltipContainer; public readonly string TooltipContainer;
Lazy<TooltipContainerWidget> tooltipContainer; readonly Lazy<TooltipContainerWidget> tooltipContainer;
public string TooltipFormat = ""; public string TooltipFormat = "";
public ResourceBarOrientation Orientation = ResourceBarOrientation.Vertical; public ResourceBarOrientation Orientation = ResourceBarOrientation.Vertical;
@@ -31,8 +31,8 @@ namespace OpenRA.Mods.Common.Widgets
public Func<float> GetProvided = () => 0; public Func<float> GetProvided = () => 0;
public Func<float> GetUsed = () => 0; public Func<float> GetUsed = () => 0;
public Func<Color> GetBarColor = () => Color.White; public Func<Color> GetBarColor = () => Color.White;
EWMA providedLerp = new EWMA(0.3f); readonly EWMA providedLerp = new EWMA(0.3f);
EWMA usedLerp = new EWMA(0.3f); readonly EWMA usedLerp = new EWMA(0.3f);
readonly World world; readonly World world;
Sprite indicator; Sprite indicator;

View File

@@ -53,12 +53,12 @@ namespace OpenRA.Mods.Common.Widgets
readonly SupportPowerManager spm; readonly SupportPowerManager spm;
Animation icon; Animation icon;
Animation clock; readonly Animation clock;
Dictionary<Rectangle, SupportPowerIcon> icons = new Dictionary<Rectangle, SupportPowerIcon>(); Dictionary<Rectangle, SupportPowerIcon> icons = new Dictionary<Rectangle, SupportPowerIcon>();
public SupportPowerIcon TooltipIcon { get; private set; } public SupportPowerIcon TooltipIcon { get; private set; }
public Func<SupportPowerIcon> GetTooltipIcon; public Func<SupportPowerIcon> GetTooltipIcon;
Lazy<TooltipContainerWidget> tooltipContainer; readonly Lazy<TooltipContainerWidget> tooltipContainer;
HotkeyReference[] hotkeys; HotkeyReference[] hotkeys;
Rectangle eventBounds; Rectangle eventBounds;

View File

@@ -16,9 +16,9 @@ namespace OpenRA.Platforms.Default
{ {
static class MultiTapDetection static class MultiTapDetection
{ {
static Cache<(Keycode Key, Modifiers Mods), TapHistory> keyHistoryCache = static readonly Cache<(Keycode Key, Modifiers Mods), TapHistory> keyHistoryCache =
new Cache<(Keycode, Modifiers), TapHistory>(_ => new TapHistory(DateTime.Now - TimeSpan.FromSeconds(1))); new Cache<(Keycode, Modifiers), TapHistory>(_ => new TapHistory(DateTime.Now - TimeSpan.FromSeconds(1)));
static Cache<byte, TapHistory> clickHistoryCache = static readonly Cache<byte, TapHistory> clickHistoryCache =
new Cache<byte, TapHistory>(_ => new TapHistory(DateTime.Now - TimeSpan.FromSeconds(1))); new Cache<byte, TapHistory>(_ => new TapHistory(DateTime.Now - TimeSpan.FromSeconds(1)));
public static int DetectFromMouse(byte button, int2 xy) public static int DetectFromMouse(byte button, int2 xy)

View File

@@ -19,7 +19,7 @@ namespace OpenRA.Test
[TestFixture] [TestFixture]
public class VariableExpressionTest public class VariableExpressionTest
{ {
IReadOnlyDictionary<string, int> testValues = new Dictionary<string, int> readonly IReadOnlyDictionary<string, int> testValues = new Dictionary<string, int>
{ {
{ "t", 5 }, { "t", 5 },
{ "t-1", 7 }, { "t-1", 7 },