Ejemplo n.º 1
0
        // Token: 0x060000C3 RID: 195 RVA: 0x00008B04 File Offset: 0x00006D04
        public static void AssignDirectionalAnimation(this AIAnimator aiAnimator, string name, DirectionalAnimation animation, CompanionBuilder.AnimationType type)
        {
            switch (type)
            {
            case CompanionBuilder.AnimationType.Move:
                aiAnimator.MoveAnimation = animation;
                break;

            case CompanionBuilder.AnimationType.Idle:
                aiAnimator.IdleAnimation = animation;
                break;

            case CompanionBuilder.AnimationType.Fidget:
                aiAnimator.IdleFidgetAnimations.Add(animation);
                break;

            case CompanionBuilder.AnimationType.Flight:
                aiAnimator.FlightAnimation = animation;
                break;

            case CompanionBuilder.AnimationType.Hit:
                aiAnimator.HitAnimation = animation;
                break;

            case CompanionBuilder.AnimationType.Talk:
                aiAnimator.TalkAnimation = animation;
                break;

            default:
                aiAnimator.OtherAnimations.Add(new AIAnimator.NamedDirectionalAnimation
                {
                    anim = animation,
                    name = name
                });
                break;
            }
        }
Ejemplo n.º 2
0
        // Token: 0x060000C0 RID: 192 RVA: 0x0000891C File Offset: 0x00006B1C
        public static tk2dSpriteAnimationClip AddAnimation(this GameObject obj, string name, string spriteDirectory, int fps, CompanionBuilder.AnimationType type, DirectionalAnimation.DirectionType directionType = DirectionalAnimation.DirectionType.None, DirectionalAnimation.FlipType flipType = DirectionalAnimation.FlipType.None)
        {
            AIAnimator           orAddComponent       = obj.GetOrAddComponent <AIAnimator>();
            DirectionalAnimation directionalAnimation = orAddComponent.GetDirectionalAnimation(name, directionType, type);
            bool flag = directionalAnimation == null;

            if (flag)
            {
                directionalAnimation = new DirectionalAnimation
                {
                    AnimNames = new string[0],
                    Flipped   = new DirectionalAnimation.FlipType[0],
                    Type      = directionType,
                    Prefix    = string.Empty
                };
            }
            directionalAnimation.AnimNames = directionalAnimation.AnimNames.Concat(new string[]
            {
                name
            }).ToArray <string>();
            directionalAnimation.Flipped = directionalAnimation.Flipped.Concat(new DirectionalAnimation.FlipType[]
            {
                flipType
            }).ToArray <DirectionalAnimation.FlipType>();
            orAddComponent.AssignDirectionalAnimation(name, directionalAnimation, type);
            return(CompanionBuilder.BuildAnimation(orAddComponent, name, spriteDirectory, fps));
        }
Ejemplo n.º 3
0
        // Token: 0x060000C2 RID: 194 RVA: 0x00008A8C File Offset: 0x00006C8C
        public static DirectionalAnimation GetDirectionalAnimation(this AIAnimator aiAnimator, string name, DirectionalAnimation.DirectionType directionType, CompanionBuilder.AnimationType type)
        {
            DirectionalAnimation directionalAnimation = null;

            switch (type)
            {
            case CompanionBuilder.AnimationType.Move:
                directionalAnimation = aiAnimator.MoveAnimation;
                break;

            case CompanionBuilder.AnimationType.Idle:
                directionalAnimation = aiAnimator.IdleAnimation;
                break;

            case CompanionBuilder.AnimationType.Flight:
                directionalAnimation = aiAnimator.FlightAnimation;
                break;

            case CompanionBuilder.AnimationType.Hit:
                directionalAnimation = aiAnimator.HitAnimation;
                break;

            case CompanionBuilder.AnimationType.Talk:
                directionalAnimation = aiAnimator.TalkAnimation;
                break;
            }
            bool flag = directionalAnimation != null;
            DirectionalAnimation result;

            if (flag)
            {
                result = directionalAnimation;
            }
            else
            {
                result = null;
            }
            return(result);
        }
