本文整理汇总了C#中Eluant.LuaFunction.Call方法的典型用法代码示例。如果您正苦于以下问题:C# LuaFunction.Call方法的具体用法?C# LuaFunction.Call怎么用?C# LuaFunction.Call使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Eluant.LuaFunction
的用法示例。
在下文中一共展示了LuaFunction.Call方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetPlayers
public Player[] GetPlayers(LuaFunction filter)
{
return Context.World.Players
.Where(p =>
{
using (var f = filter.Call(p.ToLuaValue(Context)))
return f.First().ToBoolean();
}).ToArray();
}
示例2: Any
public bool Any(LuaValue[] collection, LuaFunction func)
{
foreach (var c in collection)
using (var ret = func.Call(c))
using (var result = ret.FirstOrDefault())
if (result != null && result.ToBoolean())
return true;
return false;
}
示例3: ActorsInCircle
public LuaTable ActorsInCircle(WPos location, WRange radius, LuaFunction filter)
{
var actors = context.World.FindActorsInCircle(location, radius)
.Select(a => a.ToLuaValue(context))
.Where(a =>
{
using (var f = filter.Call(a))
return f.First().ToBoolean();
});
return actors.ToLuaTable(context);
}
示例4: GetPlayers
public LuaTable GetPlayers(LuaFunction filter)
{
var players = context.World.Players
.Select(p => p.ToLuaValue(context))
.Where(a =>
{
using (var f = filter.Call(a))
return f.First().ToBoolean();
});
return players.ToLuaTable(context);
}
示例5: All
public bool All(LuaValue[] collection, LuaFunction func)
{
foreach (var c in collection)
{
using (var ret = func.Call(c))
{
var result = ret.FirstOrDefault();
if (result == null || !result.ToBoolean())
return false;
}
}
return true;
}
示例6: Any
public bool Any(LuaTable table, LuaFunction func)
{
foreach (var kv in table)
{
using (var ret = func.Call(kv.Value))
{
var result = ret.FirstOrDefault();
if (result != null && result.ToBoolean())
return true;
}
}
return false;
}
示例7: ActorsInBox
public Actor[] ActorsInBox(WPos topLeft, WPos bottomRight, LuaFunction filter = null)
{
var actors = Context.World.ActorMap.ActorsInBox(topLeft, bottomRight);
if (filter != null)
{
actors = actors.Where(a =>
{
using (var f = filter.Call(a.ToLuaValue(Context)))
return f.First().ToBoolean();
});
}
return actors.ToArray();
}
示例8: ActorsInCircle
public Actor[] ActorsInCircle(WPos location, WDist radius, LuaFunction filter = null)
{
var actors = Context.World.FindActorsInCircle(location, radius);
if (filter != null)
{
actors = actors.Where(a =>
{
using (var f = filter.Call(a.ToLuaValue(Context)))
return f.First().ToBoolean();
});
}
return actors.ToArray();
}
示例9: Do
public void Do(LuaValue[] collection, LuaFunction func)
{
foreach (var c in collection)
func.Call(c).Dispose();
}
示例10: Execute
void Execute(string cmd, string args, LuaFunction filter)
{
var handleOutput = new Action<string, CommandOutput>(
(text, command) =>
{
// Clean up new lines in the end of the string.
if (text.EndsWith(Environment.NewLine))
text = text.Replace(Environment.NewLine, string.Empty);
command.Raw.Add(text);
if (filter == null)
goto SkipFilter;
var result = filter.Call(text);
if (result.Count == 0)
return;
text = result[0].ToString();
SkipFilter:
command.Lines.Add(text);
Build.Output.WriteLine(text);
});
ExecuteProcess(cmd, args, handleOutput);
}
示例11: BuildStep
void BuildStep(string name, LuaFunction step)
{
Output.PushGroup("Build step '{0}'", name);
step.Call();
Output.PopGroup();
}
示例12: RunCode
private static void RunCode(LuaFunction function)
{
try
{
function.Call();
}
catch (Exception ex)
{
throw new BuildException("Error in Lua script: " + ex.ToString());
}
}
示例13: Do
public void Do(LuaTable table, LuaFunction func)
{
foreach (var kv in table)
func.Call(kv.Value).Dispose();
}
示例14: Where
public LuaTable Where(LuaValue[] collection, LuaFunction func)
{
var t = Context.CreateTable();
foreach (var c in collection)
using (var ret = func.Call(c))
using (var result = ret.FirstOrDefault())
if (result != null && result.ToBoolean())
t.Add(t.Count + 1, c);
return t;
}