Example #1
0
        public Derpy(ThingBlock block, ThingDefinition def)
            : base(block, def)
        {
            bodyComponent = ModelComponents[0];
            flagComponent = ModelComponents[1];
            startLightComponent = ModelComponents[2];

            bodyFacing = new Euler(0, 0, 0);
            neckFacing = new Euler(0, 0, 0);

            Skeleton skeleton = bodyComponent.Entity.Skeleton;
            skeleton.BlendMode = SkeletonAnimationBlendMode.ANIMBLEND_CUMULATIVE;

            blinkState = bodyComponent.Entity.GetAnimationState("Blink2");
            blinkState.Enabled = true;
            blinkState.Loop = true;
            blinkState.Weight = 1f;
            blinkState.AddTime(ID);

            neckBone = skeleton.GetBone("Neck");
            neckBone.SetManuallyControlled(true);
            foreach (var state in bodyComponent.Entity.AllAnimationStates.GetAnimationStateIterator())
            {
                // don't add a blend mask to the blink state because we'll make a different one for it
                if (state == blinkState)
                    continue;

                state.CreateBlendMask(skeleton.NumBones);
                state.SetBlendMaskEntry(neckBone.Handle, 0f);
            }
            neckBone.InheritOrientation = false;

            blinkState.CreateBlendMask(skeleton.NumBones, 0f);
            ushort handle = skeleton.GetBone("EyeBrowTop.R").Handle;
            blinkState.SetBlendMaskEntry(handle, 1f);
            handle = skeleton.GetBone("EyeBrowBottom.R").Handle;
            blinkState.SetBlendMaskEntry(handle, 1f);
            handle = skeleton.GetBone("EyeBrowTop.L").Handle;
            blinkState.SetBlendMaskEntry(handle, 1f);
            handle = skeleton.GetBone("EyeBrowBottom.L").Handle;
            blinkState.SetBlendMaskEntry(handle, 1f);

            LKernel.GetG<AnimationManager>().Add(blinkState);

            interpNode = LKernel.GetG<SceneManager>().RootSceneNode.CreateChildSceneNode("DerpyInterpNode" + ID, Vector3.ZERO);

            anim = DerpyAnimation.Hover1;
        }
Example #2
0
 /// <summary>
 /// Change animations based on kart speed
 /// </summary>
 private void EveryTenth(object state)
 {
     if (followKart == null)
         return;
     float speed = followKart.VehicleSpeed;
     if ((speed < 30f && speed > -15f) && anim == DerpyAnimation.Forward1)
     {
         bodyComponent.AnimationBlender.Blend("Hover1", AnimationBlendingTransition.BlendThenAnimate, 0.2f, true);
         anim = DerpyAnimation.Hover1;
     }
     else if ((speed > 30f || speed < -15f) && anim == DerpyAnimation.Hover1)
     {
         bodyComponent.AnimationBlender.Blend("Forward1", AnimationBlendingTransition.BlendThenAnimate, 0.2f, true);
         anim = DerpyAnimation.Forward1;
     }
 }
Example #3
0
        public override void ChangeAnimation(string animationName)
        {
            if (bodyComponent.Entity.AllAnimationStates.HasAnimationState(animationName))
            {
                bodyComponent.AnimationBlender.Blend(animationName, AnimationBlendingTransition.BlendSwitch, 0, true);

                if (animationName == "FlagWave1" || animationName == "FlagWave2")
                {
                    startLightComponent.Entity.Visible = false;
                    flagComponent.Entity.Visible = true;

                    flagComponent.AnimationBlender.Blend(animationName, AnimationBlendingTransition.BlendSwitch, 0, true);
                    startLightComponent.AnimationBlender.Blend("Basis", AnimationBlendingTransition.BlendSwitch, 0, true);
                }
                else if (animationName == "HoldStartLight1")
                {
                    flagComponent.Entity.Visible = false;
                    startLightComponent.Entity.Visible = true;

                    startLightComponent.AnimationBlender.Blend(animationName, AnimationBlendingTransition.BlendSwitch, 0, true);
                    flagComponent.AnimationBlender.Blend("Basis", AnimationBlendingTransition.BlendSwitch, 0, true);
                }
                else
                {
                    flagComponent.Entity.Visible = false;
                    startLightComponent.Entity.Visible = false;

                    startLightComponent.AnimationBlender.Blend("Basis", AnimationBlendingTransition.BlendSwitch, 0, true);
                    flagComponent.AnimationBlender.Blend("Basis", AnimationBlendingTransition.BlendSwitch, 0, true);
                }

                anim = (DerpyAnimation) System.Enum.Parse(typeof(DerpyAnimation), animationName, true);
            }
        }