public static float CalculatedWeight(Item item,
                                      Targets.Item target,
                                      bool simulation    = false,
                                      bool forceRealTime = false)
 {
     try
     {
         var minValue = simulation ? item.SimulationMinValue : item.MinValue;
         var maxValue = simulation ? item.SimulationMaxValue : item.MaxValue;
         if (item.Weight <= MinWeight || maxValue <= 0)
         {
             return(MinWeight);
         }
         var minWeight = minValue > 0 ? item.Weight / (maxValue / minValue) : MinWeight;
         var weight    = item.Inverted
             ? item.Weight - item.Weight * GetValue(item, target, forceRealTime) / maxValue + minWeight
             : item.Weight * GetValue(item, target, forceRealTime) / maxValue;
         return(float.IsNaN(weight) || float.IsInfinity(weight)
             ? MinWeight
             : Math.Min(MaxWeight, Math.Min(item.Weight, Math.Max(MinWeight, Math.Max(weight, minWeight)))));
     }
     catch
     {
         // Ignored
     }
     return(MinWeight);
 }
 public static float GetValue(Item item, Targets.Item target, bool forceRealTime = false)
 {
     try
     {
         if (ItemCache.MaxAge > 0 && !forceRealTime)
         {
             var cacheValue = ItemCache[item.UniqueName];
             if (cacheValue != null)
             {
                 return((float)cacheValue);
             }
         }
         var value = item.ValueFunction(target.Hero);
         value = Math.Max(0, value);
         ItemCache.AddOrUpdate(item.UniqueName, value);
         return(value);
     }
     catch
     {
         return(item.Inverted ? item.MaxValue : item.MinValue);
     }
 }
 public Item(Obj_AI_Hero sender, Targets.Item target)
 {
     Sender    = sender;
     Target    = target;
     Timestamp = Game.Time;
 }