Пример #1
0
        private static int ExtractSampleRateFrom([NotNull] IBlockMappingNode root)
        {
            var sampleRateText  = root.FindMapEntryBySimpleKey("m_SampleRate")?.Content?.Value.GetPlainScalarText();
            var foundSampleRate = int.TryParse(sampleRateText, out var sampleRate);

            return(foundSampleRate ? sampleRate : throw new AnimationExtractorException());
        }
Пример #2
0
        private static LocalList <long> ExtractStateMachineBehavioursAnchorsFrom([NotNull] IBlockMappingNode root)
        {
            var node = root.FindMapEntryBySimpleKey("m_StateMachineBehaviours")?.Content?.Value;

            if (!(node is IBlockSequenceNode record))
            {
                return(new LocalList <long>());
            }
            return(record.Entries.Aggregate(new LocalList <long>(), AddAnchor));
        }
Пример #3
0
        private static string ExtractAnimatorStateNameFrom([NotNull] IBlockMappingNode root)
        {
            var name = root.FindMapEntryBySimpleKey("m_Name")?.Content?.Value?.GetPlainScalarText();

            if (name is null)
            {
                throw new AnimatorExtractorException();
            }
            return(name);
        }
Пример #4
0
        private static LocalList <long> ExtractChildAnchors(
            [NotNull] IBlockMappingNode root, string recordKey, string innerRecordKey)
        {
            var anchors = (root.FindMapEntryBySimpleKey(recordKey)?.Content?.Value as IBlockSequenceNode)?
                          .Entries
                          .SelectNotNull(t => t?.Value as IBlockMappingNode)
                          .SelectNotNull(t => t.FindMapEntryBySimpleKey(innerRecordKey)?.Content?.Value as IFlowMappingNode)
                          .SelectNotNull(t => t.FindMapEntryBySimpleKey("fileID")?.Value as IPlainScalarNode)
                          .SelectNotNull(t => long.TryParse(t?.GetPlainScalarText(), out var anchor) ? anchor : (long?)null);
            var list = new LocalList <long>();

            if (anchors is null)
            {
                return(list);
            }
            foreach (var anchor in anchors)
            {
                list.Add(anchor);
            }
            return(list);
        }
Пример #5
0
        public static string GetValueFromModifications(IBlockMappingNode modification, string targetFileId, string value)
        {
            if (targetFileId != null && modification.FindMapEntryBySimpleKey(UnityYamlConstants.ModificationsProperty)?.Value is IBlockSequenceNode modifications)
            {
                foreach (var element in modifications.Entries)
                {
                    if (!(element.Value is IBlockMappingNode mod))
                    {
                        return(null);
                    }
                    var type = (mod.FindMapEntryBySimpleKey(UnityYamlConstants.PropertyPathProperty)?.Value as IPlainScalarNode)
                               ?.Text.GetText();
                    var target = mod.FindMapEntryBySimpleKey(UnityYamlConstants.TargetProperty)?.Value?.AsFileID();
                    if (type?.Equals(value) == true && target?.fileID.Equals(targetFileId) == true)
                    {
                        return((mod.FindMapEntryBySimpleKey(UnityYamlConstants.ValueProperty)?.Value as IPlainScalarNode)?.Text.GetText());
                    }
                }
            }

            return(null);
        }