Added CnC: gdi05b
This commit is contained in:
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user