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; }
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; }
/** * <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); }
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; }