コード例 #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
ファイル: SplineNodes.cs プロジェクト: aquadran/ME3Explorer
        public SplinePoint0Node(int idx, float x, float y, IMEPackage p, PathingGraphEditor grapheditor)
            : base(idx, p, grapheditor)
        {
            string         s          = export.ObjectName;
            StructProperty splineInfo = export.GetProperty <StructProperty>("SplineInfo");

            if (splineInfo != null)
            {
                ArrayProperty <StructProperty> pointsProp = splineInfo.GetProp <ArrayProperty <StructProperty> >("Points");
                StructProperty point0 = pointsProp[0];
                StructProperty point1 = pointsProp[1];
                a    = PathfindingEditor.GetVector2(point0.GetProp <StructProperty>("OutVal"));
                tan1 = PathfindingEditor.GetVector2(point0.GetProp <StructProperty>("LeaveTangent"));
                tan2 = PathfindingEditor.GetVector2(point1.GetProp <StructProperty>("ArriveTangent"));
                d    = PathfindingEditor.GetVector2(point1.GetProp <StructProperty>("OutVal"));
                // = getType(s);
                float w = 25;
                float h = 25;
                shape          = PPath.CreateEllipse(0, 0, w, h);
                outlinePen     = new Pen(color);
                shape.Pen      = outlinePen;
                shape.Brush    = pathfindingNodeBrush;
                shape.Pickable = false;
                this.AddChild(shape);
                this.Bounds       = new RectangleF(0, 0, w, h);
                val               = new SText(export.Index + "\nSpline Start");
                val.Pickable      = false;
                val.TextAlignment = StringAlignment.Center;
                val.X             = w / 2 - val.Width / 2;
                val.Y             = h / 2 - val.Height / 2;
                this.AddChild(val);
                var props = export.GetProperties();
                this.TranslateBy(x, y);
            }
        }
コード例 #3
0
        /// <summary>
        /// Randomizes a tint.
        /// </summary>
        /// <param name="tint">A LinearColor struct (floatproperty values)</param>
        /// <param name="randomizeAlpha"></param>
        public static void RandomizeTint(StructProperty tint, bool randomizeAlpha, bool randomizeZeroValues = true)
        {
            var a = tint.GetProp <FloatProperty>("A");
            var r = tint.GetProp <FloatProperty>("R");
            var g = tint.GetProp <FloatProperty>("G");
            var b = tint.GetProp <FloatProperty>("B");

            float totalTintValue = r + g + b;

            if (!randomizeZeroValues && totalTintValue == 0)
            {
                return; // Don't randomize
            }
            //Randomizing hte pick order will ensure we get a random more-dominant first color (but only sometimes).
            //e.g. if e went in R G B order red would always have a chance at a higher value than the last picked item
            List <FloatProperty> randomOrderChooser = new List <FloatProperty>();

            randomOrderChooser.Add(r);
            randomOrderChooser.Add(g);
            randomOrderChooser.Add(b);
            randomOrderChooser.Shuffle();

            randomOrderChooser[0].Value = ThreadSafeRandom.NextFloat(0, totalTintValue);
            totalTintValue -= randomOrderChooser[0].Value;

            randomOrderChooser[1].Value = ThreadSafeRandom.NextFloat(0, totalTintValue);
            totalTintValue -= randomOrderChooser[1].Value;

            randomOrderChooser[2].Value = totalTintValue;
            if (randomizeAlpha)
            {
                a.Value = ThreadSafeRandom.NextFloat(0, 1);
            }
        }
コード例 #4
0
 internal static Point3D GetLocationFromVector(StructProperty vector)
 {
     return(new Point3D()
     {
         X = vector.GetProp <FloatProperty>("X"),
         Y = vector.GetProp <FloatProperty>("Y"),
         Z = vector.GetProp <FloatProperty>("Z")
     });
 }
