public InventoryCharacterStat(InventoryPlayer player, InventoryItemProperty property)
     : this(player, property.name, property.valueStringFormat, property.baseValue, property.maxValue, property.showInUI)
 { }
        public static void SetItemProperties(InventoryPlayer player, InventoryItemProperty[] properties, SetItemPropertiesAction action)
        {
            float multiplier = 1.0f;
            switch (action)
            {
                case SetItemPropertiesAction.Use:
                    multiplier = 1.0f;
                    break;
                case SetItemPropertiesAction.UnUse:
                    multiplier = -1f;
                    break;
                default:
                    Debug.LogWarning("Action " + action + " not found (Going with default use)");
                    break;
            }

            // Use the item's properties.
            if (player != null)
            {
                foreach (var property in properties)
                {
                    var stat = player.characterCollection.GetStat(property.category, property.name);
                    if (stat != null)
                    {
                        switch (property.actionEffect)
                        {
                            case InventoryItemProperty.ActionEffect.Add:

                                if (property.isFactor)
                                {
                                    //if (property.increaseMax)
                                    //    stat.ChangeFactorMax((property.floatValue - 1.0f) * multiplier, true);
                                    //else
                                        stat.ChangeFactorMax((property.floatValue - 1.0f) * multiplier, true);
                                }
                                else
                                {
                                    //if(property.increaseMax)
                                    //    stat.ChangeMaxValueRaw(property.floatValue * multiplier, true);
                                    //else
                                        stat.ChangeMaxValueRaw(property.floatValue * multiplier, true);
                                }

                                break;
                            case InventoryItemProperty.ActionEffect.Restore:

                                if (property.isFactor)
                                    stat.ChangeCurrentValueRaw((stat.currentValue * (property.floatValue - 1.0f)) * multiplier);
                                else
                                    stat.ChangeCurrentValueRaw(property.floatValue * multiplier);

                                break;
                            default:
                                Debug.LogWarning("Action effect" + property.actionEffect + " not found.");
                                break;
                        }

                        //player.characterCollection.NotifyStatChanged(stat); // Done by the stat itself.
                    }
                    else
                    {
                        Debug.LogWarning("Stat based on property: " + property.name + " not found on player.");
                    }
                }
            }
        }
        private bool VerifyFilter(InventoryItemProperty[] properties, InventoryItemProperty property, FilterType filterType)
        {
            switch (filterType)
            {
                case FilterType.Equal:
                    return properties.Any(o => o.ID == property.ID);
                case FilterType.NotEqual:
                    return properties.All(o => o.ID != property.ID);
                case FilterType.LessThan:
                    var prop = properties.FirstOrDefault(o => o.ID == property.ID);
                    if (prop == null)
                        return true; // None is also considered less than... Use Equal instead.

                    return prop.floatValue < floatValue;
                case FilterType.GreatherThan:
                    var prop2 = properties.FirstOrDefault(o => o.ID == property.ID);
                    if (prop2 == null)
                        return false;

                    return prop2.floatValue > floatValue;
                default:

                    break;
            }

            return false;
        }