Example #1
0
        public List <Item> GetInventoryItems(InventoryIndex index)
        {
            Inventory inventory = GameController.Game.IngameState.IngameUi.InventoryPanel[index];
            List <NormalInventoryItem> inventoryItems = inventory.VisibleInventoryItems;

            List <Item> itemList = new List <Item>();

            if (inventoryItems == null)
            {
                LogMessage("Player inventory->VisibleInventoryItems is null!", 5);
                return(itemList);
            }

            foreach (NormalInventoryItem inventoryItem in inventoryItems)
            {
                if (inventoryItem.Item == null)
                {
                    continue;
                }

                if (string.IsNullOrEmpty(inventoryItem.Item.Path))
                {
                    LogMessage($"Bugged item detected on X:{inventoryItem.InventPosX}, Y:{inventoryItem.InventPosY}, skipping.. Change location to fix this or restart the game (exit to character selection).", 5);
                    continue;
                }
                itemList.Add(new Item(inventoryItem));
            }
            return(itemList);
        }
 internal InventoryCell(
     int rowCoord,
     int colCoord)
 {
     IndexInInventory = new InventoryIndex(rowCoord, colCoord);
     ItemId           = "";
 }
Example #3
0
 public Inventory this[InventoryIndex k]
 {
     get
     {
         return(AllInventories[k]);
     }
 }
Example #4
0
        public void SwitchActiveWeapon(KeyCode keyPressed)
        {
            switch (keyPressed)
            {
            case KeyCode.Alpha1:
            {
                _currentActiveWeaponSlot = InventoryIndex.First;
                ChangeSelectedWeaponHUD?.Invoke(InventoryIndex.First);
                if (_weaponSlots[InventoryIndex.Second] != null)
                {
                    _weaponSlots[InventoryIndex.Second].WeaponStateProp = WeaponState.InInventory;
                }
                break;
            }

            case KeyCode.Alpha2:
            {
                _currentActiveWeaponSlot = InventoryIndex.Second;
                ChangeSelectedWeaponHUD?.Invoke(InventoryIndex.Second);
                if (_weaponSlots[InventoryIndex.First] != null)
                {
                    _weaponSlots[InventoryIndex.First].WeaponStateProp = WeaponState.InInventory;
                }
                break;
            }
            }
        }
Example #5
0
        public Element GetElementSlot(InventoryIndex inventoryIndex)
        {
            switch (inventoryIndex)
            {
            case InventoryIndex.None:
                throw new ArgumentOutOfRangeException(nameof(inventoryIndex));

            case InventoryIndex.Helm:
                return(EquippedItems.GetChildAtIndex(10));

            case InventoryIndex.Amulet:
                return(EquippedItems.GetChildAtIndex(11));

            case InventoryIndex.Chest:
                return(EquippedItems.GetChildAtIndex(12));

            case InventoryIndex.LWeapon:
                return(EquippedItems.GetChildAtIndex(14));

            case InventoryIndex.RWeapon:
                return(EquippedItems.GetChildAtIndex(13));

            case InventoryIndex.LWeaponSwap:
                return(EquippedItems.GetChildAtIndex(3));

            case InventoryIndex.RWeaponSwap:
                return(EquippedItems.GetChildAtIndex(2));

            case InventoryIndex.LRing:
                return(EquippedItems.GetChildAtIndex(17));

            case InventoryIndex.RRing:
                return(EquippedItems.GetChildAtIndex(18));

            case InventoryIndex.Gloves:
                return(EquippedItems.GetChildAtIndex(19));

            case InventoryIndex.Belt:
                return(EquippedItems.GetChildAtIndex(20));

            case InventoryIndex.Boots:
                return(EquippedItems.GetChildAtIndex(21));

            case InventoryIndex.PlayerInventory:
                return(EquippedItems.GetChildAtIndex(22));

            case InventoryIndex.Flask:
                return(EquippedItems.GetChildAtIndex(23));

            case InventoryIndex.Trinket:
                return(EquippedItems.GetChildAtIndex(24));

            case InventoryIndex.BloodCrucible:
                return(EquippedItems.GetChildAtIndex(1));

            default:
                throw new ArgumentOutOfRangeException(nameof(inventoryIndex));
            }
        }
Example #6
0
 public Inventory this[InventoryIndex inv]
 {
     get
     {
         int num = (int)inv;
         return base.ReadObject<Inventory>((this.ListStart + 8) + (num * 0x10));
     }
 }
Example #7
0
 public Inventory this[InventoryIndex inv]
 {
     get
     {
         int num = (int)inv;
         return(base.ReadObject <Inventory>((this.ListStart + 8) + (num * 0x10)));
     }
 }
Example #8
0
 public Inventory this[InventoryIndex inv]
 {
     get
     {
         var num = (int)inv;
         return(ReadObject <Inventory>(ListStart + 8 + num * 0x10));
     }
 }
Example #9
0
        private void Awake()
        {
            _weaponSlots = new Dictionary <InventoryIndex, WeaponBehaviourScript>
            {
                { InventoryIndex.First, null }, { InventoryIndex.Second, null }, { InventoryIndex.Throwable, null }
            };

            _currentActiveWeaponSlot = InventoryIndex.First;
        }