コード例 #5
0
 public static CIVector3 FromStructProperty(StructProperty sp, string xKey, string yKey, string zKey)
 {
     return(new CIVector3()
     {
         X = sp.GetProp <IntProperty>(xKey),
         Y = sp.GetProp <IntProperty>(yKey),
         Z = sp.GetProp <IntProperty>(zKey)
     });
 }
コード例 #6
0
 /// <summary>
 /// Maps R => W, G => X, B => Y, A => Z
 /// </summary>
 /// <param name="getProp"></param>
 /// <returns></returns>
 public static CFVector4 FromLinearColorStructProperty(StructProperty getProp)
 {
     return(new CFVector4()
     {
         W = getProp.GetProp <FloatProperty>("R"),
         X = getProp.GetProp <FloatProperty>("G"),
         Y = getProp.GetProp <FloatProperty>("B"),
         Z = getProp.GetProp <FloatProperty>("A"),
     });
 }
コード例 #7
0
 public static ScalarParameter FromStruct(StructProperty sp)
 {
     return(new ScalarParameter
     {
         Property = sp,
         ParameterName = sp.GetProp <NameProperty>("ParameterName")?.Value,
         ParameterValue = sp.GetProp <FloatProperty>(sp.StructType == "SMAScalarParameter" ? "Parameter" : "ParameterValue").Value,
         Group = sp.GetProp <NameProperty>("Group")
     });
 }
コード例 #8
0
 public static VectorParameter FromStruct(StructProperty sp)
 {
     return(new VectorParameter
     {
         Property = sp,
         ParameterName = sp.GetProp <NameProperty>("ParameterName")?.Value,
         ParameterValue = RStructs.FromLinearColorStructProperty(sp.GetProp <StructProperty>(sp.StructType == "SMAVectorParameter" ? "Parameter" : "ParameterValue")),
         Group = sp.GetProp <NameProperty>("Group")
     });
 }
コード例 #9
0
        /// <summary>
        /// Converts struct property to SharpDX Vector 2
        /// </summary>
        /// <param name="vectorStruct">Vector Struct to convert</param>
        /// <returns></returns>
        public static Vector2 GetVector2(StructProperty vectorStruct)
        {
            Vector2 v = new Vector2
            {
                X = vectorStruct.GetProp <FloatProperty>("X"),
                Y = vectorStruct.GetProp <FloatProperty>("Y")
            };

            return(v);
        }
コード例 #10
0
 public static CVector4 FromStructProperty(StructProperty sp, string wKey, string xKey, string yKey, string zKey)
 {
     return(new CVector4()
     {
         W = sp.GetProp <FloatProperty>(wKey),
         X = sp.GetProp <FloatProperty>(xKey),
         Y = sp.GetProp <FloatProperty>(yKey),
         Z = sp.GetProp <FloatProperty>(zKey)
     });
 }
コード例 #11
0
 public static VectorTrackPoint FromStruct(StructProperty vtsp)
 {
     return(new VectorTrackPoint()
     {
         InVal = vtsp.GetProp <FloatProperty>("InVal"),
         OutVal = CFVector3.FromStructProperty(vtsp.GetProp <StructProperty>("OutVal"), "X", "Y", "Z"),
         ArriveTangent = CFVector3.FromStructProperty(vtsp.GetProp <StructProperty>("ArriveTangent"), "X", "Y", "Z"),
         LeaveTangent = CFVector3.FromStructProperty(vtsp.GetProp <StructProperty>("LeaveTangent"), "X", "Y", "Z"),
         InterpMode = Enum.Parse <EInterpCurveMode>(vtsp.GetProp <EnumProperty>("InterpMode").Value)
     });
 }
コード例 #12
0
        //internal static string ClassesDatabasePath = Path.Combine(App.ExecFolder, "pathfindingclassdb.json");

        /// <summary>
        /// Converts struct property to SharpDX Vector 3
        /// </summary>
        /// <param name="vectorStruct">Vector Struct to convert</param>
        /// <returns></returns>
        public static Vector3 GetVector3(StructProperty vectorStruct)
        {
            Vector3 v = new Vector3
            {
                X = vectorStruct.GetProp <FloatProperty>("X"),
                Y = vectorStruct.GetProp <FloatProperty>("Y"),
                Z = vectorStruct.GetProp <FloatProperty>("Z")
            };

            return(v);
        }
