Exemplo n.º 1
0
 public static void AddComponents(Entity subject)
 {
     ItemBase.AddComponents(subject);
     Equippable.AddTo(subject, null);
     SlotComponent.AddTo(subject, Slot.Id);
     BowComponent.AddTo(subject);
     ItemActivation.AddTo(subject, GetChargeAction);
 }
Exemplo n.º 2
0
        public static void AddComponents(Entity subject)
        {
            ItemBase.AddComponents(subject);

            // Item stuff
            Equippable.AddTo(subject, null);
            Countable.AddTo(subject);
        }
Exemplo n.º 3
0
        public static void AddComponents(Entity subject, IntVector2 relativeDirection, int pierceIncrease)
        {
            ItemBase.AddComponents(subject);

            // Item stuff
            Equippable.AddTo(subject, ShieldComponent.Hookable);
            SlotComponent.AddTo(subject, Slot.Id);
        }
Exemplo n.º 4
0
        public static void AddComponents(Entity subject)
        {
            ItemBase.AddComponents(subject);

            // Item stuff
            Equippable.AddTo(subject, null);
            SlotComponent.AddTo(subject, Slot.Id);
            ItemActivation.AddTo(subject, GetAction);
        }
Exemplo n.º 5
0
        public void EquipSimple()
        {
            // The id of an unregistered factory is 0:0
            var item = World.Global.SpawnEntity(itemFactory, IntVector2.Zero);

            Equippable.AddTo(item, null);

            var entity    = World.Global.SpawnEntity(entityFactory, new IntVector2(1, 0));
            var inventory = entity.GetInventory();

            Assert.Zero(inventory._generalStorage.Count);
            Assert.Zero(inventory._excess.Count);
            Assert.Zero(inventory._slots.Count);
            Assert.False(inventory.ContainsItem(item.typeId));

            // Move onto the item
            var moveAction = Moving.Action.Compile(new IntVector2(-1, 0));

            entity.GetActing().ActivateWith(moveAction);
            Assert.AreEqual(new IntVector2(0, 0), entity.GetTransform().position);
            Assert.True(inventory.ContainsItem(item.typeId));

            inventory.Remove(item.typeId);
            Assert.False(inventory.ContainsItem(item.typeId));

            // Reset acting flags (so that we can act again)
            // acting._flags = 0;

            // Move the entity back
            entity.GetTransform().ResetPositionInGrid(new IntVector2(1, 0));

            // Spawn two items this time
            // Since two of the same items without a slot is not allowed, assign them a slot
            var slot = new Slot(false); slot.Id = new Identifier(3, 1);

            var item1 = World.Global.SpawnEntity(itemFactory, IntVector2.Zero);

            Equippable.AddTo(item1, null);
            SlotComponent.AddTo(item1, slot.Id);

            var item2 = World.Global.SpawnEntity(itemFactory, IntVector2.Zero);

            Equippable.AddTo(item2, null);
            SlotComponent.AddTo(item2, slot.Id);

            // item 1 gets picked up, then immediately replaced by item 2.
            // item 1 is dropped back as excess.
            entity.GetActing().ActivateWith(moveAction);
            Assert.True(inventory.ContainsItem(item2.typeId));
            Assert.AreSame(inventory.GetItem(item2.typeId), item2);
            Assert.AreSame(item1.GetTransform().GetAllFromLayer(Layers.ITEM).Single().entity, item1);
            Assert.AreSame(inventory.GetItemFromSlot(slot.Id), item2);
        }