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

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

View File

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

View File

@@ -101,10 +101,7 @@ namespace OpenRA.Mods.Cnc.FileFormats
this.dataSize = dataSize;
}
public override long Length
{
get { return outputSize; }
}
public override long Length => outputSize;
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 ushort Frames { get { return frames; } }
public byte Framerate { get { return framerate; } }
public ushort Width { get { return width; } }
public ushort Height { get { return height; } }
public ushort Frames => frames;
public byte Framerate => framerate;
public ushort Width => width;
public ushort Height => height;
readonly ushort frames;
readonly byte framerate;
@@ -65,12 +65,12 @@ namespace OpenRA.Mods.Cnc.FileFormats
byte[] audioData; // audio for this frame: 22050Hz 16bit mono pcm, uncompressed.
bool hasAudio;
public byte[] AudioData { get { return audioData; } }
public int CurrentFrame { get { return currentFrame; } }
public int SampleRate { get { return sampleRate; } }
public int SampleBits { get { return sampleBits; } }
public int AudioChannels { get { return audioChannels; } }
public bool HasAudio { get { return hasAudio; } }
public byte[] AudioData => audioData;
public int CurrentFrame => currentFrame;
public int SampleRate => sampleRate;
public int SampleBits => sampleBits;
public int AudioChannels => audioChannels;
public bool HasAudio => hasAudio;
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)
{

View File

@@ -23,7 +23,7 @@ namespace OpenRA.Mods.Cnc.FileSystem
sealed class BigFile : IReadOnlyPackage
{
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 Stream s;

View File

@@ -25,7 +25,7 @@ namespace OpenRA.Mods.Cnc.FileSystem
public sealed class MixFile : IReadOnlyPackage
{
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 long dataStart;

View File

@@ -30,7 +30,7 @@ namespace OpenRA.Mods.Cnc.FileSystem
sealed class PakFile : IReadOnlyPackage
{
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 Stream stream;

View File

@@ -61,10 +61,10 @@ namespace OpenRA.Mods.Cnc.Graphics
cache = new IFinalizedRenderable[] { };
}
public WPos Pos { get { return pos; } }
public PaletteReference Palette { get { return null; } }
public int ZOffset { get { return zOffset; } }
public bool IsDecoration { get { return true; } }
public WPos Pos => pos;
public PaletteReference Palette => null;
public int ZOffset => zOffset;
public bool IsDecoration => true;
public IPalettedRenderable WithPalette(PaletteReference newPalette)
{

View File

@@ -32,8 +32,8 @@ namespace OpenRA.Mods.Cnc.Graphics
readonly uint frames;
readonly uint limbs;
uint IModel.Frames { get { return frames; } }
uint IModel.Sections { get { return limbs; } }
uint IModel.Frames => frames;
uint IModel.Sections => limbs;
public Voxel(VoxelLoader loader, VxlReader vxl, HvaReader hva, (string Vxl, string Hva) files)
{

View File

@@ -114,7 +114,7 @@ namespace OpenRA.Mods.Cnc.Graphics
return models[model].ContainsKey(sequence);
}
public IVertexBuffer<Vertex> VertexBuffer { get { return loader.VertexBuffer; } }
public IVertexBuffer<Vertex> VertexBuffer => loader.VertexBuffer;
public void Dispose()
{

View File

@@ -30,12 +30,12 @@ namespace OpenRA.Mods.Cnc.SpriteLoaders
class ShpD2Frame : ISpriteFrame
{
public SpriteFrameType Type { get { return SpriteFrameType.Indexed8; } }
public SpriteFrameType Type => SpriteFrameType.Indexed8;
public Size Size { get; private set; }
public Size FrameSize { get { return Size; } }
public float2 Offset { get { return float2.Zero; } }
public Size FrameSize => Size;
public float2 Offset => float2.Zero;
public byte[] Data { get; set; }
public bool DisableExportPadding { get { return false; } }
public bool DisableExportPadding => false;
public ShpD2Frame(Stream s)
{

View File

@@ -77,12 +77,12 @@ namespace OpenRA.Mods.Cnc.SpriteLoaders
class ImageHeader : ISpriteFrame
{
public SpriteFrameType Type { get { return SpriteFrameType.Indexed8; } }
public Size Size { get { return reader.Size; } }
public Size FrameSize { get { return reader.Size; } }
public float2 Offset { get { return float2.Zero; } }
public SpriteFrameType Type => SpriteFrameType.Indexed8;
public Size Size => reader.Size;
public Size FrameSize => reader.Size;
public float2 Offset => float2.Zero;
public byte[] Data { get; set; }
public bool DisableExportPadding { get { return false; } }
public bool DisableExportPadding => false;
public uint FileOffset;
public Format Format;

View File

@@ -19,12 +19,12 @@ namespace OpenRA.Mods.Cnc.SpriteLoaders
{
class TmpRAFrame : ISpriteFrame
{
public SpriteFrameType Type { get { return SpriteFrameType.Indexed8; } }
public SpriteFrameType Type => SpriteFrameType.Indexed8;
public Size Size { get; private set; }
public Size FrameSize { get; private set; }
public float2 Offset { get { return float2.Zero; } }
public float2 Offset => float2.Zero;
public byte[] Data { get; set; }
public bool DisableExportPadding { get { return false; } }
public bool DisableExportPadding => false;
public TmpRAFrame(byte[] data, Size size)
{

View File

@@ -19,12 +19,12 @@ namespace OpenRA.Mods.Cnc.SpriteLoaders
{
class TmpTDFrame : ISpriteFrame
{
public SpriteFrameType Type { get { return SpriteFrameType.Indexed8; } }
public SpriteFrameType Type => SpriteFrameType.Indexed8;
public Size Size { get; private set; }
public Size FrameSize { get; private set; }
public float2 Offset { get { return float2.Zero; } }
public float2 Offset => float2.Zero;
public byte[] Data { get; set; }
public bool DisableExportPadding { get { return false; } }
public bool DisableExportPadding => false;
public TmpTDFrame(byte[] data, Size size)
{

View File

@@ -21,12 +21,12 @@ namespace OpenRA.Mods.Cnc.SpriteLoaders
{
readonly TmpTSFrame parent;
public SpriteFrameType Type { get { return SpriteFrameType.Indexed8; } }
public Size Size { get { return parent.Size; } }
public Size FrameSize { get { return Size; } }
public float2 Offset { get { return parent.Offset; } }
public byte[] Data { get { return parent.DepthData; } }
public bool DisableExportPadding { get { return false; } }
public SpriteFrameType Type => SpriteFrameType.Indexed8;
public Size Size => parent.Size;
public Size FrameSize => Size;
public float2 Offset => parent.Offset;
public byte[] Data => parent.DepthData;
public bool DisableExportPadding => false;
public TmpTSDepthFrame(TmpTSFrame parent)
{
@@ -36,13 +36,13 @@ namespace OpenRA.Mods.Cnc.SpriteLoaders
class TmpTSFrame : ISpriteFrame
{
public SpriteFrameType Type { get { return SpriteFrameType.Indexed8; } }
public SpriteFrameType Type => SpriteFrameType.Indexed8;
public Size Size { get; private set; }
public Size FrameSize { get { return Size; } }
public Size FrameSize => Size;
public float2 Offset { get; private set; }
public byte[] Data { get; set; }
public byte[] DepthData { get; set; }
public bool DisableExportPadding { get { return false; } }
public bool DisableExportPadding => false;
public TmpTSFrame(Stream s, Size size, int u, int v)
{

View File

@@ -162,7 +162,7 @@ namespace OpenRA.Mods.Cnc.Traits
}
Color ISelectionBar.GetColor() { return Info.TimeBarColor; }
bool ISelectionBar.DisplayWhenEmpty { get { return false; } }
bool ISelectionBar.DisplayWhenEmpty => false;
void ModifyActorInit(TypeDictionary init)
{

View File

@@ -254,6 +254,6 @@ namespace OpenRA.Mods.Cnc.Traits
}
Color ISelectionBar.GetColor() { return info.TimeBarColor; }
bool ISelectionBar.DisplayWhenEmpty { get { return false; } }
bool ISelectionBar.DisplayWhenEmpty => false;
}
}

View File

@@ -37,13 +37,7 @@ namespace OpenRA.Mods.Cnc.Traits
disguise = self.Trait<Disguise>();
}
public ITooltipInfo TooltipInfo
{
get
{
return disguise.Disguised ? disguise.AsTooltipInfo : Info;
}
}
public ITooltipInfo TooltipInfo => disguise.Disguised ? disguise.AsTooltipInfo : Info;
public Player Owner
{
@@ -98,7 +92,7 @@ namespace OpenRA.Mods.Cnc.Traits
public readonly string Cursor = "ability";
[GrantedConditionReference]
public IEnumerable<string> LinterConditions { get { return DisguisedAsConditions.Values; } }
public IEnumerable<string> LinterConditions => DisguisedAsConditions.Values;
public override object Create(ActorInitializer init) { return new Disguise(init.Self, this); }
}
@@ -110,8 +104,8 @@ namespace OpenRA.Mods.Cnc.Traits
public Player AsPlayer { get; private set; }
public ITooltipInfo AsTooltipInfo { get; private set; }
public bool Disguised { get { return AsPlayer != null; } }
public Player Owner { get { return AsPlayer; } }
public bool Disguised => AsPlayer != null;
public Player Owner => AsPlayer;
readonly Actor self;
readonly DisguiseInfo info;

View File

@@ -337,8 +337,8 @@ namespace OpenRA.Mods.Cnc.Traits
class BeginMinefieldOrderTargeter : IOrderTargeter
{
public string OrderID { get { return "BeginMinefield"; } }
public int OrderPriority { get { return 5; } }
public string OrderID => "BeginMinefield";
public int OrderPriority => 5;
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, List<Actor> othersAtTarget, ref TargetModifiers modifiers, ref string cursor)

View File

@@ -149,10 +149,7 @@ namespace OpenRA.Mods.Cnc.Traits
chargeTick = Info.ChargeDelay;
}
public bool CanTeleport
{
get { return chargeTick <= 0; }
}
public bool CanTeleport => chargeTick <= 0;
float ISelectionBar.GetValue()
{
@@ -160,7 +157,7 @@ namespace OpenRA.Mods.Cnc.Traits
}
Color ISelectionBar.GetColor() { return Color.Magenta; }
bool ISelectionBar.DisplayWhenEmpty { get { return false; } }
bool ISelectionBar.DisplayWhenEmpty => false;
}
class PortableChronoOrderTargeter : IOrderTargeter
@@ -172,8 +169,8 @@ namespace OpenRA.Mods.Cnc.Traits
this.targetCursor = targetCursor;
}
public string OrderID { get { return "PortableChronoTeleport"; } }
public int OrderPriority { get { return 5; } }
public string OrderID => "PortableChronoTeleport";
public int OrderPriority => 5;
public bool IsQueued { get; protected set; }
public bool TargetOverridesSelection(Actor self, in Target target, List<Actor> actorsAt, CPos xy, TargetModifiers modifiers) { return true; }

View File

@@ -45,7 +45,7 @@ namespace OpenRA.Mods.Cnc.Traits
return new ReadOnlyDictionary<CPos, SubCell>(occupied);
}
bool IOccupySpaceInfo.SharesCell { get { return false; } }
bool IOccupySpaceInfo.SharesCell => false;
// Used to determine if actor can spawn
public bool CanEnterCell(World world, Actor self, CPos cell, SubCell subCell = SubCell.FullCell, Actor ignoreActor = null, BlockedByActor check = BlockedByActor.All)
@@ -70,19 +70,19 @@ namespace OpenRA.Mods.Cnc.Traits
[Sync]
public WAngle Facing
{
get { return orientation.Yaw; }
set { orientation = orientation.WithYaw(value); }
get => orientation.Yaw;
set => orientation = orientation.WithYaw(value);
}
public WRot Orientation { get { return orientation; } }
public WRot Orientation => orientation;
[Sync]
public WPos CenterPosition { get; private set; }
public CPos TopLeft { get { return self.World.Map.CellContaining(CenterPosition); } }
public CPos TopLeft => self.World.Map.CellContaining(CenterPosition);
// Isn't used anyway
public WAngle TurnSpeed { get { return WAngle.Zero; } }
public WAngle TurnSpeed => WAngle.Zero;
CPos cachedLocation;
@@ -142,10 +142,7 @@ namespace OpenRA.Mods.Cnc.Traits
Facing = Facing == Left ? Right : Left;
}
int MovementSpeed
{
get { return OpenRA.Mods.Common.Util.ApplyPercentageModifiers(Info.Speed, speedModifiers); }
}
int MovementSpeed => OpenRA.Mods.Common.Util.ApplyPercentageModifiers(Info.Speed, speedModifiers);
public (CPos, SubCell)[] OccupiedCells() { return new[] { (TopLeft, SubCell.FullCell) }; }
@@ -223,7 +220,7 @@ namespace OpenRA.Mods.Cnc.Traits
public CPos NearestMoveableCell(CPos cell) { return cell; }
// Actors with TDGunboat always move
public MovementType CurrentMovementTypes { get { return MovementType.Horizontal; } set { } }
public MovementType CurrentMovementTypes { get => MovementType.Horizontal; set { } }
public bool CanEnterTargetNow(Actor self, in Target target)
{

View File

@@ -58,6 +58,6 @@ namespace OpenRA.Mods.Cnc.Traits
this.remaining = remaining;
}
string IConditionTimerWatcher.Condition { get { return info.Condition; } }
string IConditionTimerWatcher.Condition => info.Condition;
}
}

View File

@@ -22,7 +22,7 @@ namespace OpenRA.Mods.Cnc.UtilityCommands
{
class ConvertPngToShpCommand : IUtilityCommand
{
string IUtilityCommand.Name { get { return "--shp"; } }
string IUtilityCommand.Name => "--shp";
bool IUtilityCommand.ValidateArguments(string[] args)
{

View File

@@ -26,7 +26,7 @@ namespace OpenRA.Mods.Cnc.UtilityCommands
public ImportRedAlertLegacyMapCommand()
: base(128) { }
string IUtilityCommand.Name { get { return "--import-ra-map"; } }
string IUtilityCommand.Name => "--import-ra-map";
bool IUtilityCommand.ValidateArguments(string[] args) { return ValidateArguments(args); }
[Desc("FILENAME", "Convert a legacy Red Alert INI/MPR map to the OpenRA format.")]

View File

@@ -26,7 +26,7 @@ namespace OpenRA.Mods.Cnc.UtilityCommands
{
class ImportTSMapCommand : IUtilityCommand
{
string IUtilityCommand.Name { get { return "--import-ts-map"; } }
string IUtilityCommand.Name => "--import-ts-map";
bool IUtilityCommand.ValidateArguments(string[] args) { return args.Length >= 2; }
static readonly Dictionary<byte, string> OverlayToActor = new Dictionary<byte, string>()

View File

@@ -24,7 +24,7 @@ namespace OpenRA.Mods.Cnc.UtilityCommands
public ImportTiberianDawnLegacyMapCommand()
: base(64) { }
string IUtilityCommand.Name { get { return "--import-td-map"; } }
string IUtilityCommand.Name => "--import-td-map";
bool IUtilityCommand.ValidateArguments(string[] args) { return ValidateArguments(args); }
[Desc("FILENAME", "Convert a legacy Tiberian Dawn INI/MPR map to the OpenRA format.")]

View File

@@ -24,7 +24,7 @@ namespace OpenRA.Mods.Cnc.UtilityCommands
return args.Length >= 3;
}
string IUtilityCommand.Name { get { return "--rules-import"; } }
string IUtilityCommand.Name => "--rules-import";
IniFile rulesIni;
IniFile artIni;

View File

@@ -23,7 +23,7 @@ namespace OpenRA.Mods.Cnc.UtilityCommands
return args.Length >= 2;
}
string IUtilityCommand.Name { get { return "--sequence-import"; } }
string IUtilityCommand.Name => "--sequence-import";
IniFile file;
MapGrid grid;

View File

@@ -20,7 +20,7 @@ namespace OpenRA.Mods.Cnc.UtilityCommands
{
class ImportLegacyTilesetCommand : IUtilityCommand
{
string IUtilityCommand.Name { get { return "--tileset-import"; } }
string IUtilityCommand.Name => "--tileset-import";
bool IUtilityCommand.ValidateArguments(string[] args)
{

View File

@@ -20,7 +20,7 @@ namespace OpenRA.Mods.Cnc.UtilityCommands
{
class ListMixContents : IUtilityCommand
{
string IUtilityCommand.Name { get { return "--list-mix"; } }
string IUtilityCommand.Name => "--list-mix";
bool IUtilityCommand.ValidateArguments(string[] args)
{

View File

@@ -22,7 +22,7 @@ namespace OpenRA.Mods.Cnc.UtilityCommands
{
class RemapShpCommand : IUtilityCommand
{
string IUtilityCommand.Name { get { return "--remap"; } }
string IUtilityCommand.Name => "--remap";
bool IUtilityCommand.ValidateArguments(string[] args)
{