コード例 #13
0
        public UnrealGUID(StructProperty guid)
        {
            if (guid.StructType != "Guid")
            {
                throw new Exception("Can't parse non-guid struct with UnrealGUID");
            }

            A = guid.GetProp <IntProperty>("A");
            B = guid.GetProp <IntProperty>("B");
            C = guid.GetProp <IntProperty>("C");
            D = guid.GetProp <IntProperty>("D");
        }
コード例 #14
0
        public static Guid GetGuid(StructProperty guidProp)
        {
            int a  = guidProp.GetProp <IntProperty>("A");
            int b  = guidProp.GetProp <IntProperty>("B");
            int c  = guidProp.GetProp <IntProperty>("C");
            int d  = guidProp.GetProp <IntProperty>("D");
            var ms = new MemoryStream(16);

            ms.WriteInt32(a);
            ms.WriteInt32(b);
            ms.WriteInt32(c);
            ms.WriteInt32(d);
            return(new Guid(ms.ToArray()));
        }
コード例 #15
0
        /// <summary>
        /// Fetches an UnrealGUID object from a GUID struct.
        /// </summary>
        /// <param name="guidStruct"></param>
        /// <returns></returns>
        public static UnrealGUID GetGUIDFromStruct(StructProperty guidStruct)
        {
            int        a    = guidStruct.GetProp <IntProperty>("A");
            int        b    = guidStruct.GetProp <IntProperty>("B");
            int        c    = guidStruct.GetProp <IntProperty>("C");
            int        d    = guidStruct.GetProp <IntProperty>("D");
            UnrealGUID guid = new UnrealGUID();

            guid.A = a;
            guid.B = b;
            guid.C = c;
            guid.D = d;
            return(guid);
        }
コード例 #16
0
        public void SetShape()
        {
            if (shape != null)
            {
                RemoveChild(shape);
            }
            bool addVal = val == null;

            if (val == null)
            {
                val = new SText(index.ToString());

                if (Properties.Settings.Default.PathfindingEditorShowNodeSizes)
                {
                    StructProperty maxPathSize = export.GetProperty <StructProperty>("MaxPathSize");
                    if (maxPathSize != null)
                    {
                        float height = maxPathSize.GetProp <FloatProperty>("Height");
                        float radius = maxPathSize.GetProp <FloatProperty>("Radius");

                        if (radius >= 135)
                        {
                            val.Text += "\nBS";
                        }
                        else if (radius >= 90)
                        {
                            val.Text += "\nMB";
                        }
                        else
                        {
                            val.Text += "\nM";
                        }
                    }
                }
                val.Pickable      = false;
                val.TextAlignment = StringAlignment.Center;
            }
            outlinePen     = new Pen(GetDefaultShapeColor()); //Pen's can't be static and used in more than one place at a time.
            shape          = GetDefaultShape();
            shape.Pen      = Selected ? selectedPen : outlinePen;
            shape.Brush    = pathfindingNodeBrush;
            shape.Pickable = false;
            val.X          = 50f / 2 - val.Width / 2;
            val.Y          = 50f / 2 - val.Height / 2;
            AddChild(0, shape);
            if (addVal)
            {
                AddChild(val);
            }
        }
