|
| 1 | +using System.Diagnostics.CodeAnalysis; |
1 | 2 | using System.Reflection; |
2 | 3 |
|
3 | 4 | namespace Natsu.Mathematics.Transforms; |
4 | 5 |
|
5 | | -public class TransformSequence<T>(T target) : ITransformSequence<T> { |
| 6 | +public class TransformSequence<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)] T>(T target) : ITransformSequence<T> { |
6 | 7 | /// <summary> |
7 | 8 | /// Returns the end time of the sequence. |
8 | 9 | /// </summary> |
@@ -76,7 +77,6 @@ public void ResetTo(float toTime, int startIndex = 0, int endIndex = -1) { |
76 | 77 | } |
77 | 78 |
|
78 | 79 | transform.DoReset?.Invoke(); |
79 | | - Console.WriteLine("Resetting " + transform.Name); |
80 | 80 | } else if (transform.StartTime < toTime && transform.StartTime + transform.Duration >= toTime) { |
81 | 81 | float progress = (toTime - transform.StartTime) / transform.Duration; |
82 | 82 | transform.Reset(false); |
@@ -118,8 +118,8 @@ public TransformSequence<T> Append(ITransform transform, bool applyBaseTime = tr |
118 | 118 | /// <param name="name">The name of the transform for identification</param> |
119 | 119 | /// <param name="interpolation">The interpolation function to use</param> |
120 | 120 | /// <returns>The created sequence</returns> |
121 | | - public TransformSequence<T> Create<X>(string property, X to, float duration, Easing easing, string? name, Func<X, X, float, X> interpolation) { |
122 | | - PropertyInfo? propertyInfo = typeof(T).GetProperty(property); |
| 121 | + public TransformSequence<T> Create<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)] X>(string property, X to, float duration, Easing easing, string? name, Func<X, X, float, X> interpolation) { |
| 122 | + PropertyInfo? propertyInfo = typeof(T).GetProperty(property, BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic); |
123 | 123 | if (propertyInfo == null) throw new InvalidOperationException($"Property {property} does not exist in {typeof(T).Name}"); |
124 | 124 |
|
125 | 125 | X a = FutureData.TryGetValue(property, out object? value) ? (X)value : (X)propertyInfo.GetValue(Target)!; |
@@ -148,7 +148,7 @@ public TransformSequence<T> Create<X>(string property, X to, float duration, Eas |
148 | 148 | /// <param name="easing">The easing to apply to the time</param> |
149 | 149 | /// <param name="name">The name of the transform for identification</param> |
150 | 150 | /// <returns>The created sequence</returns> |
151 | | - public TransformSequence<T> Create<X>(string property, X to, float duration, Easing easing = Easing.Linear, string? name = null) => Create(property, to, duration, easing, name, EasingHelper.GetInterpolation<X>()); |
| 151 | + public TransformSequence<T> Create<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)] X>(string property, X to, float duration, Easing easing = Easing.Linear, string? name = null) => Create(property, to, duration, easing, name, EasingHelper.GetInterpolation<X>()); |
152 | 152 |
|
153 | 153 | /// <summary> |
154 | 154 | /// Moves the <see cref="BaseTime" /> of the sequence to the end of the longest transform. |
|
0 commit comments