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; }
private string GetPropertyDisplayValue(int languageNumber, InvItem invItem) { if (invItem != null) { InvVar invVar = invItem.GetProperty(itemPropertyID); if (invVar != null) { return(invVar.GetDisplayValue(languageNumber)); } } return(""); }
private string GetPropertyDisplayValue(int languageNumber, InvItem invItem) { if (invItem != null) { InvVar invVar = invItem.GetProperty(itemPropertyID, multiplyByItemCount); if (invVar != null) { return(invVar.GetDisplayValue(languageNumber)); } } return(string.Empty); }
override public float Run() { InvItem invItem = (setVarAsPropertyMethod == SetVarAsPropertyMethod.SelectedItem) ? KickStarter.runtimeInventory.LastSelectedItem : KickStarter.inventoryManager.GetItem(invID); if (invItem != null && runtimeVariable != null) { InvVar invVar = invItem.GetProperty(propertyID); if (invVar == null) { LogWarning("Cannot find property with ID " + propertyID + " on Inventory item " + invItem.GetLabel(0)); return(0f); } if (runtimeVariable.type == VariableType.String) { runtimeVariable.textVal = invVar.GetDisplayValue(Options.GetLanguage()); } else if (runtimeVariable.type == invVar.type) { if (invVar.type == VariableType.Float) { runtimeVariable.FloatValue = invVar.FloatValue; } else if (invVar.type == VariableType.Vector3) { runtimeVariable.Vector3Value = invVar.Vector3Value; } else { runtimeVariable.IntegerValue = invVar.IntegerValue; } } else { LogWarning("Cannot assign " + varLocation.ToString() + " Variable " + runtimeVariable.label + "'s value from '" + invVar.label + "' property because their types do not match."); } } return(0); }
override public float Run() { GVar myVar = (varLocation == VariableLocation.Global) ? GlobalVariables.GetVariable(variableID) : LocalVariables.GetVariable(variableID, localVariables); InvItem invItem = (setVarAsPropertyMethod == SetVarAsPropertyMethod.SelectedItem) ? KickStarter.runtimeInventory.LastSelectedItem : KickStarter.inventoryManager.GetItem(invID); if (invItem != null && myVar != null) { InvVar invVar = invItem.GetProperty(propertyID); if (myVar.type == VariableType.String) { myVar.textVal = invVar.GetDisplayValue(Options.GetLanguage()); } else if (myVar.type == invVar.type) { if (invVar.type == VariableType.Float) { myVar.FloatValue = invVar.FloatValue; } else if (invVar.type == VariableType.Vector3) { myVar.Vector3Value = invVar.Vector3Value; } else { myVar.IntegerValue = invVar.IntegerValue; } } else { ACDebug.LogWarning("Cannot assign " + varLocation.ToString() + " Variable " + myVar.label + "'s value from '" + invVar.label + "' property because their types do not match."); } } return(0); }
public override float Run() { int runtimeInvID = -1; if (setVarAsPropertyMethod == SetVarAsPropertyMethod.SelectedItem) { if (KickStarter.runtimeInventory.SelectedItem != null) { runtimeInvID = KickStarter.runtimeInventory.SelectedItem.id; } } else { runtimeInvID = invID; } InvVar invVar = null; if (runtimeInvID >= 0) { if (multiplyByItemCount) { invVar = KickStarter.runtimeInventory.GetPropertyTotals(propertyID, runtimeInvID); } else { InvItem invItem = KickStarter.inventoryManager.GetItem(runtimeInvID); if (invItem != null) { invVar = invItem.GetProperty(propertyID); } } } if (invVar == null) { LogWarning("Cannot find property with ID " + propertyID + " on Inventory item ID " + runtimeInvID); return(0f); } if (runtimeVariable.type == VariableType.String) { runtimeVariable.textVal = invVar.GetDisplayValue(Options.GetLanguage()); } else if (runtimeVariable.type == invVar.type) { if (invVar.type == VariableType.Float) { runtimeVariable.FloatValue = invVar.FloatValue; } else if (invVar.type == VariableType.Vector3) { runtimeVariable.Vector3Value = invVar.Vector3Value; } else { runtimeVariable.IntegerValue = invVar.IntegerValue; } } else { LogWarning("Cannot assign " + varLocation.ToString() + " Variable " + runtimeVariable.label + "'s value from '" + invVar.label + "' property because their types do not match."); } return(0); }
private string GetPropertyDisplayValue(int languageNumber, InvItem invItem) { if (invItem != null) { InvVar invVar = invItem.GetProperty (itemPropertyID); if (invVar != null) { return invVar.GetDisplayValue (languageNumber); } } return ""; }
public override float Run() { int runtimeInvID = -1; if (setVarAsPropertyMethod == SetVarAsPropertyMethod.SelectedItem) { if (KickStarter.runtimeInventory.SelectedItem != null) { runtimeInvID = KickStarter.runtimeInventory.SelectedItem.id; } } else { runtimeInvID = invID; } InvVar invVar = null; InvItem invItem = null; if (runtimeInvID >= 0) { if (useLiveValues) { invItem = KickStarter.runtimeInventory.GetItem(runtimeInvID); if (invItem == null) { LogWarning("Cannot find Inventory item with ID " + runtimeInvID + " in the Player's inventory"); return(0f); } } else { invItem = KickStarter.inventoryManager.GetItem(runtimeInvID); } if (invItem != null) { invVar = invItem.GetProperty(propertyID); } } if (invVar == null) { LogWarning("Cannot find property with ID " + propertyID + " on Inventory item ID " + runtimeInvID); return(0f); } if (runtimeVariable.type == VariableType.String) { runtimeVariable.TextValue = invVar.GetDisplayValue(Options.GetLanguage()); } else if (runtimeVariable.type == invVar.type) { int itemCount = (useLiveValues && multiplyByItemCount) ? KickStarter.runtimeInventory.GetCount(runtimeInvID) : 1; switch (invVar.type) { case VariableType.Float: runtimeVariable.FloatValue = invVar.FloatValue * (float)itemCount; break; case VariableType.Integer: runtimeVariable.IntegerValue = invVar.IntegerValue * itemCount; break; case VariableType.Vector3: runtimeVariable.Vector3Value = invVar.Vector3Value; break; default: runtimeVariable.IntegerValue = invVar.IntegerValue; break; } } else { LogWarning("Cannot assign " + varLocation.ToString() + " Variable " + runtimeVariable.label + "'s value from '" + invVar.label + "' property because their types do not match."); } return(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; }