コード例 #17
0
        /// <summary>
        /// Generates a DistributionVector
        /// </summary>
        /// <param name="sp"></param>
        /// <returns></returns>
        public static DistributionVector FromStruct(StructProperty sp)
        {
            var lookupTable = sp.GetProp <ArrayProperty <FloatProperty> >("LookupTable");

            if (lookupTable != null && lookupTable.Count > 1)
            {
                float min = lookupTable[0];
                float max = lookupTable[1];

                int            index   = 2;
                List <Vector3> vectors = new List <Vector3>();
                while (index < lookupTable.Count)
                {
                    Vector3 v = new Vector3(lookupTable[index], lookupTable[index + 1], lookupTable[index + 2]);
                    vectors.Add(v);
                    index += 3;
                }

                DistributionVector dv = new DistributionVector
                {
                    HasLookupTable = true,
                    MinValue       = min,
                    MaxValue       = max,
                    Property       = sp,
                    PropertyName   = sp.Name.Name,
                    Vectors        = new ObservableCollectionExtended <Vector3>(vectors)
                };
                return(dv);
            }

            // ERROR
            return(null);
        }
コード例 #18
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);
        }
コード例 #19
0
        public static void GenerateNewRandomGUID(ExportEntry export)
        {
            StructProperty guidProp = export.GetProperty <StructProperty>("NavGuid");

            if (guidProp != null)
            {
                Random      rnd  = new Random();
                IntProperty A    = guidProp.GetProp <IntProperty>("A");
                IntProperty B    = guidProp.GetProp <IntProperty>("B");
                IntProperty C    = guidProp.GetProp <IntProperty>("C");
                IntProperty D    = guidProp.GetProp <IntProperty>("D");
                byte[]      data = export.Data;

                data.OverwriteRange((int)A.ValueOffset, BitConverter.GetBytes(rnd.Next()));
                data.OverwriteRange((int)B.ValueOffset, BitConverter.GetBytes(rnd.Next()));
                data.OverwriteRange((int)C.ValueOffset, BitConverter.GetBytes(rnd.Next()));
                data.OverwriteRange((int)D.ValueOffset, BitConverter.GetBytes(rnd.Next()));
                export.Data = data;
            }
        }
コード例 #20
0
        public static InterpCurve <T> FromStructProperty(StructProperty prop)
        {
            var result = new InterpCurve <T>();

            if (prop.GetProp <ArrayProperty <StructProperty> >("Points") is { } pointProps)
            {
                result.Points.AddRange(pointProps.Select(InterpCurvePoint <T> .FromStructProperty));
            }

            return(result);
        }
コード例 #21
0
        /// <summary>
        /// Randomizes the export. Does not check CanRandomize()
        /// </summary>
        /// <param name="export"></param>
        /// <param name="option"></param>
        private static void RandomizeInternal(ExportEntry export, RandomizationOption option)
        {
            var props = export.GetProperties();
            ArrayProperty <StructProperty> m_aMorphFeatures = props.GetProp <ArrayProperty <StructProperty> >("m_aMorphFeatures");

            if (m_aMorphFeatures != null)
            {
                foreach (StructProperty morphFeature in m_aMorphFeatures)
                {
                    FloatProperty offset = morphFeature.GetProp <FloatProperty>("Offset");
                    if (offset != null)
                    {
                        //Debug.WriteLine("Randomizing morph face " + Path.GetFilePath(export.FileRef.FilePath) + " " + export.UIndex + " " + export.FullPath + " offset");
                        offset.Value = offset.Value * ThreadSafeRandom.NextFloat(1 - (option.SliderValue / 3), 1 + (option.SliderValue / 3));
                    }
                }
            }

            ArrayProperty <StructProperty> m_aFinalSkeleton = props.GetProp <ArrayProperty <StructProperty> >("m_aFinalSkeleton");

            if (m_aFinalSkeleton != null)
            {
                foreach (StructProperty offsetBonePos in m_aFinalSkeleton)
                {
                    StructProperty vPos = offsetBonePos.GetProp <StructProperty>("vPos");
                    if (vPos != null)
                    {
                        //Debug.WriteLine("Randomizing morph face " + Path.GetFilePath(export.FileRef.FilePath) + " " + export.UIndex + " " + export.FullPath + " vPos");
                        FloatProperty x = vPos.GetProp <FloatProperty>("X");
                        FloatProperty y = vPos.GetProp <FloatProperty>("Y");
                        FloatProperty z = vPos.GetProp <FloatProperty>("Z");
                        x.Value = x.Value * ThreadSafeRandom.NextFloat(1 - option.SliderValue, 1 + option.SliderValue);
                        y.Value = y.Value * ThreadSafeRandom.NextFloat(1 - option.SliderValue, 1 + option.SliderValue);
                        z.Value = z.Value * ThreadSafeRandom.NextFloat(1 - (option.SliderValue / .85), 1 + (option.SliderValue / .85));
                    }
                }
            }

            export.WriteProperties(props);
        }
