예제 #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;
            }
        }
예제 #2
0
        public void Run(World world)
        {
            //throw new NotImplementedException();

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

            _engine.Execute(_effect);
        }
예제 #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);
        }
예제 #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;
        }
예제 #5
0
파일: Program.cs 프로젝트: vogon/Demotic
        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);
            }
        }
예제 #6
0
        public void Run(World world)
        {
            if (!_bindings.ContainsKey(world))
            {
                BindTo(world);
            }

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