Exemplo n.º 1
0
 private string GetPropertyDisplayValue(int languageNumber, InvInstance invInstance)
 {
     if (InvInstance.IsValid(invInstance))
     {
         InvVar invVar = invInstance.GetProperty(itemPropertyID);
         if (invVar != null)
         {
             if (multiplyByItemCount)
             {
                 return(invVar.GetDisplayValue(languageNumber, invInstance.Count));
             }
             return(invVar.GetDisplayValue(languageNumber));
         }
     }
     return(string.Empty);
 }
Exemplo n.º 2
0
        public override float Run()
        {
            int runtimeInvID = -1;

            if (setVarAsPropertyMethod == SetVarAsPropertyMethod.SelectedItem)
            {
                if (InvInstance.IsValid(KickStarter.runtimeInventory.SelectedInstance))
                {
                    runtimeInvID = KickStarter.runtimeInventory.SelectedInstance.ItemID;
                }
            }
            else
            {
                runtimeInvID = invID;
            }

            InvVar invVar = null;

            if (runtimeInvID >= 0)
            {
                InvInstance invInstance = (useLiveValues)
                                                                                        ? KickStarter.runtimeInventory.GetInstance(runtimeInvID)
                                                                                        : new InvInstance(KickStarter.inventoryManager.GetItem(runtimeInvID));

                if (!InvInstance.IsValid(invInstance))
                {
                    if (useLiveValues)
                    {
                        LogWarning("Cannot find Inventory item with ID " + runtimeInvID + " in the Player's inventory");
                    }
                    else
                    {
                        LogWarning("Cannot find Inventory item with ID " + runtimeInvID);
                    }
                    return(0f);
                }

                invVar = invInstance.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);
        }