Exemple #1
0
        internal AnimCharacterCollection(AnimPlayer animPlayer)
        {
            if (AnimLoader.GetLoadedMods(out var mods))
            {
                foreach (Mod mod in mods)
                {
                    this[mod] = new AnimCharacter(animPlayer, mod);
                }

                characterStack = new CharStack <AnimCharacter>(mods.Count);
            }
        }
Exemple #2
0
        /// <summary>
        /// Gets a <see cref="DrawData"/> from the given <see cref="PlayerDrawInfo"/>, based on your <see cref="AnimationController"/> and
        /// <see cref="AnimationSource"/>.
        /// <para>
        /// This can be a quick way to get a <see cref="DrawData"/> that's ready to use for your <see cref="PlayerLayer"/>s.
        /// For a more performant way of getting a <see cref="DrawData"/>, cache your <see cref="AnimationController"/> in your <see cref="ModPlayer"/>
        /// and <see cref="Animations.Animation"/> in your <see cref="AnimationController"/>, and use
        /// <see cref="Animations.Animation.GetDrawData(PlayerDrawInfo)"/>.
        /// </para>
        /// </summary>
        /// <typeparam name="TController"> Your type of <see cref="AnimationController"/>.</typeparam>
        /// <typeparam name="TSource"> Your type of <see cref="AnimationSource"/>.</typeparam>
        /// <param name="drawInfo">The <see cref="PlayerDrawInfo"/> to get the <see cref="DrawData"/> from.</param>
        /// <returns>A <see cref="DrawData"/> that is ready to be drawn. Feel free to modify it.</returns>
        public static DrawData GetDrawData <TController, TSource>(PlayerDrawInfo drawInfo)
            where TController : AnimationController where TSource : AnimationSource
        {
            AnimPlayer          animPlayer = drawInfo.drawPlayer.GetModPlayer <AnimPlayer>();
            Mod                 mod        = AnimHelper.GetModFromController <TController>();
            AnimationController controller = animPlayer.characters[mod].animationController;

            Debug.Assert(controller != null);
            Animation anim = controller.GetAnimation <TSource>();

            return(anim.GetDrawData(drawInfo));
        }