Пример #1
0
        public static StatDefinition CreateDefinition(StatValueType type, float value)
        {
            var d = ScriptableObject.CreateInstance <StatDefinition>();

            d.Value.type = type;

            switch (type)
            {
            case StatValueType.Int:
                var vInt = (StatValueInt)d.Value.GetValue();
                vInt.value = Mathf.RoundToInt(value);
                break;

            case StatValueType.IntCurve:
                var vIntCurve = (StatValueIntCurve)d.Value.GetValue();
                vIntCurve.value = new AnimationCurve(new Keyframe(0, value));
                break;

            case StatValueType.Float:
                var vFloat = (StatValueFloat)d.Value.GetValue();
                vFloat.value = value;
                break;

            case StatValueType.FloatCurve:
                var vFloatCurve = (StatValueFloatCurve)d.Value.GetValue();
                vFloatCurve.value = new AnimationCurve(new Keyframe(0, value));
                break;

            default:
                throw new System.ArgumentOutOfRangeException("type", type, null);
            }

            return(d);
        }
        public SubconditionAffixControlViewModel(ConditionAffix condition, List <Affix> affixes, StatValueType statValueType, AffixType affixType, PoeCrafting.Entities.ItemBase itemBase)
        {
            _statValueType = statValueType;
            _affixes       = affixes;
            _affixType     = affixType;
            _itemBase      = itemBase;

            AffixName = condition.ModType;

            if (condition.Min1.HasValue)
            {
                FirstStatMin = condition.Min1.Value;
            }
            if (condition.Max1.HasValue)
            {
                FirstStatMax = condition.Max1.Value;
            }
            if (condition.Min2.HasValue)
            {
                SecondStatMin = condition.Min2.Value;
            }
            if (condition.Max2.HasValue)
            {
                SecondStatMax = condition.Max2.Value;
            }
            if (condition.Min3.HasValue)
            {
                ThirdStatMin = condition.Min3.Value;
            }
            if (condition.Max3.HasValue)
            {
                ThirdStatMax = condition.Max3.Value;
            }
        }
Пример #3
0
        public static StatValueTypeOverride ToOverride(this StatValueType type)
        {
            var i = (int)type;

            i += 1;

            return((StatValueTypeOverride)i);
        }
 private ItemProperty AffixToItemProperty(Affix affix, StatValueType valueType, List <int> values = null)
 {
     return(new ItemProperty()
     {
         Group = affix.Group,
         Values = GetTypedValue(affix, valueType, values),
         Type = (AffixType)Enum.Parse(typeof(AffixType), affix.GenerationType, true)
     });
 }
        public List <int> GetAffixValues(string mod, Equipment item, AffixType type, StatValueType valueType)
        {
            var conditionItem = new ConditionContainer()
            {
                ItemBase = item.ItemBase,
                Affixes  = item.Stats.Select(x => AffixToItemProperty(x.Affix, valueType, x.Values)).ToList()
            };

            return(GetAffixValue(mod, type, conditionItem));
        }
Пример #6
0
        public SubconditionAffixesControlViewModel(List <ConditionAffix> conditions, List <Affix> affixes, AffixType affixType, PoeCrafting.Entities.ItemBase itemBase, StatValueType valueType)
        {
            _affixType = affixType;
            Initialize(conditions, affixes, affixType, itemBase, valueType);
            _valueType = valueType;

            OnPropertyChanged(nameof(FirstAffix));
            OnPropertyChanged(nameof(SecondAffix));
            OnPropertyChanged(nameof(ThirdAffix));
        }
        public SubconditionAffixesControl(List<ConditionAffix> conditions, List<Affix> affixes, AffixType affixType, ItemBase itemBase, StatValueType valueType)
        {
            _affixType = affixType;
            Dispatcher.Invoke(() => Initialize(conditions, affixes, affixType, itemBase, valueType), DispatcherPriority.SystemIdle);
            _valueType = valueType;
            DataContext = this;
            InitializeComponent();

            OnPropertyChanged(nameof(FirstAffix));
            OnPropertyChanged(nameof(SecondAffix));
            OnPropertyChanged(nameof(ThirdAffix));
        }
        private List <int> GetTypedValue(Affix affix, StatValueType valueType, List <int> values = null)
        {
            switch (valueType)
            {
            case StatValueType.Flat:
                return(values);

            case StatValueType.Max:
                return(affix.MaxStats);

            case StatValueType.Tier:
                return(new List <int> {
                    affix.Tier
                });

            default:
                throw new NotImplementedException($"Stat type {valueType} has not yet been implemented");
            }
        }
Пример #9
0
        SerializedProperty GetPropertyByType(SerializedProperty prop, StatValueType type)
        {
            switch (type)
            {
            case StatValueType.Int:
                return(prop.FindPropertyRelative("value._valueInt.value"));

            case StatValueType.IntCurve:
                return(prop.FindPropertyRelative("value._valueIntCurve.value"));

            case StatValueType.Float:
                return(prop.FindPropertyRelative("value._valueFloat.value"));

            case StatValueType.FloatCurve:
                return(prop.FindPropertyRelative("value._valueFloatCurve.value"));

            default:
                throw new ArgumentOutOfRangeException("type", type, null);
            }
        }
        protected SerializedProperty GetPropertyValueType(StatValueType type, SerializedProperty parent)
        {
            switch (type)
            {
            case StatValueType.Int:
                return(GetPropertyInt(parent));

            case StatValueType.IntCurve:
                return(GetPropertyIntCurve(parent));

            case StatValueType.Float:
                return(GetPropertyFloat(parent));

            case StatValueType.FloatCurve:
                return(GetPropertyFloatCurve(parent));

            default:
                throw new ArgumentOutOfRangeException("type", type, null);
            }
        }