コード例 #22
0
        public static void RandomizeColor(StructProperty color, bool randomizeAlpha, double alphaMinMult = 1, double alphaMaxMult = 1)
        {
            var a = color.GetProp <ByteProperty>("A");
            var r = color.GetProp <ByteProperty>("R");
            var g = color.GetProp <ByteProperty>("G");
            var b = color.GetProp <ByteProperty>("B");

            int totalcolorValue = r.Value + g.Value + b.Value;

            if (totalcolorValue > 0)
            {
                //Randomizing hte pick order will ensure we get a random more-dominant first color (but only sometimes).
                //e.g. if e went in R G B order red would always have a chance at a higher value than the last picked item
                var randomOrderChooser = new List <ByteProperty>();
                randomOrderChooser.Add(r);
                randomOrderChooser.Add(g);
                randomOrderChooser.Add(b);
                randomOrderChooser.Shuffle();

                randomOrderChooser[0].Value = (byte)ThreadSafeRandom.Next(0, Math.Min(totalcolorValue, 256));
                totalcolorValue            -= randomOrderChooser[0].Value;

                randomOrderChooser[1].Value = (byte)ThreadSafeRandom.Next(0, Math.Min(totalcolorValue, 256));
                totalcolorValue            -= randomOrderChooser[1].Value;

                randomOrderChooser[2].Value = (byte)totalcolorValue;
                if (randomizeAlpha)
                {
                    if (alphaMaxMult != 1 && alphaMaxMult != 1)
                    {
                        a.Value = (byte)ThreadSafeRandom.Next(a.Value * (int)alphaMinMult, Math.Min(256, (int)(a.Value * alphaMaxMult)));
                    }
                    else
                    {
                        a.Value = (byte)ThreadSafeRandom.Next(0, 256);
                    }
                }
            }
        }
コード例 #23
0
        private static void randomizeBaseHead(StructProperty basehead, ExportEntry frontEnd, Dictionary <string, StructProperty> sliders)
        {
            var bhSettings = basehead.GetProp <ArrayProperty <StructProperty> >("m_fBaseHeadSettings");

            foreach (var baseSlider in bhSettings)
            {
                var sliderName = baseSlider.GetProp <StrProperty>("m_sSliderName");
                //is slider stepped?
                if (sliderName.Value == "Scar")
                {
                    baseSlider.GetProp <FloatProperty>("m_fValue").Value = 1;
                    continue;
                }
                var slider  = sliders[sliderName.Value];
                var notched = slider.GetProp <BoolProperty>("m_bNotched");
                var val     = baseSlider.GetProp <FloatProperty>("m_fValue");

                if (notched)
                {
                    //it's indexed
                    var maxIndex = slider.GetProp <IntProperty>("m_iSteps");
                    val.Value = ThreadSafeRandom.Next(maxIndex);
                }
                else
                {
                    //it's variable, we have to look up the m_fRange in the SliderMorph.
                    var sliderDatas = slider.GetProp <ArrayProperty <ObjectProperty> >("m_aoSliderData");
                    if (sliderDatas.Count == 1)
                    {
                        var slDataExport = frontEnd.FileRef.GetUExport(sliderDatas[0].Value);
                        var range        = slDataExport.GetProperty <FloatProperty>("m_fRange");
                        val.Value = ThreadSafeRandom.NextFloat(0, range * 100);
                    }
                    else
                    {
                        // This is just a guess
                        val.Value = ThreadSafeRandom.NextFloat(0, 1f);
                    }
                }
            }
        }
