Added CnC: gdi05b

This commit is contained in:
Moshe Schmidt
2015-04-13 22:31:51 +02:00
parent 70c9bca847
commit 7d6f367d84
8 changed files with 1004 additions and 0 deletions

View File

@@ -59,6 +59,12 @@ namespace OpenRA.Mods.Common.Scripting
return true;
}
[Desc("Returns the first n values from a collection.")]
public LuaValue[] Take(int n, LuaValue[] source)
{
return source.Take(n).ToArray();
}
[Desc("Skips over the first numElements members of a table and return the rest.")]
public LuaTable Skip(LuaTable table, int numElements)
{

View File

@@ -9,6 +9,7 @@
#endregion
using System;
using System.Collections.Generic;
using System.Linq;
using Eluant;
using OpenRA.Mods.Common.Traits;
@@ -32,5 +33,20 @@ namespace OpenRA.Mods.Common.Scripting
.Where(a => a.Owner == Player && !a.IsDead && a.IsInWorld && a.HasTrait<Mobile>())
.ToArray();
}
[Desc("Returns all living actors of the specified type of this player")]
public Actor[] GetActorsByType(string type)
{
var result = new List<Actor>();
ActorInfo ai;
if (!Context.World.Map.Rules.Actors.TryGetValue(type, out ai))
throw new LuaException("Unknown actor type '{0}'".F(type));
result.AddRange(Player.World.ActorMap.ActorsInWorld()
.Where(actor => actor.Owner == Player && !actor.IsDead && actor.IsInWorld && actor.Info.Name == ai.Name));
return result.ToArray();
}
}
}