using RhythmBase.Events; using System.Reflection; namespace RhythmBase.Components.Easing { /// /// Represents an easing property with a float value. /// public class EasePropertyFloat : IEaseProperty { private EaseValue _value; /// public float GetValue(RDBeat beat) => _value.GetValue(beat.BeatOnly); /// public static bool CanConvert(object data) => data is float; /// public static EaseNode?[] Convert(IEaseEvent data, PropertyInfo property) { RDExpression? value = (RDExpression?)property.GetValue(data); return [ value is RDExpression v? new EaseNode(v.Value) { Duration = data.Duration, Time = ((BaseEvent)data).Beat.BeatOnly, Type = data.Ease } : null, ]; } /// public static IEaseProperty CreateEaseProperty(float originalValue, IEaseEvent[] data, PropertyInfo property) { EaseNode?[][] nodes = [.. data.Select(d => Convert(d, property))]; return new EasePropertyFloat() { _value = new(originalValue, [.. nodes.Select(i => i[0]).Where(i => i is not null).Cast()]) }; } } }