Merge pull request #6836 from pchote/polish-gdi0102

Closes #6757
Closes #6834
This commit is contained in:
Matthias Mailänder
2014-10-26 08:02:46 +01:00
11 changed files with 117 additions and 56 deletions

View File

@@ -39,11 +39,12 @@ namespace OpenRA.Scripting
var genericType = initType.GetInterfaces()
.First(x => x.IsGenericType && x.GetGenericTypeDefinition() == typeof(IActorInit<>));
var innerType = genericType.GetGenericArguments().First();
var valueType = innerType.IsEnum ? typeof(int) : innerType;
// Try and coerce the table value to the required type
object value;
if (!kv.Value.TryGetClrValue(innerType, out value))
throw new LuaException("Invalid data type for '{0}' (expected '{1}')".F(typeName, innerType.Name));
if (!kv.Value.TryGetClrValue(valueType, out value))
throw new LuaException("Invalid data type for '{0}' (expected '{1}')".F(typeName, valueType.Name));
// Construct the ActorInit. Phew!
var test = initType.GetConstructor(new[] { innerType }).Invoke(new[] { value });

View File

@@ -117,7 +117,7 @@ namespace OpenRA.Mods.RA.Scripting
{
foreach (var cargoType in cargoTypes)
{
var passenger = CreateActor(owner, cargoType, false);
var passenger = CreateActor(owner, cargoType, false, entryPath[0]);
passengers.Add(passenger);
cargo.Load(transport, passenger);
}

View File

@@ -17,8 +17,13 @@ namespace OpenRA.Mods.RA.Scripting
[ScriptPropertyGroup("Movement")]
public class MobileProperties : ScriptActorProperties, Requires<MobileInfo>
{
readonly Mobile mobile;
public MobileProperties(ScriptContext context, Actor self)
: base(context, self) { }
: base(context, self)
{
mobile = self.Trait<Mobile>();
}
[ScriptActorPropertyActivity]
[Desc("Moves within the cell grid. closeEnough defines an optional range " +
@@ -35,6 +40,13 @@ namespace OpenRA.Mods.RA.Scripting
self.QueueActivity(new Move.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));
}
[ScriptActorPropertyActivity]
[Desc("Leave the current position in a random direction.")]
public void Scatter()

View File

@@ -33,6 +33,9 @@ namespace OpenRA.Mods.RA.Scripting
[Desc("Teleport an existing actor inside this transport.")]
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); }
[ScriptActorPropertyActivity]
[Desc("Command transport to unload passengers.")]
public void UnloadPassengers()