Example #1
0
 /// <summary>
 /// Add a Bone to the Skeleton.
 /// </summary>
 /// <param name="bone">The Bone to add.</param>
 /// <returns>The added Bone.</returns>
 public Bone AddBone(Bone bone) {
     bones.Add(bone);
     bone.Skeleton = this;
     return bone;
 }
Example #2
0
        /// <summary>
        /// Remove a Bone from the Skeleton.
        /// </summary>
        /// <param name="bone"></param>
        /// <returns></returns>
        public Bone RemoveBone(Bone bone) {
            if (stringByBones.ContainsKey(bone)) {
                bonesByString.Remove(stringByBones[bone]);
                stringByBones.Remove(bone);
            }
            bones.RemoveIfContains(bone);
            bone.Skeleton = null;

            return bone;
        }
Example #3
0
        void ParseXml(XmlNodeList nodes, string parent = "") {
            foreach (XmlNode node in nodes) {
                var bone = new Bone(
                    node.AttributeFloat("x", 0),
                    node.AttributeFloat("y", 0),
                    node.AttributeFloat("rotation", 0),
                    node.AttributeFloat("scaleX", 1),
                    node.AttributeFloat("scaleY", 1)
                    );

                bone.FlipGraphicY = node.AttributeBool("flipGraphicY", false);
                bone.FlipGraphicX = node.AttributeBool("flipGraphicX", false);
                bone.LocalFlipX = node.AttributeBool("flipX", false);
                bone.LocalFlipY = node.AttributeBool("flipY", false);

                var boneName = node.AttributeString("name", "base");

                var boneEntityType = Util.GetTypeFromAllAssemblies(node.AttributeString("entity"));
                var boneEntity = (Entity)Activator.CreateInstance(boneEntityType, 0, 0);
                bone.SetEntity(boneEntity);

                if (parent == "") {
                    AddBone(boneName, bone);
                }
                else {
                    AddBone(parent, boneName, bone);
                }

                if (node.ChildNodes.Count > 0) {
                    ParseXml(node.ChildNodes, boneName);
                }
            }
        }
Example #4
0
 /// <summary>
 /// Add a Bone to the Skeleton.
 /// </summary>
 /// <param name="id">The id of the bone being added.</param>
 /// <param name="bone">The Bone being added.</param>
 /// <returns>The added Bone.</returns>
 public Bone AddBone(Enum id, Bone bone = null) {
     return AddBone(Util.EnumValueToString(id), bone);
 }
Example #5
0
        /// <summary>
        /// Remove a Bone from the Skeleton.
        /// </summary>
        /// <param name="name">The name of the Bone to remove.</param>
        /// <param name="bone">The Bone to return if no Bone was removed.</param>
        /// <returns>The removed Bone, or the Bone passed into the method if no Bone was removed.</returns>
        public Bone RemoveBone(string name, Bone bone = null) {
            bone = bone == null ? new Bone() : bone;
            if (bonesByString.ContainsKey(name)) {
                stringByBones.Remove(bonesByString[name]);
                bone = bonesByString[name];
                bonesByString.Remove(name);
                bones.RemoveIfContains(bone);
                bone.Skeleton = null;
            }

            return bone;
        }
Example #6
0
 /// <summary>
 /// Add a Bone to the Skeleton.
 /// </summary>
 /// <param name="name">The name of the Bone being added.</param>
 /// <param name="bone">The Bone being added.</param>
 /// <returns>The added Bone.</returns>
 public Bone AddBone(string name, Bone bone = null) {
     bone = bone == null ? new Bone() : bone;
     bonesByString.Add(name, bone);
     stringByBones.Add(bone, name); // Inverted dictionary for cross look up or something I dunno lol
     AddBone(bone);
     bone.Name = name;
     return bone;
 }
Example #7
0
 /// <summary>
 /// Add a Bone to the Skeleton.
 /// </summary>
 /// <param name="parent">The parent Bone.</param>
 /// <param name="bone">The Bone being added.</param>
 /// <returns>The added Bone.</returns>
 public Bone AddBone(Bone parent, Bone bone = null) {
     bone = bone == null ? new Bone() : bone;
     parent.AddBone(bone);
     AddBone(bone);
     return bone;
 }
Example #8
0
 /// <summary>
 /// Add a Bone to the Skeleton.
 /// </summary>
 /// <param name="parentName">The name of the Bone to parent this bone to.</param>
 /// <param name="name">The name of the Bone being added.</param>
 /// <param name="bone">The Bone being added.</param>
 /// <returns>The added Bone.</returns>
 public Bone AddBone(Enum parentName, Enum name, Bone bone = null) {
     return AddBone(Util.EnumValueToString(parentName), Util.EnumValueToString(name), bone);
 }
Example #9
0
 /// <summary>
 /// Add a Bone to the Skeleton.
 /// </summary>
 /// <param name="parentName">The name of the Bone to parent this bone to.</param>
 /// <param name="name">The name of the Bone being added.</param>
 /// <param name="bone">The Bone being added.</param>
 /// <returns>The added Bone.</returns>
 public Bone AddBone(string parentName, string name, Bone bone = null) {
     bone = bone == null ? new Bone() : bone;
     var parent = bonesByString[parentName];
     parent.AddBone(bone);
     AddBone(name, bone);
     return bone;
 }
Example #10
0
 /// <summary>
 /// Add a bone as a child of this bone.  This should be done via a Skeleton!
 /// </summary>
 /// <param name="e">The bone to add.</param>
 /// <returns>The added bone.</returns>
 public Bone AddBone(Bone e) {
     Children.Add(e);
     e.Parent = this;
     return e;
 }