コード例 #24
0
        public void WriteIntoStruct(StructProperty existingStruct = null)
        {
            // We assume it already exists
            MinValue = Vectors.Min(x => x.MinValue());
            MaxValue = Vectors.Max(x => x.MaxValue());
            var tbl = new List <float> {
                MinValue, MaxValue
            };

            foreach (var v in Vectors)
            {
                tbl.Add(v.X);
                tbl.Add(v.Y);
                tbl.Add(v.Z);
            }

            if (existingStruct == null)
            {
                existingStruct = Property;
            }
            existingStruct.GetProp <ArrayProperty <FloatProperty> >("LookupTable").ReplaceAll(tbl.Select(x => new FloatProperty(x)));
        }
コード例 #25
0
        private void populateDuplicateGUIDs()
        {
            navGuidLists   = new Dictionary <string, List <UnrealGUID> >();
            duplicateGuids = new List <UnrealGUID>();

            IExportEntry level = null;

            foreach (IExportEntry exp in pcc.Exports)
            {
                if (exp.ClassName == "Level" && exp.ObjectName == "PersistentLevel")
                {
                    level = exp;
                    break;
                }
            }
            int start = 0x4;

            if (level != null)
            {
                start = PathfindingEditor.findEndOfProps(level);
            }
            //Read persistent level binary
            byte[] data = level.Data;

            uint exportid = BitConverter.ToUInt32(data, start);

            start += 4;
            uint numberofitems = BitConverter.ToUInt32(data, start);
            int  countoffset   = start;
            int  itemcount     = 2;

            start += 8;
            while (itemcount < numberofitems)
            {
                //get header.
                uint itemexportid = BitConverter.ToUInt32(data, start);
                if (itemexportid - 1 < pcc.Exports.Count && itemexportid > 0)
                {
                    IExportEntry   exportEntry = pcc.Exports[(int)itemexportid - 1];
                    StructProperty navguid     = exportEntry.GetProperty <StructProperty>("NavGuid");
                    if (navguid != null)
                    {
                        int        a   = navguid.GetProp <IntProperty>("A");
                        int        b   = navguid.GetProp <IntProperty>("B");
                        int        c   = navguid.GetProp <IntProperty>("C");
                        int        d   = navguid.GetProp <IntProperty>("D");
                        UnrealGUID nav = new UnrealGUID();
                        nav.A              = a;
                        nav.B              = b;
                        nav.C              = c;
                        nav.D              = d;
                        nav.export         = exportEntry;
                        nav.levelListIndex = itemcount;

                        List <UnrealGUID> list;
                        if (navGuidLists.TryGetValue(nav.ToString(), out list))
                        {
                            list.Add(nav);
                        }
                        else
                        {
                            list = new List <UnrealGUID>();
                            navGuidLists[nav.ToString()] = list;
                            list.Add(nav);
                        }
                    }
                    start += 4;
                    itemcount++;
                }
                else
                {
                    //INVALID or empty item encountered. We don't care right now though.
                    start += 4;
                    itemcount++;
                }
            }


            duplicatesListBox.Items.Clear();
            foreach (List <UnrealGUID> guidList in navGuidLists.Values)
            {
                if (guidList.Count > 1)
                {
                    Debug.WriteLine("Number of duplicates: " + guidList.Count);
                    //contains duplicates
                    foreach (UnrealGUID guid in guidList)
                    {
                        //Debug.WriteLine(guid.levelListIndex + " Duplicate: " + guid.export.ObjectName);
                        duplicateGuids.Add(guid);
                        duplicatesListBox.Items.Add(guid.levelListIndex + " " + guid.export.Index + " " + guid.export.ObjectName + "_" + guid.export.indexValue);
                    }
                }
                else
                {
                    Debug.WriteLine("Not a duplicate ");
                }
            }
        }
