63 lines
2.0 KiB
C#
63 lines
2.0 KiB
C#
![]() |
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using System.Collections.Immutable;
|
||
|
using System.Linq;
|
||
|
using Animancer;
|
||
|
using AYellowpaper.SerializedCollections;
|
||
|
using BITKit;
|
||
|
using Unity.Mathematics;
|
||
|
using UnityEngine;
|
||
|
|
||
|
namespace Project.B.Animation
|
||
|
{
|
||
|
public class ScriptableHumanoidTransitionAnimationFactory : ScriptableObject,IHumanoidTransitionAnimationFactory
|
||
|
{
|
||
|
[SerializeReference, SubclassSelector] private IReference[] tags;
|
||
|
|
||
|
[SerializeField] public SerializedDictionary<float2, AnimationClip> idleToWalk;
|
||
|
[SerializeField] public SerializedDictionary<float2, AnimationClip> walkToIdle;
|
||
|
[SerializeField] public SerializedDictionary<float2, AnimationClip> idleTurn;
|
||
|
|
||
|
[SerializeField] private AnimationClip runToIdle;
|
||
|
|
||
|
public IWrapper<float2> CreateIdleToWalk()
|
||
|
{
|
||
|
if (idleToWalk.Count is 0) return null;
|
||
|
var state = new DirectionalMixerState();
|
||
|
foreach (var (parameter,clip) in idleToWalk)
|
||
|
{
|
||
|
state.Add(clip, parameter);
|
||
|
}
|
||
|
return new MixerStateWrapperFloat2(state);
|
||
|
}
|
||
|
|
||
|
public IWrapper<float2> CreateWalkToIdle()
|
||
|
{
|
||
|
if (walkToIdle.Count is 0) return null;
|
||
|
var state = new DirectionalMixerState();
|
||
|
foreach (var (parameter,clip) in walkToIdle)
|
||
|
{
|
||
|
state.Add(clip, parameter);
|
||
|
}
|
||
|
return new MixerStateWrapperFloat2(state);
|
||
|
}
|
||
|
|
||
|
public IWrapper<float2> CreateIdleTurn()
|
||
|
{
|
||
|
if (idleTurn.Count is 0) return null;
|
||
|
var state = new DirectionalMixerState();
|
||
|
foreach (var (parameter,clip) in idleTurn)
|
||
|
{
|
||
|
state.Add(clip, parameter);
|
||
|
}
|
||
|
return new MixerStateWrapperFloat2(state);
|
||
|
}
|
||
|
|
||
|
public object CreateRunToIdle() => runToIdle;
|
||
|
|
||
|
public int Hash => tags.GetHashCode();
|
||
|
public IReadOnlyCollection<string> Tags => tags.Select(x => x.Value).ToImmutableArray();
|
||
|
}
|
||
|
|
||
|
}
|