Esempio n. 1
0
        public async Task EntityScript_should_work()
        {
            var entity = _world.CreateEntity();

            entity.Set(new TestComponent {
                Dice1 = Dice.Parse("2d+5")
            });

            var c = entity.Get <TestComponent>();

            //sanity
            Assert.Equal(0, c.RollResult);

            var changeScript = new EntityScript(@"
                            if(entity.Has<TestComponent>())
                            {
                                var c = entity.Get<TestComponent>();
                                c.RollResult = c.Dice1.Roll();
                            }
                        ", Assembly.GetExecutingAssembly());

            await changeScript.RunAsyncOn(entity);

            Assert.NotEqual(0, c.RollResult);
        }