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

@@ -19,14 +19,14 @@ namespace OpenRA.Mods.Common.Scripting.Global
public AngleGlobal(ScriptContext context)
: base(context) { }
public WAngle North { get { return WAngle.Zero; } }
public WAngle NorthWest { get { return new WAngle(128); } }
public WAngle West { get { return new WAngle(256); } }
public WAngle SouthWest { get { return new WAngle(384); } }
public WAngle South { get { return new WAngle(512); } }
public WAngle SouthEast { get { return new WAngle(640); } }
public WAngle East { get { return new WAngle(768); } }
public WAngle NorthEast { get { return new WAngle(896); } }
public WAngle North => WAngle.Zero;
public WAngle NorthWest => new WAngle(128);
public WAngle West => new WAngle(256);
public WAngle SouthWest => new WAngle(384);
public WAngle South => new WAngle(512);
public WAngle SouthEast => new WAngle(640);
public WAngle East => new WAngle(768);
public WAngle NorthEast => new WAngle(896);
[Desc("Create an arbitrary angle.")]
public WAngle New(int a) { return new WAngle(a); }

View File

@@ -22,8 +22,8 @@ namespace OpenRA.Mods.Common.Scripting
[Desc("The center of the visible viewport.")]
public WPos Position
{
get { return Context.WorldRenderer.Viewport.CenterPosition; }
set { Context.WorldRenderer.Viewport.Center(value); }
get => Context.WorldRenderer.Viewport.CenterPosition;
set => Context.WorldRenderer.Viewport.Center(value);
}
}
}

View File

@@ -51,41 +51,41 @@ namespace OpenRA.Mods.Common.Scripting.Global
throw new LuaException("Invalid rrggbb[aa] hex string.");
}
public Color Aqua { get { return Color.Aqua; } }
public Color Black { get { return Color.Black; } }
public Color Blue { get { return Color.Blue; } }
public Color Brown { get { return Color.Brown; } }
public Color Cyan { get { return Color.Cyan; } }
public Color DarkBlue { get { return Color.DarkBlue; } }
public Color DarkCyan { get { return Color.DarkCyan; } }
public Color DarkGray { get { return Color.DarkGray; } }
public Color DarkGreen { get { return Color.DarkGreen; } }
public Color DarkOrange { get { return Color.DarkOrange; } }
public Color DarkRed { get { return Color.DarkRed; } }
public Color Fuchsia { get { return Color.Fuchsia; } }
public Color Gold { get { return Color.Gold; } }
public Color Gray { get { return Color.Gray; } }
public Color Green { get { return Color.Green; } }
public Color LawnGreen { get { return Color.LawnGreen; } }
public Color LightBlue { get { return Color.LightBlue; } }
public Color LightCyan { get { return Color.LightCyan; } }
public Color LightGray { get { return Color.LightGray; } }
public Color LightGreen { get { return Color.LightGreen; } }
public Color LightYellow { get { return Color.LightYellow; } }
public Color Lime { get { return Color.Lime; } }
public Color LimeGreen { get { return Color.LimeGreen; } }
public Color Magenta { get { return Color.Magenta; } }
public Color Maroon { get { return Color.Maroon; } }
public Color Navy { get { return Color.Navy; } }
public Color Olive { get { return Color.Olive; } }
public Color Orange { get { return Color.Orange; } }
public Color OrangeRed { get { return Color.OrangeRed; } }
public Color Purple { get { return Color.Purple; } }
public Color Red { get { return Color.Red; } }
public Color Salmon { get { return Color.Salmon; } }
public Color SkyBlue { get { return Color.SkyBlue; } }
public Color Teal { get { return Color.Teal; } }
public Color Yellow { get { return Color.Yellow; } }
public Color White { get { return Color.White; } }
public Color Aqua => Color.Aqua;
public Color Black => Color.Black;
public Color Blue => Color.Blue;
public Color Brown => Color.Brown;
public Color Cyan => Color.Cyan;
public Color DarkBlue => Color.DarkBlue;
public Color DarkCyan => Color.DarkCyan;
public Color DarkGray => Color.DarkGray;
public Color DarkGreen => Color.DarkGreen;
public Color DarkOrange => Color.DarkOrange;
public Color DarkRed => Color.DarkRed;
public Color Fuchsia => Color.Fuchsia;
public Color Gold => Color.Gold;
public Color Gray => Color.Gray;
public Color Green => Color.Green;
public Color LawnGreen => Color.LawnGreen;
public Color LightBlue => Color.LightBlue;
public Color LightCyan => Color.LightCyan;
public Color LightGray => Color.LightGray;
public Color LightGreen => Color.LightGreen;
public Color LightYellow => Color.LightYellow;
public Color Lime => Color.Lime;
public Color LimeGreen => Color.LimeGreen;
public Color Magenta => Color.Magenta;
public Color Maroon => Color.Maroon;
public Color Navy => Color.Navy;
public Color Olive => Color.Olive;
public Color Orange => Color.Orange;
public Color OrangeRed => Color.OrangeRed;
public Color Purple => Color.Purple;
public Color Red => Color.Red;
public Color Salmon => Color.Salmon;
public Color SkyBlue => Color.SkyBlue;
public Color Teal => Color.Teal;
public Color Yellow => Color.Yellow;
public Color White => Color.White;
}
}

