mirror of
https://github.com/AssetRipper/AssetRipper.git
synced 2025-12-11 20:15:29 +01:00
* first draft * change requests * actually working draft * duplicated method * use more the new method * - put StateContext class on a separate file - new BidirectionalDictionary<T1,T2> class - other tweaks * - put StateMachineContext class on a separate file - move all asset creations into VirtualAnimationFactory class - added extension method GetName() to IStateConstant - other tweaks * Apply suggestions from code review Co-authored-by: Jeremy Pritts <49847914+ds5678@users.noreply.github.com> * apply requested changes * Apply suggestions from code review Co-authored-by: Jeremy Pritts <49847914+ds5678@users.noreply.github.com> * reorder methods * Update Source/AssetRipper.Processing/AnimatorControllers/AnimatorStateContext.cs Co-authored-by: Jeremy Pritts <49847914+ds5678@users.noreply.github.com> * apply requested changes * IndexedState to StateData[] * Update Source/AssetRipper.Processing/AnimatorControllers/AnimatorStateContext.cs Co-authored-by: Jeremy Pritts <49847914+ds5678@users.noreply.github.com> * apply requested changes * Apply suggestions from code review Co-authored-by: Jeremy Pritts <49847914+ds5678@users.noreply.github.com> * a lot of restructuring and comments * statemachine parenting finished * simplify CreateDefaultAnimatorState * small tweaks --------- Co-authored-by: Jeremy Pritts <49847914+ds5678@users.noreply.github.com>
48 lines
1.6 KiB
C#
48 lines
1.6 KiB
C#
using AssetRipper.SourceGenerated.Subclasses.ControllerConstant;
|
|
using AssetRipper.SourceGenerated.Subclasses.LayerConstant;
|
|
|
|
namespace AssetRipper.SourceGenerated.Extensions
|
|
{
|
|
public static class ControllerConstantExtensions
|
|
{
|
|
public static ILayerConstant GetLayerByStateMachineIndex(this IControllerConstant controllerConstant, int index)
|
|
{
|
|
for (int i = 0; i < controllerConstant.LayerArray.Count; i++)
|
|
{
|
|
ILayerConstant layer = controllerConstant.LayerArray[i].Data;
|
|
if (layer.StateMachineIndex == index && layer.StateMachineSynchronizedLayerIndex == 0)
|
|
{
|
|
return layer;
|
|
}
|
|
}
|
|
throw new ArgumentOutOfRangeException(nameof(index));
|
|
}
|
|
|
|
public static int GetLayerIndexByStateMachineIndex(this IControllerConstant controllerConstant, int index, out ILayerConstant layer)
|
|
{
|
|
for (int i = 0; i < controllerConstant.LayerArray.Count; i++)
|
|
{
|
|
layer = controllerConstant.LayerArray[i].Data;
|
|
if (layer.StateMachineIndex == index && layer.StateMachineSynchronizedLayerIndex == 0)
|
|
{
|
|
return i;
|
|
}
|
|
}
|
|
throw new ArgumentOutOfRangeException(nameof(index));
|
|
}
|
|
|
|
public static int GetLayerIndex(this IControllerConstant controllerConstant, ILayerConstant layer)
|
|
{
|
|
for (int i = 0; i < controllerConstant.LayerArray.Count; i++)
|
|
{
|
|
ILayerConstant checkLayer = controllerConstant.LayerArray[i].Data;
|
|
if (checkLayer.StateMachineIndex == layer.StateMachineIndex && checkLayer.StateMachineSynchronizedLayerIndex == layer.StateMachineSynchronizedLayerIndex)
|
|
{
|
|
return i;
|
|
}
|
|
}
|
|
throw new ArgumentException("Layer hasn't been found", nameof(layer));
|
|
}
|
|
}
|
|
}
|