Example #10
0
 public Inventory this[InventoryIndex inv]
 {
     get
     {
         var num = (int)inv;
         if (num < 0 || num >= InventoryCount)
         {
             return(null);
         }
         return(ReadObjectAt <Inventory>(num * 8));
     }
 }
Example #11
0
 /// <summary>
 /// Adds a weapon to the inventory, at the given inventory slot. If there already is a weapon there, drops it.
 /// </summary>
 /// <param name="slot">The inventory slot to add the weapon to</param>
 /// <param name="weaponScript">The WeaponBehaviourScript attached to the weapon gameobject</param>
 /// <returns>A boolean indicating if the addition was successful</returns>
 private bool AddWeapon(InventoryIndex slot, WeaponBehaviourScript weaponScript)
 {
     if (_weaponSlots[slot] != null)
     {
         if (_weaponSlots[slot].WeaponData.WeaponName.Equals(weaponScript.WeaponData.WeaponName))
         {
             if (_weaponSlots[slot].WeaponData.WeaponName is WeaponName.Grenade)
             {
                 _weaponSlots[slot].CurrentMagazineAmmunition += weaponScript.CurrentMagazineAmmunition + weaponScript.CurrentTotalAmmunition;
             }
             else
             {
                 _weaponSlots[slot].CurrentTotalAmmunition += weaponScript.CurrentMagazineAmmunition + weaponScript.CurrentTotalAmmunition;
             }
             Destroy(weaponScript.gameObject);
             weaponScript.gameObject.transform.parent = gameObject.transform;
             return(true);
         }
         else
         {
             _weaponSlots[slot].WeaponStateProp  = WeaponState.OnGround;
             _weaponSlots[slot].transform.parent = null;
             weaponScript.WeaponStateProp        = WeaponState.InInventory;
             _weaponSlots[slot] = weaponScript;
             AddWeaponHUD?.Invoke(slot, weaponScript);
             weaponScript.gameObject.transform.parent = gameObject.transform;
             return(true);
         }
     }
     else
     {
         weaponScript.WeaponStateProp = WeaponState.InInventory;
         _weaponSlots[slot]           = weaponScript;
         AddWeaponHUD?.Invoke(slot, weaponScript);
         weaponScript.gameObject.transform.parent = gameObject.transform;
         return(true);
     }
 }
Example #12
0
 public Element GetElementSlot(InventoryIndex inventoryIndex)
 {
     return(inventoryIndex switch
     {
         InventoryIndex.None => throw new ArgumentOutOfRangeException(nameof(inventoryIndex)),
         InventoryIndex.Helm => EquippedItems.GetChildAtIndex(6),
         InventoryIndex.Amulet => EquippedItems.GetChildAtIndex(7),
         InventoryIndex.Chest => EquippedItems.GetChildAtIndex(8),
         InventoryIndex.LWeapon => EquippedItems.GetChildAtIndex(10),
         InventoryIndex.RWeapon => EquippedItems.GetChildAtIndex(9),
         InventoryIndex.LWeaponSwap => EquippedItems.GetChildAtIndex(12),
         InventoryIndex.RWeaponSwap => EquippedItems.GetChildAtIndex(11),
         InventoryIndex.LRing => EquippedItems.GetChildAtIndex(13),
         InventoryIndex.RRing => EquippedItems.GetChildAtIndex(14),
         InventoryIndex.Gloves => EquippedItems.GetChildAtIndex(15),
         InventoryIndex.Belt => EquippedItems.GetChildAtIndex(16),
         InventoryIndex.Boots => EquippedItems.GetChildAtIndex(17),
         InventoryIndex.PlayerInventory => EquippedItems.GetChildAtIndex(18),
         InventoryIndex.Flask => EquippedItems.GetChildAtIndex(19),
         InventoryIndex.Trinket => EquippedItems.GetChildAtIndex(20),
         InventoryIndex.BloodCrucible => EquippedItems.GetChildAtIndex(1),
         _ => throw new ArgumentOutOfRangeException(nameof(inventoryIndex))
     });
Example #13
0
 public void RemoveFromInventory(InventoryIndex weaponSlot)
 {
     _inventoryContainer[weaponSlot].SendMessage("RemoveWeaponFromInventorySlot", SendMessageOptions.DontRequireReceiver);
 }
Example #14
0
 public Inventory this[InventoryIndex k] => AllInventories[k];
Example #15
0
 public void AddToInventory(InventoryIndex slot, WeaponBehaviourScript weaponScript)
 {
     _inventoryContainer[slot].SendMessage("AddWeaponToInventorySlot", weaponScript, SendMessageOptions.DontRequireReceiver);
 }
Example #16
0
 //Outlines the weapon image in the HUD inventory that is currently used by the player.
 public void ChangeSelected(InventoryIndex newSelectedSlot)
 {
     _inventoryContainer[_selectedSlot].transform.Find("Selected").gameObject.SetActive(false);
     _selectedSlot = newSelectedSlot;
     _inventoryContainer[_selectedSlot].transform.Find("Selected").gameObject.SetActive(true);
 }
 /// <summary>
 /// Sorted by InventoryIndex
 /// </summary>
 public int CompareTo(ItemModel other) => InventoryIndex.CompareTo(other.InventoryIndex);