예제 #1
0
        private void pathNodeSize_DropdownChanged(object sender, EventArgs e)
        {
            if (AllowChanges)
            {
                int selectedIndex = pathNodeSizeComboBox.SelectedIndex;

                Unreal.PropertyCollection props       = export.GetProperties();
                StructProperty            maxPathSize = props.GetProp <StructProperty>("MaxPathSize");
                if (maxPathSize != null)
                {
                    FloatProperty height = maxPathSize.GetProp <FloatProperty>("Height");
                    FloatProperty radius = maxPathSize.GetProp <FloatProperty>("Radius");
                    if (radius != null && height != null)
                    {
                        int radVal    = -1;
                        int heightVal = -1;

                        Point size = getDropdownSizePair(selectedIndex);
                        radVal    = size.X;
                        heightVal = size.Y;

                        long heightOffset = height.Offset;
                        long radiusOffset = radius.Offset;

                        //Manually write it to avoid property writing errors with cover stuff
                        byte[] data = export.Data;
                        WriteMem((int)heightOffset, data, BitConverter.GetBytes(Convert.ToSingle(heightVal)));
                        WriteMem((int)radiusOffset, data, BitConverter.GetBytes(Convert.ToSingle(radVal)));
                        export.Data = data;
                    }
                }
            }
        }
예제 #2
0
        private void reachspecSizeBox_Changed(object sender, EventArgs e)
        {
            int n = reachableNodesList.SelectedIndex;

            if (n < 0 || n >= reachSpecs.Count)
            {
                return;
            }

            if (AllowChanges)
            {
                int selectedIndex = reachSpecSizeSelector.SelectedIndex;

                IExportEntry reachSpec          = export.FileRef.Exports[reachSpecs[n]];
                Unreal.PropertyCollection props = reachSpec.GetProperties();

                IntProperty radius = props.GetProp <IntProperty>("CollisionRadius");
                IntProperty height = props.GetProp <IntProperty>("CollisionHeight");

                if (radius != null && height != null)
                {
                    int radVal    = -1;
                    int heightVal = -1;

                    Point size = getDropdownSizePair(selectedIndex);
                    radVal    = size.X;
                    heightVal = size.Y;

                    radius.Value = radVal;
                    height.Value = heightVal;
                    reachSpec.WriteProperties(props);
                    reachSpecSelection_Changed(null, null);
                }
            }
        }
예제 #3
0
        private void recalculateReachSpec(IExportEntry reachSpecExport, int calculatedProperDistance, float dirX, float dirY, float dirZ)
        {
            Unreal.PropertyCollection props = reachSpecExport.GetProperties();
            IntProperty    prop             = props.GetProp <IntProperty>("Distance");
            StructProperty directionProp    = props.GetProp <StructProperty>("Direction");
            FloatProperty  propX            = directionProp.GetProp <FloatProperty>("X");
            FloatProperty  propY            = directionProp.GetProp <FloatProperty>("Y");
            FloatProperty  propZ            = directionProp.GetProp <FloatProperty>("Z");

            prop.Value  = calculatedProperDistance;
            propX.Value = dirX;
            propY.Value = dirY;
            propZ.Value = dirZ;

            reachSpecExport.WriteProperties(props);
        }
예제 #4
0
        public ReachSpecCreatorForm(IMEPackage package, int sourceExportIndex)
        {
            InitializeComponent();
            specSizeCombobox.Items.Clear();
            specSizeCombobox.Items.AddRange(PathfindingNodeInfoPanel.getDropdownItems().ToArray());
            this.pcc          = package;
            this.sourceExport = pcc.Exports[sourceExportIndex];

            string sourceExportClass = sourceExport.ClassName;

            sourceNodeLabel.Text = "Export " + sourceExportIndex + " | " + sourceExportClass;

            //Get Source Location
            StructProperty locationProp = sourceExport.GetProperty <StructProperty>("location");

            Unreal.PropertyCollection nodelocprops = locationProp.Properties;
            //X offset is 0x20
            //Y offset is 0x24
            //Z offset is 0x28
            float sourceX = 0, sourceY = 0, sourceZ = 0;

            foreach (var locprop in nodelocprops)
            {
                switch (locprop.Name)
                {
                case "X":
                    sourceX = Convert.ToInt32((locprop as FloatProperty).Value);
                    break;

                case "Y":
                    sourceY = Convert.ToInt32((locprop as FloatProperty).Value);
                    break;

                case "Z":
                    sourceZ = Convert.ToInt32((locprop as FloatProperty).Value);
                    break;
                }
            }

            sourcePoint = new Point3D(sourceX, sourceY, sourceZ);
            reachSpecTypeComboBox.SelectedIndex = 0;
            specSizeCombobox.SelectedIndex      = 1;
            StartPosition = FormStartPosition.CenterParent;
        }
