using System; namespace GlitchyEngine.Editor; /// /// Specifies a minimum and maximum value that can be set using the editor for the field. /// /// /// This only affects the editor. The range does not affect scripts changing the value of the field. /// [AttributeUsage(AttributeTargets.Field)] public sealed class RangeAttribute : Attribute { /// /// The minimum value that can be assigned to the field using the editor. /// public double Min { get; private set; } /// /// The maximum value that can be assigned to the field using the editor. /// public double Max { get; private set; } /// /// The speed with which the value will be changed when dragging in the editor. /// public float Speed { get; private set; } /// /// If set to , the editor field will be a slider instead of a number field. /// public bool Slider { get; private set; } /// /// Initializes a new instance of the with a minimum, maximum value and optionally a speed. /// /// /// /// public RangeAttribute(double min, double max, float speed = 1.0f, bool slider = false) { if (max < min) throw new ArgumentOutOfRangeException(nameof(max), $"{nameof(max)} must be larger than {nameof(min)}."); if (speed <= 0) throw new ArgumentOutOfRangeException(nameof(speed), $"{nameof(speed)} must be larger than zero."); Min = min; Max = max; Speed = speed; Slider = slider; } } /// /// Specifies a minimum value that can be set using the editor for the field. /// /// /// If the field also has a , the takes precedence. ///

/// If the field also has a , and is larger than , then no range will be applied. ///

/// The value specified only affects the editor. It does not affect scripts changing the value of the field. ///
[AttributeUsage(AttributeTargets.Field)] public sealed class MinimumAttribute : Attribute { /// /// The minimum value that can be assigned to the field using the editor. /// public double Min { get; private set; } /// /// Initializes a new instance of the with a minimum value. /// /// public MinimumAttribute(double min) { Min = min; } } /// /// Specifies a maximum value that can be set using the editor for the field. /// /// /// If the field also has a , the takes precedence. ///

/// If the field also has a , and is larger than , then no range will be applied. ///

/// The value specified only affects the editor. It does not affect scripts changing the value of the field. ///
[AttributeUsage(AttributeTargets.Field)] public sealed class MaximumAttribute : Attribute { /// /// The maximum value that can be assigned to the field using the editor. /// public double Max { get; private set; } /// /// Initializes a new instance of the with a maximum value. /// /// public MaximumAttribute(double max) { Max = max; } }