Esempio n. 1
0
        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;
            }
        }
Esempio n. 2
0
        public void Run(World world)
        {
            //throw new NotImplementedException();

            ScriptScope sc = _engine.CreateScope();
            sc.SetVariable("r", world.GlobalObjectRoot);

            _engine.Execute(_effect);
        }
Esempio n. 3
0
        public bool IsTriggered(World world)
        {
            //throw new NotImplementedException();

            ScriptScope sc = _engine.CreateScope();
            sc.SetVariable("r", world.GlobalObjectRoot);

            return _engine.Execute<bool>(_trigger, sc);
        }
Esempio n. 4
0
        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;
        }
Esempio n. 5
0
        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);
            }
        }
Esempio n. 6
0
        public void Run(World world)
        {
            if (!_bindings.ContainsKey(world))
            {
                BindTo(world);
            }

            _bindings[world].Effect.Execute();
        }
Esempio n. 7
0
 public void Run(World world)
 {
     throw new NotImplementedException();
 }
Esempio n. 8
0
 public bool IsTriggered(World world)
 {
     throw new NotImplementedException();
 }
Esempio n. 9
0
 public void BindTo(World world)
 {
     //throw new NotImplementedException();
     return;
 }