コード例 #1
0
        private float CalculateDriverMultiplier(RouteDriver Driver, IEnumerable <OptimizationTag> Multipliers)
        {
            float result = 1.0f;

            string[] driverTags = Driver.Tags.Split(new string[] { "|" }, StringSplitOptions.RemoveEmptyEntries);
            foreach (string tag in driverTags)
            {
                OptimizationTag optimizationTag = (from m in Multipliers where m.Name == tag && !m.IsExclusive select m).FirstOrDefault();
                if (optimizationTag != null)
                {
                    result += (optimizationTag.Multiplier - 1.0f);                     // multiplier is additive, not compounding
                }
            }

            return(result);
        }
コード例 #2
0
        private float CalculateDriverOrderMultiplier(RouteDriver Driver, RouteOrder Order, IEnumerable <OptimizationTag> Multipliers)
        {
            float result = 1.0f;

            string[] orderTags = Order.Tags.Split(new string[] { "|" }, StringSplitOptions.RemoveEmptyEntries);
            foreach (string tag in orderTags)
            {
                OptimizationTag optimizationTag = (from m in Multipliers where
                                                   (m.Name == tag) ||
                                                   (m.Name.Contains("*") && tag.StartsWith(m.Name.Substring(0, m.Name.IndexOf("*")))) &&                 // handle wildcards
                                                   m.IsExclusive
                                                   select m)
                                                  .FirstOrDefault();

                if (optimizationTag != null && !Driver.Tags.Contains(tag))
                {
                    // If optimization tag is not found for the driver, apply multiplier
                    result += (optimizationTag.Multiplier - 1.0f);                     // multiplier is additive, not compounding
                }
            }

            return(result);
        }