コード例 #1
0
ファイル: Inventory.cs プロジェクト: wqd1019dqw/Alex
        public Item this[int index]
        {
            get
            {
                if (index < 0 || index >= Slots.Length)
                {
                    throw new IndexOutOfRangeException();
                }

                return(Slots[index]);
            }
            set
            {
                if (index < 0 || index >= Slots.Length)
                {
                    throw new IndexOutOfRangeException();
                }
                if (value.Count == 0)
                {
                    value = new ItemAir()
                    {
                        Count = 0
                    };
                }
                Slots[index] = value;
                if ((index == 36 + _selectedSlot && !IsPeInventory) || (index == _selectedSlot && IsPeInventory))
                {
                    MainHand = value;
                }
                SlotChanged?.Invoke(this, new SlotChangedEventArgs(index, value));
            }
        }
コード例 #2
0
ファイル: InventoryBase.cs プロジェクト: lvyitian/Alex
        public void SetSlot(int index, Item value, bool isServerTransaction)
        {
            if (index < 0 || index >= Slots.Length)
            {
                throw new IndexOutOfRangeException();
            }
            if (value.Count == 0)
            {
                value = new ItemAir()
                {
                    Count = 0
                };
            }

            var oldValue = Slots[index];

            Slots[index] = value;

            /*if ((index == 36 + _selectedSlot && !IsPeInventory) || (index == _selectedSlot && IsPeInventory))
             * {
             *  MainHand = value;
             * }*/
            SlotChanged?.Invoke(this, new SlotChangedEventArgs(InventoryId, index, value, oldValue, isServerTransaction));
        }
コード例 #3
0
 protected virtual void OnSlotChanged(int n, ItemStack slot)
 {
     SlotChanged?.Invoke(this, n, slot);
 }
コード例 #4
0
ファイル: InventoryBase.cs プロジェクト: lvyitian1/Alex
 protected void InvokeSlotChanged(SlotChangedEventArgs eventArgs)
 {
     SlotChanged?.Invoke(this, eventArgs);
 }