Example #1
0
        protected override YAMLMappingNode ExportYAMLRoot(IExportContainer container)
        {
            YAMLMappingNode node   = base.ExportYAMLRoot(container);
            AnimationLayout layout = container.ExportLayout.Animation;

            node.AddSerializedVersion(layout.Version);
            node.Add(layout.AnimationName, DefaultAnimation.ExportYAML(container));
            if (layout.HasAnimations)
            {
                node.Add(layout.AnimationsName, Animations.ExportYAML(container));
            }
            else
            {
                node.Add(layout.AnimationsName, AnimationsPaired.ExportYAML(container));
            }

            node.Add(layout.WrapModeName, (int)WrapMode);
            node.Add(layout.PlayAutomaticallyName, PlayAutomatically);
            node.Add(layout.AnimatePhysicsInvariantName, AnimatePhysics);
            if (layout.HasAnimateOnlyIfVisible)
            {
                node.Add(layout.CullingTypeName, AnimateOnlyIfVisible);
            }
            if (layout.HasCullingType)
            {
                node.Add(layout.CullingTypeName, (int)CullingType);
            }
            if (layout.HasUserAABB)
            {
                node.Add(layout.UserAABBName, UserAABB.ExportYAML(container));
            }
            return(node);
        }
Example #2
0
        public override IEnumerable <PPtr <Object> > FetchDependencies(DependencyContext context)
        {
            foreach (PPtr <Object> asset in base.FetchDependencies(context))
            {
                yield return(asset);
            }

            AnimationLayout layout = context.Layout.Animation;

            yield return(context.FetchDependency(DefaultAnimation, layout.AnimationName));

            if (layout.HasAnimationsPaired)
            {
                foreach (PPtr <Object> asset in context.FetchDependencies(AnimationsPaired.Select(t => t.Item2), layout.AnimationsName))
                {
                    yield return(asset);
                }
            }
            else
            {
                foreach (PPtr <Object> asset in context.FetchDependencies(Animations, layout.AnimationsName))
                {
                    yield return(asset);
                }
            }
        }
Example #3
0
        public static Animation Convert(IExportContainer container, Animation origin)
        {
            AnimationLayout layout   = container.Layout.Animation;
            AnimationLayout exlayout = container.ExportLayout.Animation;
            Animation       instance = new Animation(container.ExportLayout);

            BehaviourConverter.Convert(container, origin, instance);
            if (exlayout.HasAnimations)
            {
                instance.Animations = GetAnimations(container, origin);
            }
            else
            {
                instance.AnimationsPaired = origin.AnimationsPaired.ToArray();
            }
            instance.WrapMode          = origin.WrapMode;
            instance.PlayAutomatically = origin.PlayAutomatically;
            instance.AnimatePhysics    = origin.AnimatePhysics;
            if (exlayout.HasAnimateOnlyIfVisible && layout.HasAnimateOnlyIfVisible)
            {
                instance.AnimateOnlyIfVisible = origin.AnimateOnlyIfVisible;
            }
            if (exlayout.HasCullingType && layout.HasCullingTypeInvariant)
            {
                instance.CullingType = origin.CullingType;
            }
            if (layout.HasUserAABB && exlayout.HasUserAABB)
            {
                instance.UserAABB = origin.UserAABB;
            }
            return(instance);
        }
Example #4
0
        public Animation(AssetLayout layout) :
            base(layout)
        {
            AnimationLayout classLayout = layout.Animation;

            if (classLayout.HasAnimations)
            {
                Animations = Array.Empty <PPtr <AnimationClip> >();
            }
            else
            {
                AnimationsPaired = Array.Empty <Tuple <string, PPtr <AnimationClip> > >();
            }
            PlayAutomatically = true;
        }
Example #5
0
        public override void Write(AssetWriter writer)
        {
            base.Write(writer);

            AnimationLayout layout = writer.Layout.Animation;

            DefaultAnimation.Write(writer);
            if (layout.HasAnimations)
            {
                Animations.Write(writer);
            }
            else
            {
                AnimationsPaired.Write(writer);
            }

            writer.Write((int)WrapMode);
            writer.Write(PlayAutomatically);
            writer.Write(AnimatePhysics);
            if (layout.HasAnimateOnlyIfVisible)
            {
                writer.Write(AnimateOnlyIfVisible);
            }
            if (layout.IsAlign)
            {
                writer.AlignStream();
            }

            if (layout.HasCullingType)
            {
                writer.Write((int)CullingType);
            }
            if (layout.HasUserAABB)
            {
                UserAABB.Write(writer);
            }
        }
Example #6
0
        public override void Read(AssetReader reader)
        {
            base.Read(reader);

            AnimationLayout layout = reader.Layout.Animation;

            DefaultAnimation.Read(reader);
            if (layout.HasAnimations)
            {
                Animations = reader.ReadAssetArray <PPtr <AnimationClip> >();
            }
            else
            {
                AnimationsPaired = reader.ReadTupleStringTArray <PPtr <AnimationClip> >();
            }

            WrapMode          = (WrapMode)reader.ReadInt32();
            PlayAutomatically = reader.ReadBoolean();
            AnimatePhysics    = reader.ReadBoolean();
            if (layout.HasAnimateOnlyIfVisible)
            {
                AnimateOnlyIfVisible = reader.ReadBoolean();
            }
            if (layout.IsAlign)
            {
                reader.AlignStream();
            }

            if (layout.HasCullingType)
            {
                CullingType = (AnimationCullingType)reader.ReadInt32();
            }
            if (layout.HasUserAABB)
            {
                UserAABB.Read(reader);
            }
        }