FACS01-01 faad9b17ce
AnimatorController Child State Machine Recovery (#1389)
* 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>
2025-04-09 13:18:42 -07:00

33 lines
1.0 KiB
C#

using AssetRipper.SourceGenerated.Subclasses.StateMachineConstant;
using AssetRipper.SourceGenerated.Subclasses.SelectorStateConstant;
namespace AssetRipper.SourceGenerated.Extensions
{
public static class StateMachineConstantExtensions
{
public static int StateMachineCount(this IStateMachineConstant stateMachineConstant)
{
if (!stateMachineConstant.Has_SelectorStateConstantArray())
{
// not needed for Unity 4.x- SubStateMachine reconstruction
return 0;
}
// SelectorStateConstantArray contains Entry and Exit points for StateMachines
// SelectorStateConstantArray = [Entry1, Exit1, Entry2, Exit2, ...]
// just in case, next code handles StateMachine missing Entry or Exit SelectorStateConstant
int stateMachineCount = 0;
uint lastFullPathID = 0;
foreach (SelectorStateConstant ssc in stateMachineConstant.SelectorStateConstantArray)
{
if (lastFullPathID != ssc.FullPathID)
{
lastFullPathID = ssc.FullPathID;
stateMachineCount++;
}
}
return stateMachineCount;
}
}
}