Example #1
0
        public InventoryTests()
        {
            InitScript.Init();

            {
                entityFactory = new EntityFactory();

                // AddComponents
                var transform    = Transform.AddTo(entityFactory, Layers.REAL, TransformFlags.Default);
                var stats        = Stats.AddTo(entityFactory, Registry.Global.Stats._map);
                var acting       = Acting.AddTo(entityFactory, null, Algos.SimpleAlgo, Order.Player);
                var moving       = Moving.AddTo(entityFactory);
                var displaceable = Displaceable.AddTo(entityFactory, Layers.BLOCK);
                var inventory    = Inventory.AddTo(entityFactory);
                var ticking      = Ticking.AddTo(entityFactory);

                // InitComponents
                acting.DefaultPreset(entityFactory);
                moving.DefaultPreset();
                displaceable.DefaultPreset();
                ticking.DefaultPreset();

                // Retouch
                Equip.OnDisplaceHandlerWrapper.HookTo(entityFactory);

                Inventory.AddInitTo(entityFactory);
            }

            {
                itemFactory = new EntityFactory();
                var transform = Transform.AddTo(itemFactory, Layers.ITEM, 0);
            }
        }
Example #2
0
        public static void AddComponents(EntityFactory factory)
        {
            // Apply these one after the other.
            // This will only initialize the inject variables of the behavior / component.
            // So, apply will be autogenerated for the different behaviors based on their injects.
            // Or do it even smarter?
            // So, since I'd like to make components structs in the future and store them somewhere
            // central (optionally), these can actually reference a global storage for them.

            // So this just adds the behavior
            Acting.AddTo(factory, null, Algos.SimpleAlgo, Order.Player);
            Moving.AddTo(factory);
            Digging.AddTo(factory);
            Pushable.AddTo(factory);
            Attacking.AddTo(factory, Attacking.GetTargetProviderFromInventory, Layers.REAL, Faction.Enemy | Faction.Environment);
            Attackable.AddTo(factory, Attackness.ALWAYS);
            Damageable.AddTo(factory, new Health(5));
            Displaceable.AddTo(factory, Layers.BLOCK);
            Ticking.AddTo(factory);

            FactionComponent.AddTo(factory, Faction.Player);
            Transform.AddTo(factory, Layers.REAL, TransformFlags.Default);
            Inventory.AddTo(factory);
            Inventory.AddInitTo(factory);

            // TODO: pass this an action
            Controllable.AddTo(factory,
                               // The default action is the AttackDigMove action.
                               Action.Compose(Attacking.Action, Digging.Action, Moving.Action));

            // TODO: rename the namespaces
            Stats.AddTo(factory, Registry.Global.Stats._map);
        }
Example #3
0
        public Bouncing_Test()
        {
            InitScript.Init();

            entityFactory = new EntityFactory();
            Transform.AddTo(entityFactory, Layers.REAL, TransformFlags.Default);
            Stats.AddTo(entityFactory, Registry.Global.Stats._map);
            Displaceable.AddTo(entityFactory, Layers.BLOCK).DefaultPreset();
            Pushable.AddTo(entityFactory).DefaultPreset();
        }
Example #4
0
        public MovingTests()
        {
            InitScript.Init();

            entityFactory = new EntityFactory();
            Transform.AddTo(entityFactory, Layers.REAL, 0);
            Stats.AddTo(entityFactory, Registry.Global.Stats._map);
            Displaceable.AddTo(entityFactory, Layers.BLOCK).DefaultPreset();
            Moving.AddTo(entityFactory).DefaultPreset();
        }
Example #5
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);
 }
Example #6
0
        public Slide_Tests()
        {
            InitScript.Init();
            entityFactory = new EntityFactory();
            Transform.AddTo(entityFactory, Layers.REAL, TransformFlags.Default);
            Stats.AddTo(entityFactory, Registry.Global.Stats._map);

            Ticking.AddTo(entityFactory).DefaultPreset();
            Displaceable.AddTo(entityFactory, Layers.BLOCK).DefaultPreset();
            Moving.AddTo(entityFactory).DefaultPreset();
            Pushable.AddTo(entityFactory).DefaultPreset();
            Acting.AddTo(entityFactory, null, Algos.SimpleAlgo, Order.Entity).DefaultPreset(entityFactory);
        }
Example #7
0
 public static void AddComponents(Entity subject)
 {
     Stats.AddTo(subject, Registry.Global.Stats._map);
     Transform.AddTo(subject, Layers.PROJECTILE, 0);
     FactionComponent.AddTo(subject, Faction.Environment);
     Displaceable.AddTo(subject, 0);
     ProjectileComponent.AddTo(subject, Layers.REAL | Layers.WALL | Layers.PROJECTILE);
     Attackable.AddTo(subject, Attackness.CAN_BE_ATTACKED);
     Damageable.AddTo(subject, new Health(1));
     Ticking.AddTo(subject);
     Acting.AddTo(
         subject,
         entity => ProjectileComponent.Action.Compile(entity.GetTransform().orientation),
         Algos.SimpleAlgo,
         Order.Projectile);
 }
Example #8
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);
        }
Example #9
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);
        }