Files
Net.Like.Xue.Tokyo/Packages-Local/Com.Project.B.Unity/CharacterAnimation/ScriptablePlayerAnimationFactory.cs
2025-06-24 23:49:13 +08:00

66 lines
2.7 KiB
C#

using System.Collections;
using System.Collections.Generic;
using Animancer;
using AYellowpaper.SerializedCollections;
using BITKit;
using Unity.Mathematics;
using UnityEngine;
namespace Project.B.Animation
{
public class ScriptablePlayerAnimationFactory : ScriptableHumanoidAnimationFactory,IPlayerAnimationFactory
{
[SerializeField] public AnimationClip[] stepUpAnimations;
[SerializeField] private AnimationClip[] slidingAnimations;
[SerializeField] private AnimationClip[] climbAnimations;
[SerializeField] private AnimationClip[] climbUpAnimations;
[SerializeField] private SerializedDictionary<float, AnimationClip> climbingAnimations;
[SerializeField] private AnimationClip[] openParachuteAnimations;
[SerializeField] private SerializedDictionary<float2,AnimationClip> parachuteAnimations;
[SerializeField] private AnimationClip[] parachuteLandAnimations;
[SerializeField] private AnimationClip[] freeFallAnimations;
[SerializeField] private SerializedDictionary<float, AnimationClip> swimmingAnimations;
[SerializeField] private AnimationClip[] vaultAnimations;
public object CreateStepUpAnimation() => stepUpAnimations.Random();
public object CreateSlidingAnimation() => slidingAnimations.Random();
public object CreateClimbAnimation() => climbAnimations.Random();
public IWrapper<float> CreateClimbingAnimation()
{
var climbing = new LinearMixerState();
foreach (var (parameter, clip) in climbingAnimations)
{
climbing.Add(clip, parameter);
}
return new MixerStateWrapperFloat(climbing);
}
public object CreateClimbUpAnimation() => climbUpAnimations.Random();
public object CreateOpenParachuteAnimation() => openParachuteAnimations.Random();
public IWrapper<float2> CreateParachuteAnimation()
{
var state = new DirectionalMixerState();
foreach (var (parameter, clip) in parachuteAnimations)
{
state.Add(clip, parameter);
}
return new MixerStateWrapperFloat2(state);
}
public object CreateParachuteLandAnimation() => parachuteLandAnimations.Random();
public object CreateFreeFallAnimation() => freeFallAnimations.Random();
public IWrapper<float> CreateSwimmingAnimation()
{
var state = new LinearMixerState();
foreach (var (parameter, clip) in swimmingAnimations)
{
state.Add(clip, parameter);
}
return new MixerStateWrapperFloat(state);
}
public object CreateVaultAnimation() => vaultAnimations.Random();
}
}