コード例 #26
0
 public Volume(StructProperty volumestruct)
 {
     ActorReference = new FGuid(volumestruct.GetProp <StructProperty>("Guid"));
     ActorUIndex    = volumestruct.GetProp <ObjectProperty>("Actor").Value;
 }
コード例 #27
0
        public static void CreateReachSpec(ExportEntry startNode, bool createTwoWay, ExportEntry destinationNode, string reachSpecClass, ReachSpecSize size, PropertyCollection externalGUIDProperties = null)
        {
            IMEPackage  Pcc = startNode.FileRef;
            ExportEntry reachSpectoClone = Pcc.Exports.FirstOrDefault(x => x.ClassName == "ReachSpec");

            if (externalGUIDProperties != null) //EXTERNAL
            {
                //external node

                //Debug.WriteLine("Num Exports: " + pcc.Exports.Count);
                if (reachSpectoClone != null)
                {
                    ExportEntry outgoingSpec = reachSpectoClone.Clone();
                    Pcc.addExport(outgoingSpec);

                    IEntry reachSpecClassImp = GetEntryOrAddImport(Pcc, reachSpecClass); //new class type.

                    outgoingSpec.idxClass      = reachSpecClassImp.UIndex;
                    outgoingSpec.idxObjectName = reachSpecClassImp.idxObjectName;

                    var            properties            = outgoingSpec.GetProperties();
                    ObjectProperty outgoingSpecStartProp = properties.GetProp <ObjectProperty>("Start");                                                                   //START
                    StructProperty outgoingEndStructProp = properties.GetProp <StructProperty>("End");                                                                     //Embeds END
                    ObjectProperty outgoingSpecEndProp   = outgoingEndStructProp.Properties.GetProp <ObjectProperty>(SharedPathfinding.GetReachSpecEndName(outgoingSpec)); //END
                    outgoingSpecStartProp.Value = startNode.UIndex;
                    outgoingSpecEndProp.Value   = 0;
                    var endGuid = outgoingEndStructProp.GetProp <StructProperty>("Guid");
                    endGuid.Properties = externalGUIDProperties; //set the other guid values to our guid values

                    //Add to source node prop
                    ArrayProperty <ObjectProperty> PathList = startNode.GetProperty <ArrayProperty <ObjectProperty> >("PathList");
                    PathList.Add(new ObjectProperty(outgoingSpec.UIndex));
                    startNode.WriteProperty(PathList);
                    outgoingSpec.WriteProperties(properties);


                    //Write Spec Size
                    SharedPathfinding.SetReachSpecSize(outgoingSpec, size.SpecRadius, size.SpecHeight);

                    //Reindex reachspecs.
                    SharedPathfinding.ReindexMatchingObjects(outgoingSpec);
                }
            }
            else
            {
                //Debug.WriteLine("Source Node: " + startNode.Index);

                //Debug.WriteLine("Num Exports: " + pcc.Exports.Count);
                //int outgoingSpec = pcc.ExportCount;
                //int incomingSpec = pcc.ExportCount + 1;


                if (reachSpectoClone != null)
                {
                    ExportEntry outgoingSpec = reachSpectoClone.Clone();
                    Pcc.addExport(outgoingSpec);
                    ExportEntry incomingSpec = null;
                    if (createTwoWay)
                    {
                        incomingSpec = reachSpectoClone.Clone();
                        Pcc.addExport(incomingSpec);
                    }

                    IEntry reachSpecClassImp = GetEntryOrAddImport(Pcc, reachSpecClass); //new class type.

                    outgoingSpec.idxClass      = reachSpecClassImp.UIndex;
                    outgoingSpec.idxObjectName = reachSpecClassImp.idxObjectName;

                    var outgoingSpecProperties = outgoingSpec.GetProperties();
                    if (reachSpecClass == "Engine.SlotToSlotReachSpec")
                    {
                        outgoingSpecProperties.Add(new ByteProperty(1, "SpecDirection")); //We might need to find a way to support this edit
                    }

                    //Debug.WriteLine("Outgoing UIndex: " + outgoingSpecExp.UIndex);

                    ObjectProperty outgoingSpecStartProp = outgoingSpecProperties.GetProp <ObjectProperty>("Start");                                                       //START
                    StructProperty outgoingEndStructProp = outgoingSpecProperties.GetProp <StructProperty>("End");                                                         //Embeds END
                    ObjectProperty outgoingSpecEndProp   = outgoingEndStructProp.Properties.GetProp <ObjectProperty>(SharedPathfinding.GetReachSpecEndName(outgoingSpec)); //END
                    outgoingSpecStartProp.Value = startNode.UIndex;
                    outgoingSpecEndProp.Value   = destinationNode.UIndex;

                    //Add to source node prop
                    var PathList = startNode.GetProperty <ArrayProperty <ObjectProperty> >("PathList");
                    PathList.Add(new ObjectProperty(outgoingSpec.UIndex));
                    startNode.WriteProperty(PathList);

                    //Write Spec Size
                    SetReachSpecSize(outgoingSpecProperties, size.SpecRadius, size.SpecHeight);
                    outgoingSpec.WriteProperties(outgoingSpecProperties);

                    if (createTwoWay)
                    {
                        incomingSpec.idxClass      = reachSpecClassImp.UIndex;
                        incomingSpec.idxObjectName = reachSpecClassImp.idxObjectName;
                        var incomingSpecProperties = incomingSpec.GetProperties();
                        if (reachSpecClass == "Engine.SlotToSlotReachSpec")
                        {
                            incomingSpecProperties.Add(new ByteProperty(2, "SpecDirection"));
                        }

                        ObjectProperty incomingSpecStartProp = incomingSpecProperties.GetProp <ObjectProperty>("Start");                                                       //START
                        StructProperty incomingEndStructProp = incomingSpecProperties.GetProp <StructProperty>("End");                                                         //Embeds END
                        ObjectProperty incomingSpecEndProp   = incomingEndStructProp.Properties.GetProp <ObjectProperty>(SharedPathfinding.GetReachSpecEndName(incomingSpec)); //END

                        incomingSpecStartProp.Value = destinationNode.UIndex;                                                                                                  //Uindex
                        incomingSpecEndProp.Value   = startNode.UIndex;


                        //Add reachspec to destination node's path list (returning)
                        var DestPathList = destinationNode.GetProperty <ArrayProperty <ObjectProperty> >("PathList");
                        DestPathList.Add(new ObjectProperty(incomingSpec.UIndex));
                        destinationNode.WriteProperty(DestPathList);

                        //destNode.WriteProperty(DestPathList);
                        SetReachSpecSize(incomingSpecProperties, size.SpecRadius, size.SpecHeight);

                        incomingSpec.WriteProperties(incomingSpecProperties);
                    }

                    //Reindex reachspecs.
                    SharedPathfinding.ReindexMatchingObjects(outgoingSpec);
                }
            }
        }
コード例 #28
0
 public static void SetLocation(StructProperty prop, float x, float y, float z)
 {
     prop.GetProp <FloatProperty>("X").Value = x;
     prop.GetProp <FloatProperty>("Y").Value = y;
     prop.GetProp <FloatProperty>("Z").Value = z;
 }
コード例 #29
0
        public static void SetRotation(StructProperty prop, float newDirectionDegrees)
        {
            int newYaw = (int)((newDirectionDegrees / 360) * 65535);

            prop.GetProp <IntProperty>("Yaw").Value = newYaw;
        }
コード例 #30
0
 public static void SetLocation(StructProperty prop, CFVector3 vector)
 {
     prop.GetProp <FloatProperty>("X").Value = vector.X;
     prop.GetProp <FloatProperty>("Y").Value = vector.Y;
     prop.GetProp <FloatProperty>("Z").Value = vector.Z;
 }