View File

@@ -22,7 +22,7 @@ namespace OpenRA.Mods.Common.Scripting
public CPos New(int x, int y) { return new CPos(x, y); }
[Desc("The cell coordinate origin.")]
public CPos Zero { get { return CPos.Zero; } }
public CPos Zero => CPos.Zero;
}
[ScriptGlobal("CVec")]
@@ -35,7 +35,7 @@ namespace OpenRA.Mods.Common.Scripting
public CVec New(int x, int y) { return new CVec(x, y); }
[Desc("The cell zero-vector.")]
public CVec Zero { get { return CVec.Zero; } }
public CVec Zero => CVec.Zero;
}
[ScriptGlobal("WPos")]
@@ -48,7 +48,7 @@ namespace OpenRA.Mods.Common.Scripting
public WPos New(int x, int y, int z) { return new WPos(x, y, z); }
[Desc("The world coordinate origin.")]
public WPos Zero { get { return WPos.Zero; } }
public WPos Zero => WPos.Zero;
}
[ScriptGlobal("WVec")]
@@ -61,7 +61,7 @@ namespace OpenRA.Mods.Common.Scripting
public WVec New(int x, int y, int z) { return new WVec(x, y, z); }
[Desc("The world zero-vector.")]
public WVec Zero { get { return WVec.Zero; } }
public WVec Zero => WVec.Zero;
}
[ScriptGlobal("WDist")]

View File

