Use expression body syntax
This commit is contained in:
@@ -27,16 +27,16 @@ namespace OpenRA.Mods.Common.Scripting
|
||||
}
|
||||
|
||||
[Desc("The actor's amount of experience.")]
|
||||
public int Experience { get { return exp.Experience; } }
|
||||
public int Experience => exp.Experience;
|
||||
|
||||
[Desc("The actor's level.")]
|
||||
public int Level { get { return exp.Level; } }
|
||||
public int Level => exp.Level;
|
||||
|
||||
[Desc("The actor's maximum possible level.")]
|
||||
public int MaxLevel { get { return exp.MaxLevel; } }
|
||||
public int MaxLevel => exp.MaxLevel;
|
||||
|
||||
[Desc("Returns true if the actor can gain a level.")]
|
||||
public bool CanGainLevel { get { return exp.CanGainLevel; } }
|
||||
public bool CanGainLevel => exp.CanGainLevel;
|
||||
|
||||
[Desc("Gives the actor experience. If 'silent' is true, no animation or sound will be played if the actor levels up.")]
|
||||
public void GiveExperience(int amount, bool silent = false)
|
||||
|
||||
@@ -31,10 +31,7 @@ namespace OpenRA.Mods.Common.Scripting
|
||||
[Desc("Specifies whether the actor is in the world.")]
|
||||
public bool IsInWorld
|
||||
{
|
||||
get
|
||||
{
|
||||
return Self.IsInWorld;
|
||||
}
|
||||
get => Self.IsInWorld;
|
||||
|
||||
set
|
||||
{
|
||||
@@ -46,18 +43,15 @@ namespace OpenRA.Mods.Common.Scripting
|
||||
}
|
||||
|
||||
[Desc("Specifies whether the actor is alive or dead.")]
|
||||
public bool IsDead { get { return Self.IsDead; } }
|
||||
public bool IsDead => Self.IsDead;
|
||||
|
||||
[Desc("Specifies whether the actor is idle (not performing any activities).")]
|
||||
public bool IsIdle { get { return Self.IsIdle; } }
|
||||
public bool IsIdle => Self.IsIdle;
|
||||
|
||||
[Desc("The player that owns the actor.")]
|
||||
public Player Owner
|
||||
{
|
||||
get
|
||||
{
|
||||
return Self.Owner;
|
||||
}
|
||||
get => Self.Owner;
|
||||
|
||||
set
|
||||
{
|
||||
@@ -70,7 +64,7 @@ namespace OpenRA.Mods.Common.Scripting
|
||||
}
|
||||
|
||||
[Desc("The type of the actor (e.g. \"e1\").")]
|
||||
public string Type { get { return Self.Info.Name; } }
|
||||
public string Type => Self.Info.Name;
|
||||
|
||||
[Desc("Test whether an actor has a specific property.")]
|
||||
public bool HasProperty(string name)
|
||||
@@ -116,10 +110,10 @@ namespace OpenRA.Mods.Common.Scripting
|
||||
}
|
||||
|
||||
[Desc("The actor position in cell coordinates.")]
|
||||
public CPos Location { get { return Self.Location; } }
|
||||
public CPos Location => Self.Location;
|
||||
|
||||
[Desc("The actor position in world coordinates.")]
|
||||
public WPos CenterPosition { get { return Self.CenterPosition; } }
|
||||
public WPos CenterPosition => Self.CenterPosition;
|
||||
|
||||
[Desc("The direction that the actor is facing.")]
|
||||
public WAngle Facing
|
||||
@@ -170,10 +164,7 @@ namespace OpenRA.Mods.Common.Scripting
|
||||
[Desc("Current actor stance. Returns nil if this actor doesn't support stances.")]
|
||||
public string Stance
|
||||
{
|
||||
get
|
||||
{
|
||||
return autotarget?.Stance.ToString();
|
||||
}
|
||||
get => autotarget?.Stance.ToString();
|
||||
|
||||
set
|
||||
{
|
||||
@@ -200,7 +191,7 @@ namespace OpenRA.Mods.Common.Scripting
|
||||
}
|
||||
|
||||
[Desc("Specifies whether or not the actor supports 'tags'.")]
|
||||
public bool IsTaggable { get { return scriptTags != null; } }
|
||||
public bool IsTaggable => scriptTags != null;
|
||||
|
||||
[Desc("Add a tag to the actor. Returns true on success, false otherwise (for example the actor may already have the given tag).")]
|
||||
public bool AddTag(string tag)
|
||||
|
||||
@@ -29,12 +29,12 @@ namespace OpenRA.Mods.Common.Scripting
|
||||
[Desc("Current health of the actor.")]
|
||||
public int Health
|
||||
{
|
||||
get { return health.HP; }
|
||||
set { health.InflictDamage(Self, Self, new Damage(health.HP - value), true); }
|
||||
get => health.HP;
|
||||
set => health.InflictDamage(Self, Self, new Damage(health.HP - value), true);
|
||||
}
|
||||
|
||||
[Desc("Maximum health of the actor.")]
|
||||
public int MaxHealth { get { return health.MaxHP; } }
|
||||
public int MaxHealth => health.MaxHP;
|
||||
|
||||
[Desc("Kill the actor. damageTypes may be omitted, specified as a string, or as table of strings.")]
|
||||
public void Kill(object damageTypes = null)
|
||||
|
||||
@@ -67,6 +67,6 @@ namespace OpenRA.Mods.Common.Scripting
|
||||
}
|
||||
|
||||
[Desc("Whether the actor can move (false if immobilized).")]
|
||||
public bool IsMobile { get { return !mobile.IsTraitDisabled && !mobile.IsTraitPaused; } }
|
||||
public bool IsMobile => !mobile.IsTraitDisabled && !mobile.IsTraitPaused;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,15 +28,9 @@ namespace OpenRA.Mods.Common.Scripting
|
||||
|
||||
public int Experience
|
||||
{
|
||||
get
|
||||
{
|
||||
return exp.Experience;
|
||||
}
|
||||
get => exp.Experience;
|
||||
|
||||
set
|
||||
{
|
||||
exp.GiveExperience(value - exp.Experience);
|
||||
}
|
||||
set => exp.GiveExperience(value - exp.Experience);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,22 +25,22 @@ namespace OpenRA.Mods.Common.Scripting
|
||||
: base(context, player) { }
|
||||
|
||||
[Desc("The player's internal name.")]
|
||||
public string InternalName { get { return Player.InternalName; } }
|
||||
public string InternalName => Player.InternalName;
|
||||
|
||||
[Desc("The player's name.")]
|
||||
public string Name { get { return Player.PlayerName; } }
|
||||
public string Name => Player.PlayerName;
|
||||
|
||||
[Desc("The player's color.")]
|
||||
public Color Color { get { return Player.Color; } }
|
||||
public Color Color => Player.Color;
|
||||
|
||||
[Desc("The player's faction.")]
|
||||
public string Faction { get { return Player.Faction.InternalName; } }
|
||||
public string Faction => Player.Faction.InternalName;
|
||||
|
||||
[Desc("The player's spawnpoint ID.")]
|
||||
public int Spawn { get { return Player.SpawnPoint; } }
|
||||
public int Spawn => Player.SpawnPoint;
|
||||
|
||||
[Desc("The player's home/starting location.")]
|
||||
public CPos HomeLocation { get { return Player.HomeLocation; } }
|
||||
public CPos HomeLocation => Player.HomeLocation;
|
||||
|
||||
[Desc("The player's team ID.")]
|
||||
public int Team
|
||||
@@ -63,13 +63,13 @@ namespace OpenRA.Mods.Common.Scripting
|
||||
}
|
||||
|
||||
[Desc("Returns true if the player is a bot.")]
|
||||
public bool IsBot { get { return Player.IsBot; } }
|
||||
public bool IsBot => Player.IsBot;
|
||||
|
||||
[Desc("Returns true if the player is non combatant.")]
|
||||
public bool IsNonCombatant { get { return Player.NonCombatant; } }
|
||||
public bool IsNonCombatant => Player.NonCombatant;
|
||||
|
||||
[Desc("Returns true if the player is the local player.")]
|
||||
public bool IsLocalPlayer { get { return Player == (Player.World.RenderPlayer ?? Player.World.LocalPlayer); } }
|
||||
public bool IsLocalPlayer => Player == (Player.World.RenderPlayer ?? Player.World.LocalPlayer);
|
||||
|
||||
[Desc("Returns all living actors staying inside the world for this player.")]
|
||||
public Actor[] GetActors()
|
||||
|
||||
@@ -27,21 +27,21 @@ namespace OpenRA.Mods.Common.Scripting
|
||||
}
|
||||
|
||||
[Desc("The combined value of units killed by this player.")]
|
||||
public int KillsCost { get { return stats.KillsCost; } }
|
||||
public int KillsCost => stats.KillsCost;
|
||||
|
||||
[Desc("The combined value of all units lost by this player.")]
|
||||
public int DeathsCost { get { return stats.DeathsCost; } }
|
||||
public int DeathsCost => stats.DeathsCost;
|
||||
|
||||
[Desc("The total number of units killed by this player.")]
|
||||
public int UnitsKilled { get { return stats.UnitsKilled; } }
|
||||
public int UnitsKilled => stats.UnitsKilled;
|
||||
|
||||
[Desc("The total number of units lost by this player.")]
|
||||
public int UnitsLost { get { return stats.UnitsDead; } }
|
||||
public int UnitsLost => stats.UnitsDead;
|
||||
|
||||
[Desc("The total number of buildings killed by this player.")]
|
||||
public int BuildingsKilled { get { return stats.BuildingsKilled; } }
|
||||
public int BuildingsKilled => stats.BuildingsKilled;
|
||||
|
||||
[Desc("The total number of buildings lost by this player.")]
|
||||
public int BuildingsLost { get { return stats.BuildingsDead; } }
|
||||
public int BuildingsLost => stats.BuildingsDead;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,23 +29,14 @@ namespace OpenRA.Mods.Common.Scripting
|
||||
}
|
||||
|
||||
[Desc("Returns the total of the power the player has.")]
|
||||
public int PowerProvided
|
||||
{
|
||||
get { return pm.PowerProvided; }
|
||||
}
|
||||
public int PowerProvided => pm.PowerProvided;
|
||||
|
||||
[Desc("Returns the power used by the player.")]
|
||||
public int PowerDrained
|
||||
{
|
||||
get { return pm.PowerDrained; }
|
||||
}
|
||||
public int PowerDrained => pm.PowerDrained;
|
||||
|
||||
[Desc("Returns the player's power state " +
|
||||
"(\"Normal\", \"Low\" or \"Critical\").")]
|
||||
public string PowerState
|
||||
{
|
||||
get { return pm.PowerState.ToString(); }
|
||||
}
|
||||
"(\"Normal\", \"Low\" or \"Critical\").")]
|
||||
public string PowerState => pm.PowerState.ToString();
|
||||
|
||||
[Desc("Triggers low power for the chosen amount of ticks.")]
|
||||
public void TriggerPowerOutage(int ticks)
|
||||
|
||||
@@ -92,10 +92,7 @@ namespace OpenRA.Mods.Common.Scripting
|
||||
|
||||
return Self.Location;
|
||||
}
|
||||
set
|
||||
{
|
||||
rp.Path = new List<CPos> { value };
|
||||
}
|
||||
set => rp.Path = new List<CPos> { value };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,8 +110,8 @@ namespace OpenRA.Mods.Common.Scripting
|
||||
[Desc("Query or set the factory's primary building status.")]
|
||||
public bool IsPrimaryBuilding
|
||||
{
|
||||
get { return pb.IsPrimary; }
|
||||
set { pb.SetPrimaryProducer(Self, value); }
|
||||
get => pb.IsPrimary;
|
||||
set => pb.SetPrimaryProducer(Self, value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,18 +30,18 @@ namespace OpenRA.Mods.Common.Scripting
|
||||
[Desc("The amount of harvestable resources held by the player.")]
|
||||
public int Resources
|
||||
{
|
||||
get { return pr.Resources; }
|
||||
set { pr.Resources = value.Clamp(0, pr.ResourceCapacity); }
|
||||
get => pr.Resources;
|
||||
set => pr.Resources = value.Clamp(0, pr.ResourceCapacity);
|
||||
}
|
||||
|
||||
[Desc("The maximum resource storage of the player.")]
|
||||
public int ResourceCapacity { get { return pr.ResourceCapacity; } }
|
||||
public int ResourceCapacity => pr.ResourceCapacity;
|
||||
|
||||
[Desc("The amount of cash held by the player.")]
|
||||
public int Cash
|
||||
{
|
||||
get { return pr.Cash; }
|
||||
set { pr.Cash = Math.Max(0, value); }
|
||||
get => pr.Cash;
|
||||
set => pr.Cash = Math.Max(0, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,13 +30,13 @@ namespace OpenRA.Mods.Common.Scripting
|
||||
}
|
||||
|
||||
[Desc("Returns references to passengers inside the transport.")]
|
||||
public Actor[] Passengers { get { return cargo.Passengers.ToArray(); } }
|
||||
public Actor[] Passengers => cargo.Passengers.ToArray();
|
||||
|
||||
[Desc("Specifies whether transport has any passengers.")]
|
||||
public bool HasPassengers { get { return cargo.Passengers.Any(); } }
|
||||
public bool HasPassengers => cargo.Passengers.Any();
|
||||
|
||||
[Desc("Specifies the amount of passengers.")]
|
||||
public int PassengerCount { get { return cargo.Passengers.Count(); } }
|
||||
public int PassengerCount => cargo.Passengers.Count();
|
||||
|
||||
[Desc("Teleport an existing actor inside this transport.")]
|
||||
public void LoadPassenger(Actor a)
|
||||
|
||||
Reference in New Issue
Block a user