private static IEnumerable <IScriptUsage> GetScriptUsagesFor([NotNull] AnimatorUsagesDataElement element,
                                                                     Guid guid)
        {
            var stateUsages        = GetUsages(element, guid, element.ScriptAnchorToStateUsages);
            var stateMachineUsages = GetUsages(element, guid, element.ScriptAnchorToStateMachineUsages);

            return(ConcatUsages(stateUsages, stateMachineUsages));
        }
 private static bool TryAddBottomStateMachine([NotNull] AnimatorUsagesDataElement element,
                                              [NotNull] PathConsumer <string> namesConsumer,
                                              long anchor)
 {
     if (!element.StateMachineAnchorToUsage.TryGetValue(anchor, out var bottomElement) ||
         bottomElement is null)
     {
         return(false);
     }
     namesConsumer.Elements.Add(bottomElement.Name);
     return(true);
 }
        private static IEnumerable <T> GetUsages <T>(
            [NotNull] AnimatorUsagesDataElement element,
            Guid boxedGuid,
            [NotNull] OneToListMap <long, T> d) where T : IScriptUsage
        {
            var stateUsages = new List <T>();

            foreach (var scriptAnchor in element.GuidToAnchors.GetValuesSafe(boxedGuid))
            {
                stateUsages.AddRange(d.GetValuesSafe(scriptAnchor));
            }
            return(stateUsages);
        }
Пример #4
0
 private static void Write([CanBeNull] UnsafeWriter writer, [CanBeNull] AnimatorUsagesDataElement value)
 {
     if (writer is null || value is null)
     {
         return;
     }
     WriteGuidToAnchorsMap(writer, value.GuidToAnchors);
     WriteAnchorToUsagesMap(writer, value.ScriptAnchorToStateUsages);
     WriteAnchorToUsagesMap(writer, value.ScriptAnchorToStateMachineUsages);
     WriteStateMachineAnchorToUsageMap(writer, value.StateMachineAnchorToUsage);
     WriteChildToParentMap(writer, value.ChildToParent);
     WriteStateNames(writer, value.StateNames);
 }
        private static void ProcessPath <T>([NotNull] AnimatorUsagesDataElement element,
                                            [NotNull] PathConsumer <T> consumer,
                                            long currentAnchor)
        {
            var childToParent             = element.ChildToParent;
            var anchorToStateMachineUsage = element.StateMachineAnchorToUsage;

            while (childToParent.TryGetValue(currentAnchor, out var parent) &&
                   anchorToStateMachineUsage.TryGetValue(parent, out var usage) &&
                   usage != null)
            {
                consumer.Consume(usage);
                currentAnchor = parent;
            }
        }
        private void AddBottomElement([NotNull] AnimatorUsagesDataElement element,
                                      [NotNull] PathConsumer <string> namesConsumer,
                                      long anchor,
                                      [NotNull] IDeclaredElement declaredElement,
                                      out bool isStateMachine)
        {
            if (TryAddBottomStateMachine(element, namesConsumer, anchor))
            {
                isStateMachine = true;
                return;
            }

            isStateMachine = false;
            AddBottomStateElement(element, namesConsumer, anchor, declaredElement);
        }
        private void AddBottomStateElement([NotNull] AnimatorUsagesDataElement element,
                                           [NotNull] PathConsumer <string> namesConsumer,
                                           long anchor,
                                           [NotNull] IDeclaredElement declaredElement)
        {
            if (!(declaredElement is ITypeElement typeElement))
            {
                return;
            }
            var boxedGuid = AssetUtils.GetGuidFor(myMetaFileGuidCache, typeElement);

            if (!boxedGuid.HasValue)
            {
                return;
            }
            var name = GetUsages(element, boxedGuid.Value, element.ScriptAnchorToStateUsages)
                       .Where(usage => usage.Location.LocalDocumentAnchor == anchor)
                       .Select(usage => usage.Name)
                       .FirstOrDefault();

            namesConsumer.Elements.Add(name);
        }