public static void Modify(ItemPropertyModifier source, ref double targetValue) { if (!source.HasValue) { return; } switch (source._formula) { // mod & inverse case AggregateFormula.Modifier: case AggregateFormula.Inverse: { targetValue *= source.Value; break; } // add case AggregateFormula.Add: { targetValue += source.Value; break; } default: throw new ArgumentOutOfRangeException(); } }
public ItemPropertyModifier GetPropertyModifier(AggregateField field) { if (TryGetPropertyModifier(field, out ItemPropertyModifier m)) { return(m); } return(ItemPropertyModifier.Create(field)); }
public void Init() { _modifiers = Db.Query().CommandText("select * from aggregatevalues").Execute().ToLookup(r => r.GetValue <int>("definition"), r => { var field = r.GetValue <AggregateField>("field"); var value = r.GetValue <double>("value"); return(ItemPropertyModifier.Create(field, value)); }); }
static DefaultItemPropertyModifiers() { _defaultProperties = Database.CreateLookupCache <int, ItemPropertyModifier>("aggregatevalues", "definition", r => { var field = r.GetValue <AggregateField>("field"); var value = r.GetValue <double>("value"); return(ItemPropertyModifier.Create(field, value)); }); }
public static ItemPropertyModifier Modify(ItemPropertyModifier source, ItemPropertyModifier target) { if (!source.HasValue) { return(target); } var v = target.Value; Modify(source, ref v); return(new ItemPropertyModifier(target.Field, target._formula, v)); }
public static void Modify(ItemPropertyModifier source, ref ItemPropertyModifier targetModifier) { targetModifier = Modify(source, targetModifier); }
public void Modify(ref ItemPropertyModifier targetModifier) { Modify(this, ref targetModifier); }
public bool TryGetPropertyModifier(AggregateField field, out ItemPropertyModifier modifier) { return(_modifiers.TryGetValue(field, out modifier)); }
public static IPropertyModifierCollection Combine(this IPropertyModifierCollection source, IPropertyModifierCollection target) { var x = source.All.Select(s => ItemPropertyModifier.Modify(s, target.GetPropertyModifier(s.Field))); return(new PropertyModifierCollection(x)); }
public ItemPropertyModifier ToPropertyModifier() { return(ItemPropertyModifier.Create(Field, Value)); }