예제 #1
0
        /// <summary>
        /// Attempts to flip the inventory slots.
        /// </summary>
        /// <param name="owningPlayer">The player owner of the invnetory slots.</param>
        /// <param name="invIds">The IDs of the player inventory.</param>
        /// <param name="slotIds">The IDs of the target inventory.</param>
        /// <param name="lastChanged">The times these ids were last changed.</param>
        public virtual bool TryFlipItemStack(IPlayer owningPlayer, string[] invIds, int[] slotIds, long[] lastChanged)
        {
            // 0 = source slot
            // 1 = target slot
            ItemSlot[] slots = GetSlotsIfExists(owningPlayer, invIds, slotIds);

            if (slots[0] == null || slots[1] == null)
            {
                return(false);
            }

            InventoryBase targetInv = (InventoryBase)owningPlayer.InventoryManager.GetInventory(invIds[1]);

            // 4. Try to move the item stack
            return(targetInv.TryFlipItems(slotIds[1], slots[0]) != null);
        }
예제 #2
0
        /// <summary>
        /// Attempts to get specified slots if the slots exists.
        /// </summary>
        /// <param name="player">The player owning the slots</param>
        /// <param name="invIds">The inventory IDs</param>
        /// <param name="slotIds">The slot ids</param>
        /// <returns>The slots obtained.</returns>
        public virtual ItemSlot[] GetSlotsIfExists(IPlayer player, string[] invIds, int[] slotIds)
        {
            ItemSlot[] slots = new ItemSlot[2];

            // 1. Both inventories must exist and be modifiable
            InventoryBase sourceInv = (InventoryBase)player.InventoryManager.GetInventory(invIds[0]);
            InventoryBase targetInv = (InventoryBase)player.InventoryManager.GetInventory(invIds[1]);

            if (sourceInv == null || targetInv == null)
            {
                return(slots);
            }

            if (!sourceInv.CanPlayerModify(player, player.Entity.Pos) || !targetInv.CanPlayerModify(player, player.Entity.Pos))
            {
                return(slots);
            }

            // 3. Source and Dest slot must exist
            slots[0] = sourceInv[slotIds[0]];
            slots[1] = targetInv[slotIds[1]];

            return(slots);
        }
예제 #3
0
 public ItemSlotBarrelInput(InventoryBase inventory) : base(inventory)
 {
 }
 public ItemSlotInput(InventoryBase inventory, int outputSlotId) : base(inventory)
 {
     this.outputSlotId = outputSlotId;
 }
예제 #5
0
 /// <summary>
 /// Create a new instance of an item slot
 /// </summary>
 /// <param name="inventory"></param>
 public ItemSlot(InventoryBase inventory)
 {
     this.inventory = inventory;
 }
예제 #6
0
 public ItemSlotCreative(InventoryBase inventory) : base(inventory)
 {
 }
예제 #7
0
 public ItemSlotUniversal(InventoryBase inventory) : base(inventory)
 {
 }
예제 #8
0
 public ItemSlotOutput(InventoryBase inventory) : base(inventory)
 {
 }
예제 #9
0
 public ItemSlotSurvival(InventoryBase inventory) : base(inventory)
 {
 }
예제 #10
0
 public ItemSlotCharacter(EnumCharacterDressType type, InventoryBase inventory) : base(inventory)
 {
     this.type = type;
 }
예제 #11
0
 public DummySlot(ItemStack stack, InventoryBase inv) : base(inv)
 {
     this.itemstack = stack;
 }
예제 #12
0
 public ItemSlotOffhand(InventoryBase inventory) : base(inventory)
 {
     this.BackgroundIcon = "offhand";
 }