Esempio n. 1
0
        /// <summary>
        /// Get the standard ceiling height, or if one has not been generated, generate one based off MinimumStandardCeilingHeightName and MaximumStandardCeilingHeightName value
        /// </summary>
        /// <param name="provider">The provider to get and put value from/to</param>
        /// <param name="random">A random number generator (generating values from 0 to 1)</param>
        /// <param name="min">The minimum allowable value</param>
        /// <param name="max">The maximum allowable value</param>
        /// <returns></returns>
        public static float StandardCeilingHeight(this INamedDataCollection provider, Func <double> random, float?min = null, float?max = null)
        {
            Contract.Requires(provider != null);
            Contract.Requires(random != null);

            return(provider.DetermineHierarchicalValue(random, MathHelper.Lerp, StandardCeilingHeightName, MinimumStandardCeilingHeightName, MaximumStandardCeilingHeightName, min, max));
        }
Esempio n. 2
0
        /// <summary>
        /// Get the sidewalk width, or if one has not been generated, generate one based off MinimumSidewalkWidthName and MaximumSidewalkWidthName value
        /// </summary>
        /// <param name="provider">The provider to get and put value from/to</param>
        /// <param name="random">A random number generator (generating values from 0 to 1)</param>
        /// <param name="min">The minimum allowable value</param>
        /// <param name="max">The maximum allowable value</param>
        /// <returns></returns>
        public static float RoadSidewalkWidth(this INamedDataCollection provider, Func <double> random, float?min = null, float?max = null)
        {
            Contract.Requires(provider != null);
            Contract.Requires(random != null);

            return(provider.DetermineHierarchicalValue(random, MathHelper.Lerp, RoadSidewalkWidthName, MinimumSidewalkWidthName, MaximumSidewalkWidthName, min, max));
        }
Esempio n. 3
0
        public static string DefaultMaterial(this INamedDataCollection provider, Func <double> random, TypedName <string> name, params string[] possibilities)
        {
            Contract.Requires(provider != null);
            Contract.Requires(random != null);
            Contract.Requires(possibilities != null);

            //Select a random value from the possibilities
            var generated = possibilities.Length == 0 ? null : possibilities[random.RandomInteger(0, possibilities.Length - 1)];

            return(provider.DetermineHierarchicalValue(name, oldValue =>
            {
                //If no possibilities were provided, everything is valid!
                if (possibilities.Length == 0)
                {
                    return oldValue;
                }

                //Use the old value if it is one of the allowed possibilities
                if (((IList <string>)possibilities).Contains(oldValue))
                {
                    return oldValue;
                }

                //Otherwise generate a new value (from the range of allowed possibilities)
                return generated;
            }, () => generated));
        }
Esempio n. 4
0
        public static float ExternalWallThickness(this INamedDataCollection provider, Func <double> random, float?min = null, float?max = null)
        {
            Contract.Requires(provider != null);
            Contract.Requires(random != null);

            return(provider.DetermineHierarchicalValue(random, MathHelper.Lerp, ExternalWallThicknessName, MinimumExternalWallThicknessName, MaximumExternalWallThicknessName, min, max));
        }