@@ -28,16 +28,10 @@ namespace OpenRA.Mods.Common.Scripting
}
[Desc("True on the 31st of October.")]
public bool IsHalloween
{
get { return DateTime.Today.Month == 10 && DateTime.Today.Day == 31; }
}
public bool IsHalloween => DateTime.Today.Month == 10 && DateTime.Today.Day == 31;
[Desc("Get the current game time (in ticks).")]
public int GameTime
{
get { return Context.World.WorldTick; }
}
public int GameTime => Context.World.WorldTick;
[Desc("Converts the number of seconds into game time (ticks).")]
public int Seconds(int seconds)
@@ -54,10 +48,7 @@ namespace OpenRA.Mods.Common.Scripting
[Desc("Return or set the time limit (in ticks). When setting, the time limit will count from now. Setting the time limit to 0 will disable it.")]
public int TimeLimit
{
get
{
return tlm != null ? tlm.TimeLimit : 0;
}
get => tlm != null ? tlm.TimeLimit : 0;
set
{
@@ -71,10 +62,7 @@ namespace OpenRA.Mods.Common.Scripting
[Desc("The notification string used for custom time limit warnings. See the TimeLimitManager trait documentation for details.")]
public string TimeLimitNotification
{
get
{
return tlm != null ? tlm.Notification : null;
}
get => tlm != null ? tlm.Notification : null;
set
{

View File

@@ -40,25 +40,25 @@ namespace OpenRA.Mods.Common.Scripting
public double Red
{
get { return hasLighting ? lighting.Red : 1d; }
get => hasLighting ? lighting.Red : 1d;
set { if (hasLighting) lighting.Red = (float)value; }
}
public double Green
{
get { return hasLighting ? lighting.Green : 1d; }
get => hasLighting ? lighting.Green : 1d;
set { if (hasLighting) lighting.Green = (float)value; }
}
public double Blue
{
get { return hasLighting ? lighting.Blue : 1d; }
get => hasLighting ? lighting.Blue : 1d;
set { if (hasLighting) lighting.Blue = (float)value; }
}
public double Ambient
{
get { return hasLighting ? lighting.Ambient : 1d; }
get => hasLighting ? lighting.Ambient : 1d;
set { if (hasLighting) lighting.Ambient = (float)value; }
}
}

View File

@@ -49,27 +49,15 @@ namespace OpenRA.Mods.Common.Scripting
return FilteredObjects(actors, filter).ToArray();
}
// HACK: This api method abuses the coordinate system, and should be removed
// in favour of proper actor queries. See #8549.
[Desc("Returns the location of the top-left corner of the map (assuming zero terrain height).")]
public WPos TopLeft
{
get
{
// HACK: This api method abuses the coordinate system, and should be removed
// in favour of proper actor queries. See #8549.
return Context.World.Map.ProjectedTopLeft;
}
}
public WPos TopLeft => Context.World.Map.ProjectedTopLeft;
// HACK: This api method abuses the coordinate system, and should be removed
// in favour of proper actor queries. See #8549.
[Desc("Returns the location of the bottom-right corner of the map (assuming zero terrain height).")]
public WPos BottomRight
{
get
{
// HACK: This api method abuses the coordinate system, and should be removed
// in favour of proper actor queries. See #8549.
return Context.World.Map.ProjectedBottomRight;
}
}
public WPos BottomRight => Context.World.Map.ProjectedBottomRight;
[Desc("Returns a random cell inside the visible region of the map.")]
public CPos RandomCell()
@@ -109,10 +97,10 @@ namespace OpenRA.Mods.Common.Scripting
}
[Desc("Returns true if there is only one human player.")]
public bool IsSinglePlayer { get { return Context.World.LobbyInfo.NonBotPlayers.Count() == 1; } }
public bool IsSinglePlayer => Context.World.LobbyInfo.NonBotPlayers.Count() == 1;
[Desc("Returns true if this is a shellmap and the player has paused animations.")]
public bool IsPausedShellmap { get { return Context.World.Type == WorldType.Shellmap && gameSettings.PauseShellmap; } }
public bool IsPausedShellmap => Context.World.Type == WorldType.Shellmap && gameSettings.PauseShellmap;
[Desc("Returns the value of a `ScriptLobbyDropdown` selected in the game lobby.")]
public LuaValue LobbyOption(string id)
@@ -127,10 +115,10 @@ namespace OpenRA.Mods.Common.Scripting
}
[Desc("Returns a table of all the actors that were specified in the map file.")]
public Actor[] NamedActors { get { return sma.Actors.Values.ToArray(); } }
public Actor[] NamedActors => sma.Actors.Values.ToArray();
[Desc("Returns the actor that was specified with a given name in " +
"the map file (or nil, if the actor is dead or not found).")]
"the map file (or nil, if the actor is dead or not found).")]
public Actor NamedActor(string actorName)
{
if (!sma.Actors.TryGetValue(actorName, out var ret))
@@ -155,6 +143,6 @@ namespace OpenRA.Mods.Common.Scripting
}
[Desc("Returns a table of all the actors that are currently on the map/in the world.")]
public Actor[] ActorsInWorld { get { return world.Actors.ToArray(); } }
public Actor[] ActorsInWorld => world.Actors.ToArray();
}
}