public void RemoveKeyframe(KerbalKeyframe keyframe)
 {
     if (Keyframes.Contains(keyframe))
     {
         Keyframes.Remove(keyframe);
     }
 }
        public KerbalKeyframe CreateKeyframe(float normalizedTime)
        {
            KerbalKeyframe keyframe = new KerbalKeyframe(this);

            Keyframes.Add(keyframe);
            return(keyframe);
        }
    protected void Load(ConfigNode node)
    {
        try
        {
            this.name     = node.GetValue("Name");
            this.duration = float.Parse(node.GetValue("Duration"));
            if (node.HasValue("Layer"))
            {
                this.layer = int.Parse(node.GetValue("Layer"));
            }
            else
            {
                this.layer = 5;
            }

            ConfigNode mtNode = node.GetNode("MIXING_TRANSFORMS");
            foreach (var mt in mtNode.GetValues("MixingTransform"))
            {
                AddMixingTransform(mt);
            }

            ConfigNode keyframesNode = node.GetNode("KEYFRAMES");
            foreach (var keyframeNode in keyframesNode.GetNodes("KEYFRAME"))
            {
                KerbalKeyframe keyframe = new KerbalKeyframe(this);
                keyframe.NormalizedTime = float.Parse(keyframeNode.GetValue("NormalizedTime"));

                foreach (string animationName in AnimationNames.Values)
                {
                    if (!keyframeNode.HasValue(animationName))
                    {
                        continue;
                    }

                    string   allValues = keyframeNode.GetValue(animationName);
                    string[] values    = allValues.Split(' ');

                    float rotW = float.Parse(values [0]);
                    float rotX = float.Parse(values [1]);
                    float rotY = float.Parse(values [2]);
                    float rotZ = float.Parse(values [3]);
                    float posX = float.Parse(values [4]);
                    float posY = float.Parse(values [5]);
                    float posZ = float.Parse(values [6]);

                    keyframe.SetValue(rotW, animationName, KAS_ValueType.RotW);
                    keyframe.SetValue(rotX, animationName, KAS_ValueType.RotX);
                    keyframe.SetValue(rotY, animationName, KAS_ValueType.RotY);
                    keyframe.SetValue(rotZ, animationName, KAS_ValueType.RotZ);
                    keyframe.SetValue(posX, animationName, KAS_ValueType.PosX);
                    keyframe.SetValue(posY, animationName, KAS_ValueType.PosY);
                    keyframe.SetValue(posZ, animationName, KAS_ValueType.PosZ);
                }

                Keyframes.Add(keyframe);
            }
            Debug.Log("KerbalAnimationClip " + this.name + " was loaded successfully.");
        }
        catch (Exception e)
        {
            Debug.LogError("ERROR ENCOUNTERED LOADING ANIMATION");
            Debug.LogException(e);
        }
    }
    protected void Load(ConfigNode node)
    {
        try
        {
            this.name = node.GetValue ("Name");
            this.duration = float.Parse(node.GetValue ("Duration"));
            if(node.HasValue("Layer"))
                this.layer = int.Parse(node.GetValue("Layer"));
            else
                this.layer = 5;

            ConfigNode mtNode = node.GetNode ("MIXING_TRANSFORMS");
            foreach (var mt in mtNode.GetValues("MixingTransform"))
            {
                AddMixingTransform (mt);
            }

            ConfigNode keyframesNode = node.GetNode ("KEYFRAMES");
            foreach (var keyframeNode in keyframesNode.GetNodes("KEYFRAME"))
            {
                KerbalKeyframe keyframe = new KerbalKeyframe (this);
                keyframe.NormalizedTime = float.Parse (keyframeNode.GetValue ("NormalizedTime"));

                foreach (string animationName in AnimationNames.Values)
                {
                    if (!keyframeNode.HasValue (animationName))
                        continue;

                    string allValues = keyframeNode.GetValue (animationName);
                    string[] values = allValues.Split (' ');

                    float rotW = float.Parse (values [0]);
                    float rotX = float.Parse (values [1]);
                    float rotY = float.Parse (values [2]);
                    float rotZ = float.Parse (values [3]);
                    float posX = float.Parse (values [4]);
                    float posY = float.Parse (values [5]);
                    float posZ = float.Parse (values [6]);

                    keyframe.SetValue (rotW, animationName, KAS_ValueType.RotW);
                    keyframe.SetValue (rotX, animationName, KAS_ValueType.RotX);
                    keyframe.SetValue (rotY, animationName, KAS_ValueType.RotY);
                    keyframe.SetValue (rotZ, animationName, KAS_ValueType.RotZ);
                    keyframe.SetValue (posX, animationName, KAS_ValueType.PosX);
                    keyframe.SetValue (posY, animationName, KAS_ValueType.PosY);
                    keyframe.SetValue (posZ, animationName, KAS_ValueType.PosZ);
                }

                Keyframes.Add (keyframe);
            }
            Debug.Log("KerbalAnimationClip " + this.name + " was loaded successfully.");
        }
        catch(Exception e)
        {
            Debug.LogError ("ERROR ENCOUNTERED LOADING ANIMATION");
            Debug.LogException (e);
        }
    }
 public void RemoveKeyframe(KerbalKeyframe keyframe)
 {
     if(Keyframes.Contains(keyframe))
         Keyframes.Remove (keyframe);
 }
 public KerbalKeyframe CreateKeyframe(float normalizedTime)
 {
     KerbalKeyframe keyframe = new KerbalKeyframe (this);
     Keyframes.Add (keyframe);
     return keyframe;
 }