예제 #5
0
        private void reachSpecSelection_Changed(object sender, EventArgs e)
        {
            int n = reachableNodesList.SelectedIndex;

            if (n < 0 || n >= reachSpecs.Count)
            {
                reachSpecDestLabel.Text       = "No ReachSpec selected";
                reachSpecSizeLabel.Text       = "ReachSpec Size";
                connectionToLabel.Text        = "Connection to";
                reachSpecSizeSelector.Enabled = false;
                return;
            }

            AllowChanges = false;
            reachSpecSizeSelector.Enabled = true;

            IExportEntry reachSpec = export.FileRef.Exports[reachSpecs[n]];

            Unreal.PropertyCollection props = reachSpec.GetProperties();


            StructProperty outgoingEndStructProp = props.GetProp <StructProperty>("End");                              //Embeds END
            ObjectProperty outgoingSpecEndProp   = outgoingEndStructProp.Properties.GetProp <ObjectProperty>("Actor"); //END

            if (outgoingSpecEndProp.Value - 1 > 0)
            {
                IExportEntry endNode = export.FileRef.Exports[outgoingSpecEndProp.Value - 1];
                reachSpecDestLabel.Text = endNode.ObjectName + "_" + endNode.indexValue;
                connectionToLabel.Text  = "Connection to " + endNode.Index;
            }

            IntProperty radius = props.GetProp <IntProperty>("CollisionRadius");
            IntProperty height = props.GetProp <IntProperty>("CollisionHeight");

            if (radius != null && height != null)
            {
                reachSpecSizeLabel.Text = "ReachSpec Size: " + radius.Value + "x" + height.Value;

                reachSpecSizeSelector.SelectedIndex = findClosestNextSizeIndex(radius, height);
            }
            AllowChanges = true;
        }
예제 #6
0
        private void destinationNodeTextBox_TextChanged(object sender, EventArgs e)
        {
            int destIndex = -1;

            Int32.TryParse(destinationNodeTextBox.Text, out destIndex);
            if (destIndex >= 0 && destIndex < pcc.Exports.Count)
            {
                //Parse
                IExportEntry destExport = pcc.Exports[destIndex];

                float destX = 0, destY = 0, destZ = 0;

                StructProperty locationProp = destExport.GetProperty <StructProperty>("location");
                if (locationProp != null)
                {
                    Unreal.PropertyCollection nodelocprops = locationProp.Properties;
                    //X offset is 0x20
                    //Y offset is 0x24
                    //Z offset is 0x28
                    foreach (var locprop in nodelocprops)
                    {
                        switch (locprop.Name)
                        {
                        case "X":
                            destX = Convert.ToInt32((locprop as FloatProperty).Value);
                            break;

                        case "Y":
                            destY = Convert.ToInt32((locprop as FloatProperty).Value);
                            break;

                        case "Z":
                            destZ = Convert.ToInt32((locprop as FloatProperty).Value);
                            break;
                        }
                    }

                    Point3D destPoint = new Point3D(destX, destY, destZ);

                    double distance = sourcePoint.getDistanceToOtherPoint(destPoint);

                    //Calculate direction vectors
                    if (distance != 0)
                    {
                        float dirX = (float)((destPoint.X - sourcePoint.X) / distance);
                        float dirY = (float)((destPoint.Y - sourcePoint.Y) / distance);
                        float dirZ = (float)((destPoint.Z - sourcePoint.Z) / distance);


                        distanceLabel.Text = "Distance: " + distance.ToString("0.##");
                        directionX.Text    = "X: " + dirX.ToString("0.#####");
                        directionY.Text    = "Y: " + dirY.ToString("0.#####");
                        directionZ.Text    = "Z: " + dirZ.ToString("0.#####");

                        destinationLabel.Text = "| " + destExport.ClassName;

                        if ((string)reachSpecTypeComboBox.SelectedItem != "")
                        {
                            createSpecButton.Enabled = true;
                        }
                    }
                    else
                    {
                        float dirX = (float)((destPoint.X - sourcePoint.X) / distance);
                        float dirY = (float)((destPoint.Y - sourcePoint.Y) / distance);
                        float dirZ = (float)((destPoint.Z - sourcePoint.Z) / distance);


                        distanceLabel.Text = "Distance: 0 - move one of the nodes";
                        directionX.Text    = "X: N/A";
                        directionY.Text    = "Y: N/A";
                        directionZ.Text    = "Z: N/A";

                        destinationLabel.Text    = "| " + destExport.ClassName;
                        createSpecButton.Enabled = false;
                    }
                }
            }
            else
            {
                emptyAutoFields();
            }
        }