Пример #11
0
        public SubconditionAffixControl(ConditionAffix condition, List <Affix> affixes, StatValueType statValueType, AffixType affixType, ItemBase itemBase)
        {
            _statValueType = statValueType;
            _affixes       = affixes;
            _affixType     = affixType;
            _itemBase      = itemBase;

            AffixName = condition.ModType;

            if (condition.Min1.HasValue)
            {
                FirstStatMin = condition.Min1.Value;
            }
            if (condition.Max1.HasValue)
            {
                FirstStatMax = condition.Max1.Value;
            }
            if (condition.Min2.HasValue)
            {
                SecondStatMin = condition.Min2.Value;
            }
            if (condition.Max2.HasValue)
            {
                SecondStatMax = condition.Max2.Value;
            }
            if (condition.Min3.HasValue)
            {
                ThirdStatMin = condition.Min3.Value;
            }
            if (condition.Max3.HasValue)
            {
                ThirdStatMax = condition.Max3.Value;
            }

            DataContext = this;
            InitializeComponent();
        }
        private static CraftingSubcondition CreateCraftingSubcondition(SubconditionAggregateType aggregateType, StatValueType statType, int?min, int?max, params ConditionAffix[] affixes)
        {
            CraftingSubcondition subcondition = new CraftingSubcondition
            {
                AggregateType = aggregateType, AggregateMin = min, AggregateMax = max, ValueType = statType
            };

            subcondition.PrefixConditions.AddRange(affixes.ToList());
            return(subcondition);
        }
 internal StatValue(string name, object value, StatValueType type)
 {
     Name  = name;
     Value = value;
     Type  = type;
 }
 internal void SetStat(object value, StatValueType type)
 {
     Value = value;
     Type  = type;
 }
Пример #15
0
        private ConditionResolution ResolveCondition(ConditionAffix affix, Equipment item, AffixType type, StatValueType valueType)
        {
            AffixValueCalculator calculator = new AffixValueCalculator();
            var value = calculator.GetAffixValues(affix.ModType, item, type, valueType);

            return(new ConditionResolution()
            {
                IsPresent = value.Any(),
                IsMatch = value.Any() && IsValueWithinBounds(affix, value),
                Values = value
            });
        }
Пример #16
0
 /// <summary>
 /// When overridden in the derived class, allows for additional handling for when a mod stat
 /// changes. Use this overload instead of adding an event listener to the mod stat collection when possible.
 /// </summary>
 /// <param name="statType">The type of the stat that changed.</param>
 /// <param name="oldValue">The old value of the stat.</param>
 /// <param name="newValue">The new value of the stat.</param>
 protected virtual void OnModStatChanged(StatType statType, StatValueType oldValue, StatValueType newValue)
 {
 }
 public ConditionAffixControlModel(StatValueType statValueType, List <Affix> affixes, AffixType affixType)
 {
     ValueType = statValueType;
     _affixes  = affixes;
     AffixType = affixType;
 }
Пример #18
0
        /// <summary>
        /// When overridden in the derived class, allows for handling when a stat's value has changed.
        /// </summary>
        /// <param name="statType">The type of the stat that changed.</param>
        /// <param name="oldValue">The old value of the stat.</param>
        /// <param name="newValue">The new value of the stat.</param>
        protected override void OnStatChanged(StatType statType, StatValueType oldValue, StatValueType newValue)
        {
            base.OnStatChanged(statType, oldValue, newValue);

            _anyStatsChanged = true;
        }
Пример #19
0
 internal void SetStat(object value, StatValueType type)
 {
     this.Value = value;
     this.Type  = type;
 }
Пример #20
0
 internal StatValue(string name, object value, StatValueType type)
 {
     this.Name  = name;
     this.Value = value;
     this.Type  = type;
 }
Пример #21
0
        private void Initialize(List <ConditionAffix> conditions, List <Affix> affixes, AffixType affixType, PoeCrafting.Entities.ItemBase itemBase, StatValueType valueType)
        {
            var firstCondition  = conditions.Count >= 1 ? conditions[0] : new ConditionAffix();
            var secondCondition = conditions.Count >= 2 ? conditions[1] : new ConditionAffix();
            var thirdCondition  = conditions.Count >= 3 ? conditions[2] : new ConditionAffix();

            FirstAffixModel  = new SubconditionAffixControlViewModel(firstCondition, affixes, valueType, affixType, itemBase);
            SecondAffixModel = new SubconditionAffixControlViewModel(secondCondition, affixes, valueType, affixType, itemBase);
            ThirdAffixModel  = new SubconditionAffixControlViewModel(thirdCondition, affixes, valueType, affixType, itemBase);

            FirstAffix  = new SubconditionAffixControlView(FirstAffixModel);
            SecondAffix = new SubconditionAffixControlView(SecondAffixModel);
            ThirdAffix  = new SubconditionAffixControlView(ThirdAffixModel);
        }