(MIGRATION) Fix all compilation issues

This commit is contained in:
Haï~
2023-10-02 04:47:57 +02:00
parent c4174120b9
commit af5ce1576b
24 changed files with 185 additions and 95 deletions
+32 -63
View File
@@ -1,9 +1,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEditor;
using UnityEditor.Animations;
using UnityEngine;
using VRC.SDK3.Avatars.Components;
using Random = UnityEngine.Random;
// ReSharper disable once CheckNamespace
@@ -16,16 +16,11 @@ namespace AnimatorAsCode.V1
return new AacFlBase(configuration);
}
internal static AnimatorController AnimatorOf(VRCAvatarDescriptor ad, VRCAvatarDescriptor.AnimLayerType animLayerType)
{
return (AnimatorController) ad.baseAnimationLayers.First(it => it.type == animLayerType).animatorController;
}
internal static AnimationClip NewClip(AacConfiguration component, string suffix)
{
return RegisterClip(component, suffix, new AnimationClip());
}
internal static AnimationClip RegisterClip(AacConfiguration component, string suffix, AnimationClip clip)
{
clip.name = "zAutogenerated__" + component.AssetKey + "__" + suffix + "_" + Random.Range(0, Int32.MaxValue); // FIXME animation name conflict
@@ -82,12 +77,32 @@ namespace AnimatorAsCode.V1
public struct AacConfiguration
{
public string SystemName;
public VRCAvatarDescriptor AvatarDescriptor;
public Transform AnimatorRoot;
public Transform DefaultValueRoot;
public AnimatorController AssetContainer;
public string AssetKey;
public IAacDefaultsProvider DefaultsProvider;
public Dictionary<Type, object> AdditionalData; // Nullable
public AacConfiguration WithAdditonalData(Type key, object value)
{
var conf = this;
if (AdditionalData == null) conf.AdditionalData = new Dictionary<Type, object>();
conf.AdditionalData[key] = value;
return conf;
}
public bool TryGetAdditionalData(Type key, out object value)
{
if (AdditionalData != null && AdditionalData.TryGetValue(key, out var result))
{
value = result;
return true;
}
value = null;
return false;
}
}
public struct AacFlLayer
@@ -276,6 +291,11 @@ namespace AnimatorAsCode.V1
{
private readonly AacConfiguration _configuration;
public AacConfiguration InternalConfiguration()
{
return _configuration;
}
internal AacFlBase(AacConfiguration configuration)
{
_configuration = configuration;
@@ -333,62 +353,11 @@ namespace AnimatorAsCode.V1
.WithUnit(unit, keyframes => keyframes.Constant(0, 0f).Constant(duration, 0f)));
}
public void RemoveAllMainLayers()
{
var layerName = _configuration.SystemName;
RemoveLayerOnAllControllers(_configuration.DefaultsProvider.ConvertLayerName(layerName));
}
public AacFlLayer CreateMainArbitraryControllerLayer(AnimatorController controller) => InternalDoCreateLayer(controller, _configuration.DefaultsProvider.ConvertLayerName(_configuration.SystemName));
public AacFlLayer CreateSupportingArbitraryControllerLayer(AnimatorController controller, string suffix) => InternalDoCreateLayer(controller, _configuration.DefaultsProvider.ConvertLayerNameWithSuffix(_configuration.SystemName, suffix));
public AacFlLayer CreateFirstArbitraryControllerLayer(AnimatorController controller) => InternalDoCreateLayer(controller, controller.layers[0].name);
public void RemoveAllSupportingLayers(string suffix)
{
var layerName = _configuration.SystemName;
RemoveLayerOnAllControllers(_configuration.DefaultsProvider.ConvertLayerNameWithSuffix(layerName, suffix));
}
private void RemoveLayerOnAllControllers(string layerName)
{
var layers = _configuration.AvatarDescriptor.baseAnimationLayers.Select(layer => layer.animatorController).Where(layer => layer != null).Distinct().ToList();
foreach (var customAnimLayer in layers)
{
new AacAnimatorRemoval((AnimatorController) customAnimLayer).RemoveLayer(_configuration.DefaultsProvider.ConvertLayerName(layerName));
}
}
public AacFlLayer CreateMainFxLayer() => DoCreateMainLayerOnController(VRCAvatarDescriptor.AnimLayerType.FX);
public AacFlLayer CreateMainGestureLayer() => DoCreateMainLayerOnController(VRCAvatarDescriptor.AnimLayerType.Gesture);
public AacFlLayer CreateMainActionLayer() => DoCreateMainLayerOnController(VRCAvatarDescriptor.AnimLayerType.Action);
public AacFlLayer CreateMainIdleLayer() => DoCreateMainLayerOnController(VRCAvatarDescriptor.AnimLayerType.Additive);
public AacFlLayer CreateMainLocomotionLayer() => DoCreateMainLayerOnController(VRCAvatarDescriptor.AnimLayerType.Base);
public AacFlLayer CreateMainAv3Layer(VRCAvatarDescriptor.AnimLayerType animLayerType) => DoCreateMainLayerOnController(animLayerType);
public AacFlLayer CreateSupportingFxLayer(string suffix) => DoCreateSupportingLayerOnController(VRCAvatarDescriptor.AnimLayerType.FX, suffix);
public AacFlLayer CreateSupportingGestureLayer(string suffix) => DoCreateSupportingLayerOnController(VRCAvatarDescriptor.AnimLayerType.Gesture, suffix);
public AacFlLayer CreateSupportingActionLayer(string suffix) => DoCreateSupportingLayerOnController(VRCAvatarDescriptor.AnimLayerType.Action, suffix);
public AacFlLayer CreateSupportingIdleLayer(string suffix) => DoCreateSupportingLayerOnController(VRCAvatarDescriptor.AnimLayerType.Additive, suffix);
public AacFlLayer CreateSupportingLocomotionLayer(string suffix) => DoCreateSupportingLayerOnController(VRCAvatarDescriptor.AnimLayerType.Base, suffix);
public AacFlLayer CreateSupportingAv3Layer(VRCAvatarDescriptor.AnimLayerType animLayerType, string suffix) => DoCreateSupportingLayerOnController(animLayerType, suffix);
public AacFlLayer CreateMainArbitraryControllerLayer(AnimatorController controller) => DoCreateLayer(controller, _configuration.DefaultsProvider.ConvertLayerName(_configuration.SystemName));
public AacFlLayer CreateSupportingArbitraryControllerLayer(AnimatorController controller, string suffix) => DoCreateLayer(controller, _configuration.DefaultsProvider.ConvertLayerNameWithSuffix(_configuration.SystemName, suffix));
public AacFlLayer CreateFirstArbitraryControllerLayer(AnimatorController controller) => DoCreateLayer(controller, controller.layers[0].name);
private AacFlLayer DoCreateMainLayerOnController(VRCAvatarDescriptor.AnimLayerType animType)
{
var animator = AacV0.AnimatorOf(_configuration.AvatarDescriptor, animType);
var layerName = _configuration.DefaultsProvider.ConvertLayerName(_configuration.SystemName);
return DoCreateLayer(animator, layerName);
}
private AacFlLayer DoCreateSupportingLayerOnController(VRCAvatarDescriptor.AnimLayerType animType, string suffix)
{
var animator = AacV0.AnimatorOf(_configuration.AvatarDescriptor, animType);
var layerName = _configuration.DefaultsProvider.ConvertLayerNameWithSuffix(_configuration.SystemName, suffix);
return DoCreateLayer(animator, layerName);
}
private AacFlLayer DoCreateLayer(AnimatorController animator, string layerName)
public AacFlLayer InternalDoCreateLayer(AnimatorController animator, string layerName)
{
var ag = new AacAnimatorGenerator(animator, CreateEmptyClip().Clip, _configuration.DefaultsProvider);
var machine = ag.CreateOrClearLayerAtSameIndex(layerName, 1f);
+7 -7
View File
@@ -55,7 +55,7 @@ namespace AnimatorAsCode.V1
{
}
protected internal abstract float ValueToFloat(TParam value);
public abstract float ValueToFloat(TParam value);
}
public abstract class AacFlNumericParameter<TParam> : AacFlParameter<TParam>
@@ -71,8 +71,8 @@ namespace AnimatorAsCode.V1
protected AacFlFloatParameter(string name) : base(name) { }
public IAacFlCondition IsGreaterThan(float other) => Just(condition => condition.Add(Name, Greater, other));
public IAacFlCondition IsLessThan(float other) => Just(condition => condition.Add(Name, Less, other));
protected internal override float ValueToFloat(float value)
public override float ValueToFloat(float value)
{
return value;
}
@@ -86,8 +86,8 @@ namespace AnimatorAsCode.V1
public IAacFlCondition IsLessThan(int other) => Just(condition => condition.Add(Name, Less, other));
public IAacFlCondition IsEqualTo(int other) => Just(condition => condition.Add(Name, AnimatorConditionMode.Equals, other));
public IAacFlCondition IsNotEqualTo(int other) => Just(condition => condition.Add(Name, NotEqual, other));
protected internal override float ValueToFloat(int value)
public override float ValueToFloat(int value)
{
return value;
}
@@ -112,8 +112,8 @@ namespace AnimatorAsCode.V1
public IAacFlCondition IsFalse() => Just(condition => condition.Add(Name, IfNot, 0));
public IAacFlCondition IsEqualTo(bool other) => Just(condition => condition.Add(Name, other ? If : IfNot, 0));
public IAacFlCondition IsNotEqualTo(bool other) => Just(condition => condition.Add(Name, other ? IfNot : If, 0));
protected internal override float ValueToFloat(bool value)
public override float ValueToFloat(bool value)
{
return value ? 1f : 0f;
}