Beispiel #1
0
        // For now, do this for the sake of tests and debugging
        // The world currently does not really need an id
        public World(int width, int height)
        {
            Grid   = new GridManager(width, height);
            State  = new WorldStateManager();
            Chains = new MoreChains(Registry.Global.GlobalChains._map);

            // Preload the chains
            Chains.GetLazy(SpawnEntityIndex);
            Chains.GetLazy(StartLoopIndex);
            Chains.GetLazy(EndLoopIndex);
        }
Beispiel #2
0
 public static void AddComponents(Entity subject)
 {
     FactionComponent.AddTo(subject, Faction.Environment);
     Displaceable.AddTo(subject, Layers.BLOCK);
     Attackable.AddTo(subject, Attackness.ALWAYS);
     // TODO: Be able to manipulate stats in a simple way.
     Stats.AddTo(subject, Registry.Global.Stats._map);
     Pushable.AddTo(subject);
     Damageable.AddTo(subject, new Health(1));
     Transform.AddTo(subject, Layers.REAL, TransformFlags.Default);
     Ticking.AddTo(subject);
     MoreChains.AddTo(subject, Registry.Global.MoreChains._map);
 }
Beispiel #3
0
        public void EntityDieWorks()
        {
            var factory = new EntityFactory();

            MoreChains.AddTo(factory, Registry.Global.MoreChains._map);
            Transform.AddTo(factory, 0, 0);

            var entity  = World.Global.SpawnEntity(factory, IntVector2.Zero);
            int counter = 0;
            var handler = new Handler <Entity>(10, ctx => counter++);

            Entity.DeathPath.Get(entity).Add(handler);
            Assert.AreEqual(0, counter);
            entity.Die();
            Assert.AreEqual(1, counter);
        }
Beispiel #4
0
        public static void AddComponents(Entity subject, System.Action <Acting.Context> Algorithm, params Step[] sequenceSteps)
        {
            Stats.AddTo(subject, Registry.Global.Stats._map);
            Transform.AddTo(subject, Layers.REAL, TransformFlags.Default);
            FactionComponent.AddTo(subject, Faction.Enemy);

            Acting.AddTo(subject, Sequential.CalculateAction, Algorithm, Order.Entity);
            Moving.AddTo(subject);
            Ticking.AddTo(subject);
            Pushable.AddTo(subject);
            Attacking.AddTo(subject, entity => BufferedAttackTargetProvider.Simple, Layers.REAL, Faction.Player);
            Sequential.AddTo(subject, new Sequence(sequenceSteps));
            Attackable.AddTo(subject, Attackness.ALWAYS);
            Damageable.AddTo(subject, new Health(1));
            Displaceable.AddTo(subject, Layers.BLOCK);
            MoreChains.AddTo(subject, Registry.Global.MoreChains._map);
        }
Beispiel #5
0
        public Bind_Tests()
        {
            InitScript.Init();

            entityFactory = new EntityFactory();
            Transform.AddTo(entityFactory, Layers.REAL, TransformFlags.Default);
            Stats.AddTo(entityFactory, Registry.Global.Stats._map);
            Attackable.AddTo(entityFactory, Attackness.ALWAYS);
            Damageable.AddTo(entityFactory, new Health(1)).DefaultPreset();
            Displaceable.AddTo(entityFactory, Layers.WALL | Layers.REAL).DefaultPreset();
            Moving.AddTo(entityFactory).DefaultPreset();
            // Cannot be bound unless it has MoreChains
            MoreChains.AddTo(entityFactory, Registry.Global.MoreChains._map);


            bindingFactory = new EntityFactory();
            Transform.AddTo(bindingFactory, Layers.REAL, TransformFlags.Default);
            Stats.AddTo(bindingFactory, Registry.Global.Stats._map);
            Binding.AddTo(bindingFactory, Layers.REAL, BoundEntityModifierDefault.Hookable).DefaultPreset();
            Damageable.AddTo(bindingFactory, new Health(1)).DefaultPreset();
            Attackable.AddTo(bindingFactory, Attackness.ALWAYS);
            // The death chain is also required
            MoreChains.AddTo(bindingFactory, Registry.Global.MoreChains._map);
        }