Exemple #1
0
        /// <summary>
        /// Checks if the specified weapon set is equipped
        /// </summary>
        /// <param name="rIndex">Index of the weapon set to check</param>
        /// <returns>Boolean that determines if all the items are equipped</returns>
        public virtual bool IsWeaponSetEquipped(int rIndex = -1)
        {
            if (rIndex < 0)
            {
                rIndex = _ActiveWeaponSet;
            }
            if (rIndex < 0 || rIndex >= WeaponSets.Count)
            {
                return(false);
            }

            BasicInventorySet lSet = WeaponSets[rIndex];

            for (int i = 0; i < lSet.Items.Count; i++)
            {
                for (int j = 0; j < Slots.Count; j++)
                {
                    if (Slots[j].ID == lSet.Items[i].SlotID)
                    {
                        if (Slots[j].ItemID != lSet.Items[i].ItemID)
                        {
                            return(false);
                        }
                    }
                }
            }

            return(true);
        }
        /// <summary>
        /// Create a BasicInventorySetItem for the specified slot
        /// </summary>
        /// <param name="rBasicInventorySet"></param>
        /// <param name="rSlotID"></param>
        /// <param name="rItemID"></param>
        /// <param name="rInstantiate"></param>
        public static BasicInventorySetItem CreateSetItem(this BasicInventorySet rBasicInventorySet, string rSlotID, string rItemID,
                                                          bool rInstantiate = true)
        {
            if (string.IsNullOrEmpty(rSlotID))
            {
                return(null);
            }

            BasicInventorySetItem lWeaponSetItem = rBasicInventorySet.Items.FirstOrDefault(x => x.SlotID == rSlotID);

            if (lWeaponSetItem != null)
            {
                lWeaponSetItem.ItemID      = rItemID;
                lWeaponSetItem.Instantiate = rInstantiate;
                return(lWeaponSetItem);
            }

            lWeaponSetItem = new BasicInventorySetItem
            {
                ItemID      = rItemID,
                SlotID      = rSlotID,
                Instantiate = rInstantiate
            };
            rBasicInventorySet.Items.Add(lWeaponSetItem);

            return(lWeaponSetItem);
        }
        /// <summary>
        /// Create a new BasicInventorySet and initialize it by setting all slots to empty
        /// </summary>
        /// <param name="rBasicInventory"></param>
        /// <param name="rSetID"></param>
        /// <param name="rStance"></param>
        /// <param name="rDefaultForm"></param>
        /// <param name="rSetIndex"></param>
        /// <returns></returns>
        public static BasicInventorySet CreateInventorySet(this BasicInventory rBasicInventory, string rSetID, int rStance, int rDefaultForm, int rSetIndex)
        {
            BasicInventorySet lInventorySet = new BasicInventorySet
            {
                ID          = rSetID,
                Stance      = rStance,
                DefaultForm = rDefaultForm
            };

            foreach (BasicInventorySlot lSlot in rBasicInventory.Slots)
            {
                lInventorySet.CreateEmptySetItem(lSlot.ID);
            }

            rBasicInventory.WeaponSets.Insert(rSetIndex, lInventorySet);

            return(lInventorySet);
        }
        /// <summary>
        /// Create an empty BasicInventorySetItem for the specified slot
        /// </summary>
        /// <param name="rBasicInventorySet"></param>
        /// <param name="rSlotID"></param>
        public static BasicInventorySetItem CreateEmptySetItem(this BasicInventorySet rBasicInventorySet, string rSlotID)
        {
            if (string.IsNullOrEmpty(rSlotID))
            {
                return(null);
            }

            BasicInventorySetItem lWeaponSetItem = new BasicInventorySetItem
            {
                ItemID      = "",
                SlotID      = rSlotID,
                Instantiate = false
            };

            rBasicInventorySet.Items.Add(lWeaponSetItem);

            return(lWeaponSetItem);
        }