Example #1
0
        public void RebuildProperties()
        {
            // Which properties are available?
            List <int> availableVarIDs = new List <int> ();

            foreach (InvVar invVar in KickStarter.inventoryManager.invVars)
            {
                if (!invVar.limitToCategories || KickStarter.inventoryManager.bins.Count == 0 || invVar.categoryIDs.Contains(binID))
                {
                    availableVarIDs.Add(invVar.id);
                }
            }

            // Create new properties / transfer existing values
            List <InvVar> newInvVars = new List <InvVar> ();

            foreach (InvVar invVar in KickStarter.inventoryManager.invVars)
            {
                if (availableVarIDs.Contains(invVar.id))
                {
                    InvVar newInvVar = new InvVar(invVar);
                    InvVar oldInvVar = GetProperty(invVar.id);
                    if (oldInvVar != null)
                    {
                        newInvVar.TransferValues(oldInvVar);
                    }
                    newInvVar.popUpID = invVar.popUpID;
                    newInvVars.Add(newInvVar);
                }
            }

            vars = newInvVars;
        }
Example #2
0
        private void RebuildProperties(InvItem item)
        {
            // Which properties are available?
            List <int> availableVarIDs = new List <int>();

            foreach (InvVar invVar in invVars)
            {
                if (!invVar.limitToCategories || bins.Count == 0 || invVar.categoryIDs.Contains(item.binID))
                {
                    availableVarIDs.Add(invVar.id);
                }
            }

            // Create new properties / transfer existing values
            List <InvVar> newInvVars = new List <InvVar>();

            foreach (InvVar invVar in invVars)
            {
                if (availableVarIDs.Contains(invVar.id))
                {
                    InvVar newInvVar = new InvVar(invVar);
                    InvVar oldInvVar = item.GetProperty(invVar.id);
                    if (oldInvVar != null)
                    {
                        newInvVar.TransferValues(oldInvVar);
                    }
                    newInvVars.Add(newInvVar);
                }
            }

            item.vars = newInvVars;
        }
Example #3
0
        /**
         * <summary>Gets the total amount of given integer or float inventory property, found in the current inventory<summary>
         * <param name = "propertyID">The ID of the integer or float inventory property</param>
         * <returns>The total amount of the property's value</returns>
         */
        public InvVar GetPropertyTotals(int propertyID)
        {
            InvVar originalVar = KickStarter.inventoryManager.GetProperty(propertyID);

            if (originalVar == null)
            {
                return(null);
            }

            InvVar totalVar = new InvVar(propertyID, originalVar.type);

            foreach (InvInstance invInstance in invInstances)
            {
                if (InvInstance.IsValid(invInstance))
                {
                    InvVar var = invInstance.GetProperty(propertyID);
                    if (var != null)
                    {
                        totalVar.TransferValues(var);
                    }
                }
            }
            return(totalVar);
        }
Example #4
0
        private void RebuildProperties(InvItem item)
        {
            // Which properties are available?
            List<int> availableVarIDs = new List<int>();
            foreach (InvVar invVar in invVars)
            {
                if (!invVar.limitToCategories || bins.Count == 0 || invVar.categoryIDs.Contains (item.binID))
                {
                    availableVarIDs.Add (invVar.id);
                }
            }

            // Create new properties / transfer existing values
            List<InvVar> newInvVars = new List<InvVar>();
            foreach (InvVar invVar in invVars)
            {
                if (availableVarIDs.Contains (invVar.id))
                {
                    InvVar newInvVar = new InvVar (invVar);
                    InvVar oldInvVar = item.GetProperty (invVar.id);
                    if (oldInvVar != null)
                    {
                        newInvVar.TransferValues (oldInvVar);
                    }
                    newInvVars.Add (newInvVar);
                }
            }

            item.vars = newInvVars;
        }