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

@@ -95,13 +95,13 @@ namespace OpenRA.Mods.Common.Traits
[Sync]
bool buildAnywhere;
public bool FastCharge { get { return Enabled && fastCharge; } }
public bool AllTech { get { return Enabled && allTech; } }
public bool FastBuild { get { return Enabled && fastBuild; } }
public bool DisableShroud { get { return Enabled && disableShroud; } }
public bool PathDebug { get { return Enabled && pathDebug; } }
public bool UnlimitedPower { get { return Enabled && unlimitedPower; } }
public bool BuildAnywhere { get { return Enabled && buildAnywhere; } }
public bool FastCharge => Enabled && fastCharge;
public bool AllTech => Enabled && allTech;
public bool FastBuild => Enabled && fastBuild;
public bool DisableShroud => Enabled && disableShroud;
public bool PathDebug => Enabled && pathDebug;
public bool UnlimitedPower => Enabled && unlimitedPower;
public bool BuildAnywhere => Enabled && buildAnywhere;
bool enableAll;
@@ -275,6 +275,6 @@ namespace OpenRA.Mods.Common.Traits
Game.Debug("Cheat used: {0} by {1}{2}", order.OrderString, self.Owner.PlayerName, debugSuffix);
}
bool IUnlocksRenderPlayer.RenderPlayerUnlocked { get { return Enabled; } }
bool IUnlocksRenderPlayer.RenderPlayerUnlocked => Enabled;
}
}

View File

@@ -23,9 +23,9 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Internal id for this bot.")]
public readonly string Type = null;
string IBotInfo.Type { get { return Type; } }
string IBotInfo.Type => Type;
string IBotInfo.Name { get { return Name; } }
string IBotInfo.Name => Name;
public override object Create(ActorInitializer init) { return new DummyBot(this); }
}
@@ -49,7 +49,7 @@ namespace OpenRA.Mods.Common.Traits
void IBot.QueueOrder(Order order) { }
IBotInfo IBot.Info { get { return info; } }
Player IBot.Player { get { return player; } }
IBotInfo IBot.Info => info;
Player IBot.Player => player;
}
}

View File

@@ -276,7 +276,7 @@ namespace OpenRA.Mods.Common.Traits
{
readonly ObjectivesPanelInfo info;
public ObjectivesPanel(ObjectivesPanelInfo info) { this.info = info; }
public string PanelName { get { return info.PanelName; } }
public int ExitDelay { get { return info.ExitDelay; } }
public string PanelName => info.PanelName;
public int ExitDelay => info.ExitDelay;
}
}

View File

@@ -30,9 +30,9 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Minimum portion of pending orders to issue each tick (e.g. 5 issues at least 1/5th of all pending orders). Excess orders remain queued for subsequent ticks.")]
public readonly int MinOrderQuotientPerTick = 5;
string IBotInfo.Type { get { return Type; } }
string IBotInfo.Type => Type;
string IBotInfo.Name { get { return Name; } }
string IBotInfo.Name => Name;
public override object Create(ActorInitializer init) { return new ModularBot(this, init); }
}
@@ -50,8 +50,8 @@ namespace OpenRA.Mods.Common.Traits
IBotTick[] tickModules;
IBotRespondToAttack[] attackResponseModules;
IBotInfo IBot.Info { get { return info; } }
Player IBot.Player { get { return player; } }
IBotInfo IBot.Info => info;
Player IBot.Player => player;
public ModularBot(ModularBotInfo info, ActorInitializer init)
{

View File

@@ -81,10 +81,7 @@ namespace OpenRA.Mods.Common.Traits
});
}
public (int Left, int Right) this[MPos uv]
{
get { return terrainColor[uv]; }
}
public (int Left, int Right) this[MPos uv] => terrainColor[uv];
public static (int Left, int Right) GetColor(Map map, MPos uv)
{

View File

@@ -31,13 +31,7 @@ namespace OpenRA.Mods.Common.Traits
public int OrderCount;
public int Experience
{
get
{
return experience != null ? experience.Experience : 0;
}
}
public int Experience => experience != null ? experience.Experience : 0;
// Low resolution (every 30 seconds) record of earnings, covering the entire game
public List<int> IncomeSamples = new List<int>(100);

View File

@@ -116,7 +116,7 @@ namespace OpenRA.Mods.Common.Traits
protected DeveloperMode developerMode;
protected TechTree techTree;
public Actor Actor { get { return self; } }
public Actor Actor => self;
[Sync]
public bool Enabled { get; protected set; }
@@ -603,14 +603,9 @@ namespace OpenRA.Mods.Common.Traits
public int TotalTime { get; private set; }
public int RemainingTime { get; private set; }
public int RemainingCost { get; private set; }
public int RemainingTimeActual
{
get
{
return (pm == null || pm.PowerState == PowerState.Normal) ? RemainingTime :
RemainingTime * Queue.Info.LowPowerModifier / 100;
}
}
public int RemainingTimeActual =>
(pm == null || pm.PowerState == PowerState.Normal) ? RemainingTime :
RemainingTime * Queue.Info.LowPowerModifier / 100;
public bool Paused { get; private set; }
public bool Done { get; private set; }

View File

@@ -37,15 +37,9 @@ namespace OpenRA.Mods.Common.Traits
static readonly string[] NoPrerequisites = new string[0];
public string Name { get { return info.Name; } }
public string Name => info.Name;
public IEnumerable<string> ProvidesPrerequisites
{
get
{
return enabled ? info.Prerequisites : NoPrerequisites;
}
}
public IEnumerable<string> ProvidesPrerequisites => enabled ? info.Prerequisites : NoPrerequisites;
public ProvidesTechPrerequisite(ProvidesTechPrerequisiteInfo info, ActorInitializer init)
{

View File

@@ -66,15 +66,12 @@ namespace OpenRA.Mods.Common.Traits
shortGame = player.World.WorldActor.Trait<MapOptions>().ShortGame;
}
public IEnumerable<Actor> AllPoints
{
get { return player.World.ActorsHavingTrait<StrategicPoint>(); }
}
public IEnumerable<Actor> AllPoints => player.World.ActorsHavingTrait<StrategicPoint>();
public int Total { get { return AllPoints.Count(); } }
public int Total => AllPoints.Count();
int Owned { get { return AllPoints.Count(a => a.Owner.RelationshipWith(player) == PlayerRelationship.Ally); } }
public bool Holding { get { return Owned >= info.RatioRequired * Total / 100; } }
public bool Holding => Owned >= info.RatioRequired * Total / 100;
void ITick.Tick(Actor self)
{

View File

@@ -106,12 +106,12 @@ namespace OpenRA.Mods.Common.Traits
return ret;
}
public Player Owner { get { return player; } }
public Player Owner => player;
class Watcher
{
public readonly string Key;
public ITechTreeElement RegisteredBy { get { return watcher; } }
public ITechTreeElement RegisteredBy => watcher;
// Strings may be either actor type, or "alternate name" key
readonly string[] prerequisites;