private int LoadVec3Controls(int yPos, ElementProperty prop)
        {
            NumericUpDown Vec3NumericX = new NumericUpDown();
            Vec3NumericX.Name = prop.Name + ":X";
            Vec3NumericX.Minimum = decimal.MinValue;
            Vec3NumericX.Maximum = decimal.MaxValue;
            Vec3NumericX.DecimalPlaces = 3;
            Vec3NumericX.Location = new Point(ControlBase.Width - Vec3NumericX.Width, yPos);
            ControlBase.Controls.Add(Vec3NumericX);

            Label propLabelX = new Label();

            propLabelX.Name = prop.Name + "Label";
            propLabelX.Text = "X " + prop.Name + ": ";

            propLabelX.Location = new Point(7, yPos);

            ControlBase.Controls.Add(propLabelX);

            yPos += 26;

            NumericUpDown Vec3NumericY = new NumericUpDown();
            Vec3NumericY.Name = prop.Name + ":Y";
            Vec3NumericY.Minimum = decimal.MinValue;
            Vec3NumericY.Maximum = decimal.MaxValue;
            Vec3NumericY.DecimalPlaces = 3;
            Vec3NumericY.Location = new Point(ControlBase.Width - Vec3NumericY.Width, yPos);
            ControlBase.Controls.Add(Vec3NumericY);

            Label propLabelY = new Label();

            propLabelY.Name = prop.Name + "Label";
            propLabelY.Text = "Y " + prop.Name + ": ";

            propLabelY.Location = new Point(7, yPos);

            ControlBase.Controls.Add(propLabelY);

            yPos += 26;

            NumericUpDown Vec3NumericZ = new NumericUpDown();
            Vec3NumericZ.Name = prop.Name + ":Z";
            Vec3NumericZ.Minimum = decimal.MinValue;
            Vec3NumericZ.Maximum = decimal.MaxValue;
            Vec3NumericZ.DecimalPlaces = 3;
            Vec3NumericZ.Location = new Point(ControlBase.Width - Vec3NumericZ.Width, yPos);
            ControlBase.Controls.Add(Vec3NumericZ);

            Label propLabelZ = new Label();

            propLabelZ.Name = prop.Name + "Label";
            propLabelZ.Text = "Z " + prop.Name + ": ";

            propLabelZ.Location = new Point(7, yPos);

            ControlBase.Controls.Add(propLabelZ);

            yPos += 26;

            return yPos;
        }
        void SavePosition(ElementProperty prop)
        {
            Vector3 pos = (Vector3)prop.Data;

            List<NumericUpDown> posControls = new List<NumericUpDown>();

            List<NumericUpDown> vecControls = new List<NumericUpDown>();

            Control[] controlX = ControlBase.Controls.Find("Position:X", false);

            Control[] controlY = ControlBase.Controls.Find("Position:Y", false);

            Control[] controlZ = ControlBase.Controls.Find("Position:Z", false);

            NumericUpDown numControlX = (NumericUpDown)controlX[0];

            NumericUpDown numControlY = (NumericUpDown)controlY[0];

            NumericUpDown numControlZ = (NumericUpDown)controlZ[0];

            pos.X = Convert.ToSingle(numControlX.Value);

            pos.Y = Convert.ToSingle(numControlY.Value);

            pos.Z = Convert.ToSingle(numControlZ.Value);

            prop.Data = pos;
        }
        private void FillVec3(ElementProperty prop)
        {
            Vector3 pos = (Vector3)prop.Data;

            List<NumericUpDown> posControls = new List<NumericUpDown>();

            List<NumericUpDown> vecControls = new List<NumericUpDown>();

            Control[] controlX = ControlBase.Controls.Find("Position:X", false);

            Control[] controlY = ControlBase.Controls.Find("Position:Y", false);

            Control[] controlZ = ControlBase.Controls.Find("Position:Z", false);

            NumericUpDown numControlX = (NumericUpDown)controlX[0];

            NumericUpDown numControlY = (NumericUpDown)controlY[0];

            NumericUpDown numControlZ = (NumericUpDown)controlZ[0];

            numControlX.Value = Convert.ToDecimal(pos.X);

            numControlY.Value = Convert.ToDecimal(pos.Y);

            numControlZ.Value = Convert.ToDecimal(pos.Z);
        }
        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 ReadSpecialProcess(List<ElementProperty> fields, List<Chunk> mainListReference)
        {
            ChunkListReference = mainListReference;

            List<ElementProperty> tempFieldStorage = new List<ElementProperty>();

            foreach (ElementProperty field in fields)
            {
                switch (field.Name)
                {
                    case "Bit Field":
                        if (BitField.Count > 0)
                        {
                            int fieldValue = (int)field.Data;

                            for (int i = 0; i < BitField.Count; i++)
                            {
                                ElementProperty prop = new ElementProperty();

                                int propValue = (fieldValue & BitField[i].Mask) >> BitField[i].BitShift;

                                prop.MakeProperty(BitField[i].Name, FieldType.Integer, (int)propValue);

                                tempFieldStorage.Add(prop);
                            }
                        }
                        break;
                    case "Waypoint List":
                        int firstPointOffset = Convert.ToInt32(fields.Find(x => x.Name == "First Waypoint Offset").Data);

                        int firstWaypointIndex = firstPointOffset / 0x10;

                        int numPoints = Convert.ToInt32(fields.Find(x => x.Name == "Number of Waypoints").Data);

                        List<Chunk> chunkRPPNList = (List<Chunk>)field.Data;

                        List<IGrouping<string, Chunk>> query = ChunkListReference.GroupBy(x => x.ChunkType, x => x).ToList();

                        List<Chunk> rPPN = query.Find(x => x.Key == "RPPN").ToList();

                        for (int i = 0; i < numPoints; i++)
                        {
                            chunkRPPNList.Add(rPPN[firstWaypointIndex + i]);
                        }

                        break;
                }
            }

            if (tempFieldStorage.Count > 0)
            {
                fields.InsertRange(fields.IndexOf(fields.Find(x => x.Name == "Bit Field")), tempFieldStorage);

                fields.RemoveAt(fields.IndexOf(fields.Find(x => x.Name == "Bit Field")));
            }

            if (ChunkID == "RPAT" || ChunkID == "PATH")
            {
                int numberPointsIndex = fields.IndexOf(fields.Find(x => x.Name == "Number of Waypoints"));

                using (FileStream stream = new FileStream("C:\\consoleoutput.txt", FileMode.Create))
                {
                    EndianBinaryWriter writer = new EndianBinaryWriter(stream, Endian.Big);

                    writer.Write("Number of Points Index: " + numberPointsIndex + Environment.NewLine);
                    writer.Write("Collection count: " + fields.Count + Environment.NewLine);
                }

                if ((numberPointsIndex >= 0) && (numberPointsIndex <= fields.Count - 1))
                    fields.RemoveAt(numberPointsIndex);

                int firstPointOffsetIndex = fields.IndexOf(fields.Find(x => x.Name == "First Waypoint Offset"));

                if ((firstPointOffsetIndex >= 0) && (firstPointOffsetIndex <= fields.Count - 1))
                    fields.RemoveAt(firstPointOffsetIndex);
            }
        }
 public void AddField(ElementProperty prop)
 {
     Fields.Add(prop);
 }
        public ElementProperty Copy()
        {
            ElementProperty copiedProp = new ElementProperty();

            copiedProp.Name = Name;

            copiedProp.Length = Length;

            copiedProp.Type = Type;

            copiedProp.Data = Data;

            return copiedProp;
        }