StyleCop clean OpenRA.Game
This commit is contained in:
@@ -33,7 +33,7 @@ namespace OpenRA.Mods.RA.Scripting
|
||||
|
||||
var cs = actor.TraitOrDefault<Chronoshiftable>();
|
||||
if (cs != null && cs.CanChronoshiftTo(actor, cell))
|
||||
cs.Teleport(actor, cell, duration, killCargo, self);
|
||||
cs.Teleport(actor, cell, duration, killCargo, Self);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace OpenRA.Mods.RA.Scripting
|
||||
[Desc("Seek out and attack nearby targets.")]
|
||||
public void Hunt()
|
||||
{
|
||||
self.QueueActivity(new Hunt(self));
|
||||
Self.QueueActivity(new Hunt(Self));
|
||||
}
|
||||
|
||||
[ScriptActorPropertyActivity]
|
||||
@@ -44,7 +44,7 @@ namespace OpenRA.Mods.RA.Scripting
|
||||
"close enough to complete the activity.")]
|
||||
public void AttackMove(CPos cell, int closeEnough = 0)
|
||||
{
|
||||
self.QueueActivity(new AttackMoveActivity(self, move.MoveTo(cell, closeEnough)));
|
||||
Self.QueueActivity(new AttackMoveActivity(Self, move.MoveTo(cell, closeEnough)));
|
||||
}
|
||||
|
||||
[ScriptActorPropertyActivity]
|
||||
@@ -54,12 +54,12 @@ namespace OpenRA.Mods.RA.Scripting
|
||||
{
|
||||
foreach (var wpt in waypoints)
|
||||
{
|
||||
self.QueueActivity(new AttackMoveActivity(self, move.MoveTo(wpt, 2)));
|
||||
self.QueueActivity(new Wait(wait));
|
||||
Self.QueueActivity(new AttackMoveActivity(Self, move.MoveTo(wpt, 2)));
|
||||
Self.QueueActivity(new Wait(wait));
|
||||
}
|
||||
|
||||
if (loop)
|
||||
self.QueueActivity(new CallFunc(() => Patrol(waypoints, loop, wait)));
|
||||
Self.QueueActivity(new CallFunc(() => Patrol(waypoints, loop, wait)));
|
||||
}
|
||||
|
||||
[ScriptActorPropertyActivity]
|
||||
@@ -69,10 +69,10 @@ namespace OpenRA.Mods.RA.Scripting
|
||||
{
|
||||
Patrol(waypoints, false, wait);
|
||||
|
||||
var repeat = func.Call(self.ToLuaValue(context)).First().ToBoolean();
|
||||
var repeat = func.Call(Self.ToLuaValue(Context)).First().ToBoolean();
|
||||
if (repeat)
|
||||
using (var f = func.CopyReference() as LuaFunction)
|
||||
self.QueueActivity(new CallFunc(() => PatrolUntil(waypoints, f, wait)));
|
||||
Self.QueueActivity(new CallFunc(() => PatrolUntil(waypoints, f, wait)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,46 +32,46 @@ namespace OpenRA.Mods.RA.Scripting
|
||||
{
|
||||
get
|
||||
{
|
||||
return self.IsInWorld;
|
||||
return Self.IsInWorld;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (value)
|
||||
self.World.AddFrameEndTask(w => w.Add(self));
|
||||
Self.World.AddFrameEndTask(w => w.Add(Self));
|
||||
else
|
||||
self.World.AddFrameEndTask(w => w.Remove(self));
|
||||
Self.World.AddFrameEndTask(w => w.Remove(Self));
|
||||
}
|
||||
}
|
||||
|
||||
[Desc("Specifies whether the actor is alive or dead.")]
|
||||
public bool IsDead { get { return self.IsDead; } }
|
||||
public bool IsDead { get { return Self.IsDead; } }
|
||||
|
||||
[Desc("Specifies whether the actor is idle (not performing any activities).")]
|
||||
public bool IsIdle { get { return self.IsIdle; } }
|
||||
public bool IsIdle { get { return Self.IsIdle; } }
|
||||
|
||||
[Desc("The player that owns the actor.")]
|
||||
public Player Owner
|
||||
{
|
||||
get
|
||||
{
|
||||
return self.Owner;
|
||||
return Self.Owner;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (self.Owner != value)
|
||||
self.ChangeOwner(value);
|
||||
if (Self.Owner != value)
|
||||
Self.ChangeOwner(value);
|
||||
}
|
||||
}
|
||||
|
||||
[Desc("The type of the actor (e.g. \"e1\").")]
|
||||
public string Type { get { return self.Info.Name; } }
|
||||
public string Type { get { return Self.Info.Name; } }
|
||||
|
||||
[Desc("Test whether an actor has a specific property.")]
|
||||
public bool HasProperty(string name)
|
||||
{
|
||||
return self.HasScriptProperty(name);
|
||||
return Self.HasScriptProperty(name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,10 +89,10 @@ namespace OpenRA.Mods.RA.Scripting
|
||||
}
|
||||
|
||||
[Desc("The actor position in cell coordinates.")]
|
||||
public CPos Location { get { return self.Location; } }
|
||||
public CPos Location { get { return Self.Location; } }
|
||||
|
||||
[Desc("The actor position in world coordinates.")]
|
||||
public WPos CenterPosition { get { return self.CenterPosition; } }
|
||||
public WPos CenterPosition { get { return Self.CenterPosition; } }
|
||||
|
||||
[Desc("The direction that the actor is facing.")]
|
||||
public int Facing
|
||||
@@ -100,7 +100,7 @@ namespace OpenRA.Mods.RA.Scripting
|
||||
get
|
||||
{
|
||||
if (facing == null)
|
||||
throw new LuaException("Actor '{0}' doesn't define a facing".F(self));
|
||||
throw new LuaException("Actor '{0}' doesn't define a facing".F(Self));
|
||||
|
||||
return facing.Facing;
|
||||
}
|
||||
@@ -110,34 +110,34 @@ namespace OpenRA.Mods.RA.Scripting
|
||||
[Desc("Instantly moves the actor to the specified cell.")]
|
||||
public void Teleport(CPos cell)
|
||||
{
|
||||
self.QueueActivity(new SimpleTeleport(cell));
|
||||
Self.QueueActivity(new SimpleTeleport(cell));
|
||||
}
|
||||
|
||||
[ScriptActorPropertyActivity]
|
||||
[Desc("Run an arbitrary Lua function.")]
|
||||
public void CallFunc(LuaFunction func)
|
||||
{
|
||||
self.QueueActivity(new CallLuaFunc(func, context));
|
||||
Self.QueueActivity(new CallLuaFunc(func, Context));
|
||||
}
|
||||
|
||||
[ScriptActorPropertyActivity]
|
||||
[Desc("Wait for a specified number of game ticks (25 ticks = 1 second).")]
|
||||
public void Wait(int ticks)
|
||||
{
|
||||
self.QueueActivity(new Wait(ticks));
|
||||
Self.QueueActivity(new Wait(ticks));
|
||||
}
|
||||
|
||||
[ScriptActorPropertyActivity]
|
||||
[Desc("Remove the actor from the game, without triggering any death notification.")]
|
||||
public void Destroy()
|
||||
{
|
||||
self.QueueActivity(new RemoveSelf());
|
||||
Self.QueueActivity(new RemoveSelf());
|
||||
}
|
||||
|
||||
[Desc("Attempt to cancel any active activities.")]
|
||||
public void Stop()
|
||||
{
|
||||
self.CancelActivity();
|
||||
Self.CancelActivity();
|
||||
}
|
||||
|
||||
[Desc("Current actor stance. Returns nil if this actor doesn't support stances.")]
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace OpenRA.Mods.RA.Scripting
|
||||
public void Guard(Actor targetActor)
|
||||
{
|
||||
if (targetActor.HasTrait<Guardable>())
|
||||
guard.GuardTarget(self, Target.FromActor(targetActor));
|
||||
guard.GuardTarget(Self, Target.FromActor(targetActor));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -29,7 +29,7 @@ namespace OpenRA.Mods.RA.Scripting
|
||||
[Desc("Search for nearby resources and begin harvesting.")]
|
||||
public void FindResources()
|
||||
{
|
||||
harvester.ContinueHarvesting(self);
|
||||
harvester.ContinueHarvesting(Self);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -26,7 +26,7 @@ namespace OpenRA.Mods.RA.Scripting
|
||||
[Desc("Fly within the cell grid.")]
|
||||
public void Move(CPos cell)
|
||||
{
|
||||
self.QueueActivity(new HeliFly(self, Target.FromCell(self.World, cell)));
|
||||
Self.QueueActivity(new HeliFly(Self, Target.FromCell(Self.World, cell)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -33,7 +33,7 @@ namespace OpenRA.Mods.RA.Scripting
|
||||
"ID of the newly created objective, so that it can be referred to later.")]
|
||||
public int AddPrimaryObjective(string description)
|
||||
{
|
||||
return mo.Add(player, description, ObjectiveType.Primary);
|
||||
return mo.Add(Player, description, ObjectiveType.Primary);
|
||||
}
|
||||
|
||||
[ScriptActorPropertyActivity]
|
||||
@@ -41,7 +41,7 @@ namespace OpenRA.Mods.RA.Scripting
|
||||
"ID of the newly created objective, so that it can be referred to later.")]
|
||||
public int AddSecondaryObjective(string description)
|
||||
{
|
||||
return mo.Add(player, description, ObjectiveType.Secondary);
|
||||
return mo.Add(Player, description, ObjectiveType.Secondary);
|
||||
}
|
||||
|
||||
[ScriptActorPropertyActivity]
|
||||
@@ -53,7 +53,7 @@ namespace OpenRA.Mods.RA.Scripting
|
||||
if (id < 0 || id >= mo.Objectives.Count)
|
||||
throw new LuaException("Objective ID is out of range.");
|
||||
|
||||
mo.MarkCompleted(player, id);
|
||||
mo.MarkCompleted(Player, id);
|
||||
}
|
||||
|
||||
[ScriptActorPropertyActivity]
|
||||
@@ -65,7 +65,7 @@ namespace OpenRA.Mods.RA.Scripting
|
||||
if (id < 0 || id >= mo.Objectives.Count)
|
||||
throw new LuaException("Objective ID is out of range.");
|
||||
|
||||
mo.MarkFailed(player, id);
|
||||
mo.MarkFailed(Player, id);
|
||||
}
|
||||
|
||||
[ScriptActorPropertyActivity]
|
||||
@@ -113,7 +113,7 @@ namespace OpenRA.Mods.RA.Scripting
|
||||
"the MustBeDestroyed trait (according to the short game option).")]
|
||||
public bool HasNoRequiredUnits()
|
||||
{
|
||||
return player.HasNoRequiredUnits();
|
||||
return Player.HasNoRequiredUnits();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,28 +33,28 @@ namespace OpenRA.Mods.RA.Scripting
|
||||
"(in cells) that will be considered close enough to complete the activity.")]
|
||||
public void Move(CPos cell, int closeEnough = 0)
|
||||
{
|
||||
self.QueueActivity(new Move(self, cell, WRange.FromCells(closeEnough)));
|
||||
Self.QueueActivity(new Move(Self, cell, WRange.FromCells(closeEnough)));
|
||||
}
|
||||
|
||||
[ScriptActorPropertyActivity]
|
||||
[Desc("Moves within the cell grid, ignoring lane biases.")]
|
||||
public void ScriptedMove(CPos cell)
|
||||
{
|
||||
self.QueueActivity(new Move(self, cell));
|
||||
Self.QueueActivity(new Move(Self, cell));
|
||||
}
|
||||
|
||||
[ScriptActorPropertyActivity]
|
||||
[Desc("Moves from outside the world into the cell grid")]
|
||||
public void MoveIntoWorld(CPos cell)
|
||||
{
|
||||
self.QueueActivity(mobile.MoveIntoWorld(self, cell, mobile.ToSubCell));
|
||||
Self.QueueActivity(mobile.MoveIntoWorld(Self, cell, mobile.ToSubCell));
|
||||
}
|
||||
|
||||
[ScriptActorPropertyActivity]
|
||||
[Desc("Leave the current position in a random direction.")]
|
||||
public void Scatter()
|
||||
{
|
||||
self.Trait<Mobile>().Nudge(self, self, true);
|
||||
Self.Trait<Mobile>().Nudge(Self, Self, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -26,14 +26,14 @@ namespace OpenRA.Mods.RA.Scripting
|
||||
[Desc("Fly within the cell grid.")]
|
||||
public void Move(CPos cell)
|
||||
{
|
||||
self.QueueActivity(new Fly(self, Target.FromCell(self.World, cell)));
|
||||
Self.QueueActivity(new Fly(Self, Target.FromCell(Self.World, cell)));
|
||||
}
|
||||
|
||||
[ScriptActorPropertyActivity]
|
||||
[Desc("Return to the base, which is either the airfield given, or an auto-selected one otherwise.")]
|
||||
public void ReturnToBase(Actor airfield = null)
|
||||
{
|
||||
self.QueueActivity(new ReturnToBase(self, airfield));
|
||||
Self.QueueActivity(new ReturnToBase(Self, airfield));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace OpenRA.Mods.RA.Scripting
|
||||
[Desc("Fly an attack against the target actor.")]
|
||||
public void Attack(Actor target)
|
||||
{
|
||||
self.QueueActivity(new FlyAttack(Target.FromActor(target)));
|
||||
Self.QueueActivity(new FlyAttack(Target.FromActor(target)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -24,13 +24,13 @@ namespace OpenRA.Mods.RA.Scripting
|
||||
: base(context, player) { }
|
||||
|
||||
[Desc("The player's name.")]
|
||||
public string Name { get { return player.PlayerName; } }
|
||||
public string Name { get { return Player.PlayerName; } }
|
||||
|
||||
[Desc("Returns an array of actors representing all ground attack units of this player.")]
|
||||
public Actor[] GetGroundAttackers()
|
||||
{
|
||||
return player.World.ActorsWithTrait<AttackBase>().Select(a => a.Actor)
|
||||
.Where(a => a.Owner == player && !a.IsDead && a.IsInWorld && a.HasTrait<Mobile>())
|
||||
return Player.World.ActorsWithTrait<AttackBase>().Select(a => a.Actor)
|
||||
.Where(a => a.Owner == Player && !a.IsDead && a.IsInWorld && a.HasTrait<Mobile>())
|
||||
.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,10 +37,10 @@ namespace OpenRA.Mods.RA.Scripting
|
||||
public void Produce(string actorType, string raceVariant = null)
|
||||
{
|
||||
ActorInfo actorInfo;
|
||||
if (!self.World.Map.Rules.Actors.TryGetValue(actorType, out actorInfo))
|
||||
if (!Self.World.Map.Rules.Actors.TryGetValue(actorType, out actorInfo))
|
||||
throw new LuaException("Unknown actor type '{0}'".F(actorType));
|
||||
|
||||
self.QueueActivity(new WaitFor(() => p.Produce(self, actorInfo, raceVariant)));
|
||||
Self.QueueActivity(new WaitFor(() => p.Produce(Self, actorInfo, raceVariant)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ namespace OpenRA.Mods.RA.Scripting
|
||||
public bool IsPrimaryBuilding
|
||||
{
|
||||
get { return pb.IsPrimary; }
|
||||
set { pb.SetPrimaryProducer(self, value); }
|
||||
set { pb.SetPrimaryProducer(Self, value); }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ namespace OpenRA.Mods.RA.Scripting
|
||||
|
||||
if (actionFunc != null)
|
||||
{
|
||||
var playerIndex = self.Owner.ClientIndex;
|
||||
var playerIndex = Self.Owner.ClientIndex;
|
||||
var squadSize = actorTypes.Length;
|
||||
var squad = new List<Actor>();
|
||||
var func = actionFunc.CopyReference() as LuaFunction;
|
||||
@@ -131,7 +131,7 @@ namespace OpenRA.Mods.RA.Scripting
|
||||
if (squad.Count >= squadSize)
|
||||
{
|
||||
using (func)
|
||||
using (var luaSquad = squad.Where(u => !u.IsDead).ToArray().ToLuaValue(context))
|
||||
using (var luaSquad = squad.Where(u => !u.IsDead).ToArray().ToLuaValue(Context))
|
||||
func.Call(luaSquad).Dispose();
|
||||
|
||||
triggers.OnProducedInternal -= productionHandler;
|
||||
@@ -142,7 +142,7 @@ namespace OpenRA.Mods.RA.Scripting
|
||||
}
|
||||
|
||||
foreach (var actorType in actorTypes)
|
||||
queue.ResolveOrder(self, Order.StartProduction(self, actorType, 1));
|
||||
queue.ResolveOrder(Self, Order.StartProduction(Self, actorType, 1));
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -160,7 +160,7 @@ namespace OpenRA.Mods.RA.Scripting
|
||||
|
||||
BuildableInfo GetBuildableInfo(string actorType)
|
||||
{
|
||||
var ri = self.World.Map.Rules.Actors[actorType];
|
||||
var ri = Self.World.Map.Rules.Actors[actorType];
|
||||
var bi = ri.Traits.GetOrDefault<BuildableInfo>();
|
||||
|
||||
if (bi == null)
|
||||
@@ -232,7 +232,7 @@ namespace OpenRA.Mods.RA.Scripting
|
||||
if (squad.Count >= squadSize)
|
||||
{
|
||||
using (func)
|
||||
using (var luaSquad = squad.Where(u => !u.IsDead).ToArray().ToLuaValue(context))
|
||||
using (var luaSquad = squad.Where(u => !u.IsDead).ToArray().ToLuaValue(Context))
|
||||
func.Call(luaSquad).Dispose();
|
||||
|
||||
foreach (var q in queueTypes)
|
||||
@@ -267,7 +267,7 @@ namespace OpenRA.Mods.RA.Scripting
|
||||
|
||||
BuildableInfo GetBuildableInfo(string actorType)
|
||||
{
|
||||
var ri = player.World.Map.Rules.Actors[actorType];
|
||||
var ri = Player.World.Map.Rules.Actors[actorType];
|
||||
var bi = ri.Traits.GetOrDefault<BuildableInfo>();
|
||||
|
||||
if (bi == null)
|
||||
|
||||
@@ -28,19 +28,19 @@ namespace OpenRA.Mods.RA.Scripting
|
||||
[Desc("Start repairs on this building. `repairer` can be an allied player.")]
|
||||
public void StartBuildingRepairs(Player repairer = null)
|
||||
{
|
||||
repairer = repairer ?? self.Owner;
|
||||
repairer = repairer ?? Self.Owner;
|
||||
|
||||
if (!rb.Repairers.Contains(repairer))
|
||||
rb.RepairBuilding(self, repairer);
|
||||
rb.RepairBuilding(Self, repairer);
|
||||
}
|
||||
|
||||
[Desc("Stop repairs on this building. `repairer` can be an allied player.")]
|
||||
public void StopBuildingRepairs(Player repairer = null)
|
||||
{
|
||||
repairer = repairer ?? self.Owner;
|
||||
repairer = repairer ?? Self.Owner;
|
||||
|
||||
if (rb.RepairActive && rb.Repairers.Contains(repairer))
|
||||
rb.RepairBuilding(self, repairer);
|
||||
rb.RepairBuilding(Self, repairer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,16 +31,16 @@ namespace OpenRA.Mods.RA.Scripting
|
||||
public bool HasPassengers { get { return cargo.Passengers.Any(); } }
|
||||
|
||||
[Desc("Teleport an existing actor inside this transport.")]
|
||||
public void LoadPassenger(Actor a) { cargo.Load(self, a); }
|
||||
public void LoadPassenger(Actor a) { cargo.Load(Self, a); }
|
||||
|
||||
[Desc("Remove the first actor from the transport. This actor is not added to the world.")]
|
||||
public Actor UnloadPassenger() { return cargo.Unload(self); }
|
||||
public Actor UnloadPassenger() { return cargo.Unload(Self); }
|
||||
|
||||
[ScriptActorPropertyActivity]
|
||||
[Desc("Command transport to unload passengers.")]
|
||||
public void UnloadPassengers()
|
||||
{
|
||||
self.QueueActivity(new UnloadCargo(self, true));
|
||||
Self.QueueActivity(new UnloadCargo(Self, true));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,9 +60,9 @@ namespace OpenRA.Mods.RA.Scripting
|
||||
public void Paradrop(CPos cell)
|
||||
{
|
||||
paradrop.SetLZ(cell, true);
|
||||
self.QueueActivity(new Fly(self, Target.FromCell(self.World, cell)));
|
||||
self.QueueActivity(new FlyOffMap());
|
||||
self.QueueActivity(new RemoveSelf());
|
||||
Self.QueueActivity(new Fly(Self, Target.FromCell(Self.World, cell)));
|
||||
Self.QueueActivity(new FlyOffMap());
|
||||
Self.QueueActivity(new RemoveSelf());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user