12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- using System.Collections.Generic;
- namespace Animancer.FSM
- {
-
-
-
-
-
-
- public interface IPrioritizable : IState
- {
- float Priority { get; }
- }
-
- public partial class StateMachine<TState>
- {
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- public class StateSelector : SortedList<float, TState>
- {
- public StateSelector() : base(ReverseComparer<float>.Instance) { }
-
- public void Add<TPrioritizable>(TPrioritizable state)
- where TPrioritizable : TState, IPrioritizable
- => Add(state.Priority, state);
- }
- }
-
-
-
- public class ReverseComparer<T> : IComparer<T>
- {
-
- public static readonly ReverseComparer<T> Instance = new ReverseComparer<T>();
-
- private ReverseComparer() { }
-
- public int Compare(T x, T y) => Comparer<T>.Default.Compare(y, x);
- }
- }
|