Make ScriptContext available in Actor- and PlayerProperty classes

Needed to return non-native types to Lua
This commit is contained in:
Oliver Brakmann
2014-08-17 15:47:21 +02:00
parent 1e7f04105d
commit 1c8a56d197
14 changed files with 44 additions and 31 deletions

View File

@@ -17,8 +17,8 @@ namespace OpenRA.Mods.RA.Scripting
[ScriptPropertyGroup("Support Powers")]
public class ChronsphereProperties : ScriptActorProperties, Requires<ChronoshiftPowerInfo>
{
public ChronsphereProperties(Actor self)
: base(self) { }
public ChronsphereProperties(ScriptContext context, Actor self)
: base(context, self) { }
[Desc("Chronoshift a group of actors. A duration of 0 will teleport the actors permanently.")]
public void Chronoshift(LuaTable unitLocationPairs, int duration = 0, bool killCargo = false)

View File

@@ -17,7 +17,8 @@ namespace OpenRA.Mods.RA.Scripting
[ScriptPropertyGroup("Combat")]
public class CombatProperties : ScriptActorProperties, Requires<AttackBaseInfo>, Requires<IMoveInfo>
{
public CombatProperties(Actor self) : base(self) { }
public CombatProperties(ScriptContext context, Actor self)
: base(context, self) { }
[ScriptActorPropertyActivity]
[Desc("Seek out and attack nearby targets.")]
@@ -35,4 +36,4 @@ namespace OpenRA.Mods.RA.Scripting
self.QueueActivity(new AttackMove.AttackMoveActivity(self, new Move.Move(cell, WRange.FromCells(closeEnough))));
}
}
}
}

View File

@@ -21,7 +21,8 @@ namespace OpenRA.Mods.RA.Scripting
readonly IFacing facing;
readonly AutoTarget autotarget;
public GeneralProperties(Actor self) : base(self)
public GeneralProperties(ScriptContext context, Actor self)
: base(context, self)
{
facing = self.TraitOrDefault<IFacing>();
autotarget = self.TraitOrDefault<AutoTarget>();
@@ -135,4 +136,4 @@ namespace OpenRA.Mods.RA.Scripting
return self.HasScriptProperty(name);
}
}
}
}

View File

@@ -17,8 +17,8 @@ namespace OpenRA.Mods.RA.Scripting
public class GuardProperties : ScriptActorProperties, Requires<GuardInfo>, Requires<IMoveInfo>
{
Guard guard;
public GuardProperties(Actor self)
: base(self)
public GuardProperties(ScriptContext context, Actor self)
: base(context, self)
{
guard = self.Trait<Guard>();
}

View File

@@ -17,8 +17,8 @@ namespace OpenRA.Mods.RA.Scripting
public class HealthProperties : ScriptActorProperties, Requires<HealthInfo>
{
Health health;
public HealthProperties(Actor self)
: base(self)
public HealthProperties(ScriptContext context, Actor self)
: base(context, self)
{
health = self.Trait<Health>();
}
@@ -41,8 +41,8 @@ namespace OpenRA.Mods.RA.Scripting
public class InvulnerableProperties : ScriptActorProperties, Requires<ScriptInvulnerableInfo>
{
ScriptInvulnerable invulnerable;
public InvulnerableProperties(Actor self)
: base(self)
public InvulnerableProperties(ScriptContext context, Actor self)
: base(context, self)
{
invulnerable = self.Trait<ScriptInvulnerable>();
}

View File

@@ -20,8 +20,8 @@ namespace OpenRA.Mods.RA.Scripting
{
readonly MissionObjectives mo;
public MissionObjectiveProperties(Player player)
: base(player)
public MissionObjectiveProperties(ScriptContext context, Player player)
: base(context, player)
{
mo = player.PlayerActor.Trait<MissionObjectives>();
}

View File

@@ -17,7 +17,8 @@ namespace OpenRA.Mods.RA.Scripting
[ScriptPropertyGroup("Movement")]
public class MobileProperties : ScriptActorProperties, Requires<MobileInfo>
{
public MobileProperties(Actor self) : base(self) { }
public MobileProperties(ScriptContext context, Actor self)
: base(context, self) { }
[ScriptActorPropertyActivity]
[Desc("Moves within the cell grid. closeEnough defines an optional range " +

View File

@@ -18,8 +18,8 @@ namespace OpenRA.Mods.RA.Scripting
{
readonly Player p;
public PlayerProperties(Player player)
: base(player)
public PlayerProperties(ScriptContext context, Player player)
: base(context, player)
{
p = player;
}

View File

@@ -20,8 +20,8 @@ namespace OpenRA.Mods.RA.Scripting
{
readonly Production p;
public ProductionProperties(Actor self)
: base(self)
public ProductionProperties(ScriptContext context, Actor self)
: base(context, self)
{
p = self.Trait<Production>();
}

View File

@@ -19,8 +19,8 @@ namespace OpenRA.Mods.RA.Scripting
{
readonly PlayerResources pr;
public ResourceProperties(Player player)
: base(player)
public ResourceProperties(ScriptContext context, Player player)
: base(context, player)
{
pr = player.PlayerActor.Trait<PlayerResources>();
}

View File

@@ -21,8 +21,8 @@ namespace OpenRA.Mods.RA.Scripting
{
readonly Cargo cargo;
public TransportProperties(Actor self)
: base(self)
public TransportProperties(ScriptContext context, Actor self)
: base(context, self)
{
cargo = self.Trait<Cargo>();
}
@@ -46,8 +46,8 @@ namespace OpenRA.Mods.RA.Scripting
{
readonly ParaDrop paradrop;
public ParadropPowers(Actor self)
: base(self)
public ParadropPowers(ScriptContext context, Actor self)
: base(context, self)
{
paradrop = self.Trait<ParaDrop>();
}