using System; namespace Artemis.Core { /// /// Represents a range between two single-precision floating point numbers /// public class FloatRange { private readonly Random _rand; /// /// Creates a new instance of the class /// /// The start value of the range /// The end value of the range public FloatRange(float start, float end) { Start = start; End = end; _rand = new Random(); } /// /// Gets or sets the start value of the range /// public float Start { get; set; } /// /// Gets or sets the end value of the range /// public float End { get; set; } /// /// Determines whether the given value is in this range /// /// The value to check /// /// Whether the value may be equal to or /// Defaults to /// /// public bool IsInRange(float value, bool inclusive = true) { if (inclusive) return value >= Start && value <= End; return value > Start && value < End; } /// /// Returns a pseudo-random value between and /// /// Whether the value may be equal to /// The pseudo-random value public float GetRandomValue(bool inclusive = true) { if (inclusive) return _rand.Next((int) (Start * 100), (int) (End * 100)) / 100f; return _rand.Next((int) (Start * 100) + 1, (int) (End * 100)) / 100f; } } }