public bool IsTriggered(World world) { try { if (!_bindings.ContainsKey(world)) { BindTo(world); } } catch (Roslyn.Compilers.CompilationErrorException) { // suppress compilation errors and return false. _bindings[world] = new WorldBinding { CompilationFailed = true }; return false; } if (!_bindings[world].CompilationFailed) { return _bindings[world].Trigger.Execute(); } else { return false; } }
public void Run(World world) { //throw new NotImplementedException(); ScriptScope sc = _engine.CreateScope(); sc.SetVariable("r", world.GlobalObjectRoot); _engine.Execute(_effect); }
public bool IsTriggered(World world) { //throw new NotImplementedException(); ScriptScope sc = _engine.CreateScope(); sc.SetVariable("r", world.GlobalObjectRoot); return _engine.Execute<bool>(_trigger, sc); }
public void BindTo(World world) { WorldBinding b = new WorldBinding(); b.Session = Session.Create(world.GlobalObjectRoot); _engine.Execute("using System; using Demotic.Core; using Demotic.Core.ObjectSystem; using W3b.Sine;", b.Session); b.Trigger = _engine.CompileSubmission<bool>(_triggerSource, b.Session, isInteractive: true); b.Effect = _engine.CompileSubmission<bool>(_effectSource, b.Session, isInteractive: false); _bindings[world] = b; }
static void Main(string[] args) { World = new World(); //RoslynScript s = new RoslynScript("(Get(\"flag\") != null) && (((DNumber)Get(\"flag\")).Value >= BigFloatFactory.Instance.Create(10))", // "Console.WriteLine(\"hi!\"); Environment.Exit(0);"); IronPythonScript s = new IronPythonScript( "(r.flag != None) and (r.flag >= 10)", "print \"hi!\"; exit(0);" ); Server srv = new Server(); srv.Start(); World.RegisterScript(s); World.Start(); while (true) { Thread.Sleep(100); } }
public void Run(World world) { if (!_bindings.ContainsKey(world)) { BindTo(world); } _bindings[world].Effect.Execute(); }
public void Run(World world) { throw new NotImplementedException(); }
public bool IsTriggered(World world) { throw new NotImplementedException(); }
public void BindTo(World world) { //throw new NotImplementedException(); return; }