Ejemplo n.º 4
0
        public static void AdvAddAnimation(this AIAnimator targetAnimator, string animationName, DirectionalAnimation.DirectionType directionality, CompanionBuilder.AnimationType AnimationType, List <DirectionalAnimationData> AnimData)
        {
            List <string> subAnimNames = new List <string>();

            foreach (DirectionalAnimationData data in AnimData)
            {
                subAnimNames.Add(data.subAnimationName);

                tk2dSpriteCollectionData tk2dSpriteCollectionData = targetAnimator.GetComponent <tk2dSpriteCollectionData>();
                if (!tk2dSpriteCollectionData)
                {
                    tk2dSpriteCollectionData = SpriteBuilder.ConstructCollection(targetAnimator.gameObject, targetAnimator.name + "_collection");
                }

                string[]   resourceNames = ResourceExtractor.GetResourceNames();
                List <int> list          = new List <int>();
                for (int i = 0; i < resourceNames.Length; i++)
                {
                    if (resourceNames[i].StartsWith(data.pathDirectory.Replace('/', '.'), StringComparison.OrdinalIgnoreCase))
                    {
                        // ETGModConsole.Log($"Resource Found: {resourceNames[i]}.");
                        list.Add(SpriteBuilder.AddSpriteToCollection(resourceNames[i], tk2dSpriteCollectionData));
                    }
                }
                //ETGModConsole.Log($"Adding animation {data.subAnimationName} with list length {list.Count}.");

                tk2dSpriteAnimationClip tk2dSpriteAnimationClip = SpriteBuilder.AddAnimation(targetAnimator.spriteAnimator, tk2dSpriteCollectionData, list, data.subAnimationName, data.wrapMode);
                tk2dSpriteAnimationClip.fps = (float)data.fps;
            }

            if (AnimationType != CompanionBuilder.AnimationType.Other)
            {
                DirectionalAnimation newDirectionalAnimation = new DirectionalAnimation
                {
                    Type      = directionality,
                    Flipped   = new DirectionalAnimation.FlipType[subAnimNames.Count],
                    AnimNames = subAnimNames.ToArray(),
                    Prefix    = string.Empty,
                };

                switch (AnimationType)
                {
                case CompanionBuilder.AnimationType.Idle:
                    targetAnimator.IdleAnimation = newDirectionalAnimation;
                    break;

                case CompanionBuilder.AnimationType.Move:
                    targetAnimator.MoveAnimation = newDirectionalAnimation;
                    break;

                case CompanionBuilder.AnimationType.Hit:
                    targetAnimator.HitAnimation = newDirectionalAnimation;
                    break;

                case CompanionBuilder.AnimationType.Talk:
                    targetAnimator.TalkAnimation = newDirectionalAnimation;
                    break;

                case CompanionBuilder.AnimationType.Flight:
                    targetAnimator.FlightAnimation = newDirectionalAnimation;
                    break;

                case CompanionBuilder.AnimationType.Fidget:
                    if (targetAnimator.IdleFidgetAnimations == null)
                    {
                        targetAnimator.IdleFidgetAnimations = new List <DirectionalAnimation>();
                    }
                    targetAnimator.IdleFidgetAnimations.Add(newDirectionalAnimation);
                    break;
                }
            }
            else
            {
                AIAnimator.NamedDirectionalAnimation newOtheranim = new AIAnimator.NamedDirectionalAnimation
                {
                    name = animationName,
                    anim = new DirectionalAnimation
                    {
                        Prefix    = animationName,
                        Type      = directionality,
                        Flipped   = new DirectionalAnimation.FlipType[subAnimNames.Count],
                        AnimNames = subAnimNames.ToArray(),
                    }
                };

                if (targetAnimator.OtherAnimations == null)
                {
                    targetAnimator.OtherAnimations = new List <AIAnimator.NamedDirectionalAnimation>();
                }
                targetAnimator.OtherAnimations.Add(newOtheranim);
            }
        }