public void Write(EndianBinaryWriter writer, EntityTemplate template)
        {
            if (template.BitField.Count > 0)
            {
                ProcessBitFields(template);
            }

            foreach (ElementProperty prop in Fields)
            {
                switch (prop.Type)
                {
                    case FieldType.Byte:
                        writer.Write((byte)prop.Data);
                        break;
                    case FieldType.Short:
                        writer.Write((short)prop.Data);
                        break;
                    case FieldType.Integer:
                        writer.Write((int)prop.Data);
                        break;
                    case FieldType.Float:
                        writer.Write((float)prop.Data);
                        break;
                    case FieldType.Vector2:
                        Vector2 vec2 = (Vector2)prop.Data;
                        writer.Write((float)vec2.X);
                        writer.Write((float)vec2.Y);
                        break;
                    case FieldType.Vector3:
                        Vector3 vec3 = (Vector3)prop.Data;
                        writer.Write((float)vec3.X);
                        writer.Write((float)vec3.Y);
                        writer.Write((float)vec3.Z);
                        break;
                    case FieldType.String:
                        string name = (string)prop.Data;

                        writer.WriteFixedString(name, 8);

                        for (int i = 0; i < prop.Length - name.Length; i++)
                        {
                            writer.Write((byte)0);
                        }
                        break;
                    case FieldType.ListByte:
                        List<byte> byteList = (List<byte>)prop.Data;

                        foreach (byte by in byteList)
                        {
                            writer.Write(by);
                        }
                        break;
                }
            }
        }
        void ProcessBitFields(EntityTemplate template)
        {
            int bitField = 0;

            foreach (BitFieldObject bitOb in template.BitField)
            {
                ElementProperty prop = Fields.Find(x => x.Name == bitOb.Name);

                int shiftedPropVal = (int)prop.Data << bitOb.BitShift;

                bitField = shiftedPropVal | bitField;
            }

            ElementProperty bitFieldProp = new ElementProperty();

            bitFieldProp.MakeProperty("Bit Field", FieldType.Integer, bitField);

            Fields.Insert(Fields.IndexOf(Fields.Find(x => x.Name == template.BitField[0].Name)), bitFieldProp);

            foreach (BitFieldObject bitOb in template.BitField)
            {
                ElementProperty prop = Fields.Find(x => x.Name == bitOb.Name);

                Fields.Remove(prop);
            }
        }
        public void MakeEmptyChunkFromTemplate(EntityTemplate template)
        {
            ChunkType = template.ChunkID;

            DisplayName = "default";

            Geometry = template.Geometry;

            ActualColor = template.Color;

            DisplayColor = ActualColor;

            switch (Geometry)
            {
                case GeometryType.Cube:
                    GenerateCube();
                    break;
                case GeometryType.Sphere:
                    GenerateSphere(25);
                    break;
                case GeometryType.None:
                    Vertexes = new Vector3[1];
                    Meshes = new int[1];
                    break;
            }

            foreach (ElementProperty prop in template.Properties)
            {
                switch (prop.Type)
                {
                    case FieldType.Byte:
                        prop.Data = (byte)0;
                        break;
                    case FieldType.Short:
                        prop.Data = (short)0;
                        break;
                    case FieldType.Integer:
                        prop.Data = (int)0;
                        break;
                    case FieldType.Float:
                        prop.Data = 0.0f;
                        break;
                    case FieldType.Vector2:
                        prop.Data = new Vector2();
                        break;
                    case FieldType.Vector3:
                        prop.Data = new Vector3();
                        break;
                    case FieldType.String:
                        prop.Data = "default";
                        break;
                    case FieldType.ListByte:
                        List<byte> byteList = new List<byte>();
                        prop.Data = byteList;
                        break;
                }

                Fields.Add(prop.Copy());
            }
        }