Example #1
0
        public static void SetLocation(ExportEntry export, float x, float y, float z)
        {
            StructProperty prop = export.GetProperty <StructProperty>("location");

            SetLocation(prop, x, y, z);
            export.WriteProperty(prop);
        }
Example #2
0
        public Header(StructProperty displayStyle, string assetFolder) : this()
        {
            if (displayStyle.Value is UObject o)
            {
                if (!Properties.Settings.Default.UseChallengeBanner && o.TryGetValue(out var c1, "PrimaryColor", "Context_LimitedTimeColor") && c1 is StructProperty s1 && s1.Value is FLinearColor primaryColor)
                {
                    PrimaryColor = SKColor.Parse(primaryColor.Hex);
                }
                if (!Properties.Settings.Default.UseChallengeBanner && o.TryGetValue(out var c2, "SecondaryColor", "Context_BaseColor") && c2 is StructProperty s2 && s2.Value is FLinearColor secondaryColor)
                {
                    SecondaryColor = SKColor.Parse(secondaryColor.Hex);
                }
                if (!Properties.Settings.Default.UseChallengeBanner && o.TryGetValue("AccentColor", out var c3) && c3 is StructProperty s3 && s3.Value is FLinearColor accentColor)
                {
                    AccentColor = SKColor.Parse(accentColor.Hex);
                    if (SecondaryColor.Red + SecondaryColor.Green + SecondaryColor.Blue <= 75 || assetFolder.Equals("LTM", StringComparison.CurrentCultureIgnoreCase)) // if secondary is too dark
                    {
                        SecondaryColor = AccentColor;                                                                                                                  // use accent and pray for accent to be ligher
                    }
                }

                if (o.TryGetValue("DisplayImage", out var i) && i is SoftObjectProperty displayImage)
                {
                    DisplayImage = Utils.GetSoftObjectTexture(displayImage);
                }
                if (CustomBackground == null && o.TryGetValue("CustomBackground", out var b) && b is SoftObjectProperty customBackground)
                {
                    CustomBackground = Utils.GetSoftObjectTexture(customBackground);
                }
            }
        }
 public override void ReadStruct(IOMemoryStream ms, UAssetFile f, StructProperty s)
 {
     r = ms.ReadFloat();
     g = ms.ReadFloat();
     b = ms.ReadFloat();
     a = ms.ReadFloat();
 }
Example #4
0
        public CProperty GetProperty()
        {
            // First, read the length and value of the following property name string
            int    propNameLength = GetInt();
            string propName       = GetString(propNameLength);

            SkipPadding();

            // If this is a "None" ending type property, just return - nothing else will follow this
            if (propName == "None")
            {
                return(null);
            }

            // Get the property type string
            int    typeNameLength = GetInt();
            string typeName       = GetString(typeNameLength);

            SkipPadding();

            // Skip past the size of the following data and its padding
            GetInt();
            SkipPadding();

            // Finally, read the data based on the property type
            CProperty returnProperty;

            switch (typeName)
            {
            case "ArrayProperty":
                returnProperty = new ArrayProperty(propName, this);
                break;

            case "IntProperty":
                returnProperty = new IntProperty(propName, this);
                break;

            case "StrProperty":
                returnProperty = new StrProperty(propName, this);
                break;

            case "NameProperty":
                returnProperty = new NameProperty(propName, this);
                break;

            case "StructProperty":
                returnProperty = new StructProperty(propName, this, _outputter);
                break;

            case "BoolProperty":
                returnProperty = new BoolProperty(propName, this);
                break;

            default:
                throw new Exception($"Unexpected property type: {typeName}");
            }

            returnProperty.ParseData();
            return(returnProperty);
        }
Example #5
0
 public override void ReadStruct(IOMemoryStream ms, UAssetFile f, StructProperty s)
 {
     x = ms.ReadFloat();
     y = ms.ReadFloat();
     z = ms.ReadFloat();
     w = ms.ReadFloat();
 }
Example #6
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;
                    }
                }
            }
        }
Example #7
0
        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);
            }
        }
        /// <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);
            }
        }
Example #9
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);
        }
Example #10
0
        public override void LoadTrack()
        {
            Keys.ClearEx();
            var lookupstruct = Export.GetProperty <StructProperty>("LookupTrack");

            if (lookupstruct != null)
            {
                var trackKeys = lookupstruct.GetProp <ArrayProperty <StructProperty> >("Points"); //on lookuptrack

                var posTrack = Export.GetProperty <StructProperty>("PosTrack");
                ArrayProperty <StructProperty> points = posTrack?.GetProp <ArrayProperty <StructProperty> >("Points");
                if (trackKeys != null)
                {
                    int keyindex = 0;
                    foreach (var trackKey in trackKeys)
                    {
                        string tooltip = null;
                        if (points != null && points.Count > keyindex)
                        {
                            StructProperty vector = points[keyindex].GetProp <StructProperty>("OutVal");
                            var            point  = SharedPathfinding.GetLocationFromVector(vector);
                            tooltip = $"X={point.X},Y={point.Y},Z={point.Z}";
                        }

                        var time = trackKey.GetProp <FloatProperty>("Time");
                        Debug.WriteLine(time.Value);
                        Keys.Add(new Key(time, tooltip));
                        keyindex++;
                    }
                }
            }
        }
Example #11
0
 public override void ReadStruct(IOMemoryStream ms, UAssetFile f, StructProperty s)
 {
     b = ms.ReadByte();
     g = ms.ReadByte();
     r = ms.ReadByte();
     a = ms.ReadByte();
 }
Example #12
0
        public static void GetGameplayTags(BaseIcon icon, StructProperty s, string exportType)
        {
            if (s.Value is FGameplayTagContainer g)
            {
                if (g.GameplayTags.TryGetGameplayTag("Cosmetics.Source.", out var source))
                {
                    icon.CosmeticSource = source.String.Substring("Cosmetics.Source.".Length);
                }
                else if (g.GameplayTags.TryGetGameplayTag("Athena.ItemAction.", out var action))
                {
                    icon.CosmeticSource = action.String.Substring("Athena.ItemAction.".Length);
                }

                if (g.GameplayTags.TryGetGameplayTag("Cosmetics.Set.", out var set))
                {
                    icon.Description += GetCosmeticSet(set.String);
                }
                if (g.GameplayTags.TryGetGameplayTag("Cosmetics.Filter.Season.", out var season))
                {
                    icon.Description += GetCosmeticSeason(season.String);
                }

                UserFacingFlag.GetUserFacingFlags(
                    g.GameplayTags.GetAllGameplayTag("Cosmetics.UserFacingFlags.", "Homebase.Class.", "NPC.CharacterType.Survivor.Defender."),
                    icon, exportType);
            }
        }
        public static void SetLocation(ExportEntry export, CFVector3 location)
        {
            StructProperty prop = export.GetProperty <StructProperty>("location");

            SetLocation(prop, location);
            export.WriteProperty(prop);
        }
Example #14
0
 public static void GetPreviewImage(BaseIcon icon, StructProperty u)
 {
     if (u.Value is UObject o && o.TryGetValue("ResourceObject", out var v) && v is ObjectProperty resourceObject)
     {
         icon.IconImage = Utils.GetObjectTexture(resourceObject);
     }
 }
Example #15
0
 public override void ReadStruct(IOMemoryStream ms, UAssetFile f, StructProperty s)
 {
     ms.ReadInt();
     ms.ReadInt();
     ms.ReadInt();
     ms.ReadInt();
 }
Example #16
0
 private bool InventoryEmpty(SaveComponent inventoryComponent)
 {
     for (int i = 0; i < inventoryComponent.DataFields.Count; i++)
     {
         if (inventoryComponent.DataFields[i].PropertyName == "mInventoryStacks")
         {
             ArrayProperty inventoryArray = (ArrayProperty)inventoryComponent.DataFields[i];
             for (int j = 0; j < ((ArrayProperty)inventoryComponent.DataFields[i]).Elements.Count; j++)
             {
                 StructProperty    inventoryStruct = (StructProperty)inventoryArray.Elements[j];
                 DynamicStructData inventoryItem   = (DynamicStructData)inventoryStruct.Data;
                 for (int k = 0; k < inventoryItem.Fields.Count; k++)
                 {
                     if (inventoryItem.Fields[k].PropertyName == "NumItems")
                     {
                         IntProperty itemCount = (IntProperty)inventoryItem.Fields[k];
                         if (itemCount.Value != 0)
                         {
                             return(false);
                         }
                     }
                 }
             }
             return(true);
         }
     }
     return(true);
 }
Example #17
0
        public void OnStructChangedTest()
        {
            bool isCalled = false;

            var factory = new PropertyFactory();
            var prop    = new StructProperty(typeof(MyStruct), factory);
            var vm      = new StructViewModel(prop, new ViewModelFactory(factory, false));

            vm.OnChanged.Subscribe(x => isCalled = true);

            var memberY = vm.Members.OfType <IntViewModel>()
                          .Where(x => x.Property.PropertyInfo.Name == nameof(MyStruct.Y))
                          .First();

            memberY.IntValue.Value = 99;
            isCalled.IsTrue();

            isCalled = false;
            var memberZ = vm.Members.OfType <IntViewModel>()
                          .Where(x => x.Property.PropertyInfo.Name == nameof(MyStruct.Y))
                          .First();

            memberZ.IntValue.Value = 81;
            isCalled.IsTrue();
        }
        public static bool RandomizeExport(ExportEntry export, RandomizationOption option)
        {
            if (!CanRandomize(export))
            {
                return(false);
            }
            //Log.Information($@"Randomizing light {export.UIndex}");
            var lc = export.GetProperty <StructProperty>("LightColor");

            if (lc == null)
            {
                // create
                var pc = new PropertyCollection();
                pc.Add(new ByteProperty(255, "B"));
                pc.Add(new ByteProperty(255, "G"));
                pc.Add(new ByteProperty(255, "R"));
                pc.Add(new ByteProperty(0, "A"));

                lc = new StructProperty("Color", pc, "LightColor", true);
            }

            RStructs.RandomizeColor(lc, false);
            export.WriteProperty(lc);
            return(true);
        }
Example #19
0
        public void StructPropertyTest()
        {
            var property = new StructProperty(typeof(TestStruct), new PropertyFactory());

            property.Members.Length.Is(1);
            property.Members[0].IsInstanceOf <BoolProperty>();
        }
Example #20
0
        private static List <string> relinkPropertiesRecursive(IMEPackage importingPCC, ExportEntry relinkingExport, PropertyCollection transplantProps,
                                                               OrderedMultiValueDictionary <IEntry, IEntry> crossPCCObjectMappingList, string prefix,
                                                               bool importExportDependencies = false)
        {
            var relinkResults = new List <string>();

            foreach (UProperty prop in transplantProps)
            {
                //Debug.WriteLine($"{prefix} Relink recursive on {prop.Name}");
                if (prop is StructProperty structProperty)
                {
                    relinkResults.AddRange(relinkPropertiesRecursive(importingPCC, relinkingExport, structProperty.Properties, crossPCCObjectMappingList,
                                                                     $"{prefix}{structProperty.Name}.", importExportDependencies));
                }
                else if (prop is ArrayProperty <StructProperty> structArrayProp)
                {
                    for (int i = 0; i < structArrayProp.Count; i++)
                    {
                        StructProperty arrayStructProperty = structArrayProp[i];
                        relinkResults.AddRange(relinkPropertiesRecursive(importingPCC, relinkingExport, arrayStructProperty.Properties, crossPCCObjectMappingList,
                                                                         $"{prefix}{arrayStructProperty.Name}[{i}].", importExportDependencies));
                    }
                }
                else if (prop is ArrayProperty <ObjectProperty> objArrayProp)
                {
                    foreach (ObjectProperty objProperty in objArrayProp)
                    {
                        int    uIndex = objProperty.Value;
                        string result = relinkUIndex(importingPCC, relinkingExport, ref uIndex, objProperty.Name, crossPCCObjectMappingList, prefix, importExportDependencies);
                        objProperty.Value = uIndex;
                        if (result != null)
                        {
                            relinkResults.Add(result);
                        }
                    }
                }
                else if (prop is ObjectProperty objectProperty)
                {
                    int    uIndex = objectProperty.Value;
                    string result = relinkUIndex(importingPCC, relinkingExport, ref uIndex, objectProperty.Name, crossPCCObjectMappingList, prefix, importExportDependencies);
                    objectProperty.Value = uIndex;
                    if (result != null)
                    {
                        relinkResults.Add(result);
                    }
                }
                else if (prop is DelegateProperty delegateProp)
                {
                    int    uIndex = delegateProp.Value.Object;
                    string result = relinkUIndex(importingPCC, relinkingExport, ref uIndex, delegateProp.Name, crossPCCObjectMappingList, prefix, importExportDependencies);
                    delegateProp.Value = new ScriptDelegate(uIndex, delegateProp.Value.FunctionName);
                    if (result != null)
                    {
                        relinkResults.Add(result);
                    }
                }
            }
            return(relinkResults);
        }
Example #21
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)
     });
 }
Example #22
0
        public static void GenerateNewNavGUID(ExportEntry export)
        {
            StructProperty guidProp = export.GetProperty <StructProperty>("NavGuid");

            if (guidProp != null)
            {
                export.WriteProperty(CommonStructs.GuidProp(Guid.NewGuid(), "NavGuid"));
            }
        }
Example #23
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")
     });
 }
Example #24
0
        public static XElement ToXml(this StructProperty property)
        {
            var elem = new XElement(
                EventManifestSchema.Namespace + "struct",
                new XAttribute("name", property.Name));

            elem.Add(property.Properties.Select(ToXml));
            return(elem);
        }
Example #25
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)
     });
 }
 /// <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"),
     });
 }
 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")
     });
 }
Example #28
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);
        }
 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")
     });
 }
Example #30
0
        public static StructProperty CreateAppearanceProperty()
        {
            var props = new CProperty[]
            {
                NameProperty.Create("nmHead"),
                IntProperty.Create("iGender", 1),
                IntProperty.Create("iRace"),
                NameProperty.Create("nmHaircut"),
                IntProperty.Create("iHairColor"),
                IntProperty.Create("iFacialHair"),
                NameProperty.Create("nmBeard"),
                IntProperty.Create("iSkinColor"),
                IntProperty.Create("iEyeColor"),
                NameProperty.Create("nmFlag"),
                IntProperty.Create("iVoice"),
                IntProperty.Create("iAttitude"),
                IntProperty.Create("iArmorDeco"),
                IntProperty.Create("iArmorTint"),
                IntProperty.Create("iArmorTintSecondary"),
                IntProperty.Create("iWeaponTint"),
                IntProperty.Create("iTattooTint"),
                NameProperty.Create("nmWeaponPattern"),
                NameProperty.Create("nmPawn", "None"),
                NameProperty.Create("nmTorso"),
                NameProperty.Create("nmArms"),
                NameProperty.Create("nmLegs"),
                NameProperty.Create("nmHelmet"),
                NameProperty.Create("nmEye", "DefaultEyes"),
                NameProperty.Create("nmTeeth", "DefaultTeeth"),
                NameProperty.Create("nmFacePropLower"),
                NameProperty.Create("nmFacePropUpper"),
                NameProperty.Create("nmPatterns"),
                NameProperty.Create("nmVoice"),
                NameProperty.Create("nmLanguage", "None"),
                NameProperty.Create("nmTattoo_LeftArm"),
                NameProperty.Create("nmTattoo_RightArm"),
                NameProperty.Create("nmScars"),
                NameProperty.Create("nmTorso_Underlay"),
                NameProperty.Create("nmArms_Underlay"),
                NameProperty.Create("nmLegs_Underlay"),
                NameProperty.Create("nmFacePaint"),
                NameProperty.Create("nmLeftArm"),
                NameProperty.Create("nmRightArm"),
                NameProperty.Create("nmLeftArmDeco"),
                NameProperty.Create("nmRightArmDeco"),
                NameProperty.Create("nmLeftForearm"),
                NameProperty.Create("nmRightForearm"),
                NameProperty.Create("nmThighs"),
                NameProperty.Create("nmShins", "None"),
                NameProperty.Create("nmTorsoDeco")
            };
            var structProp = StructProperty.Create("kAppearance", props);

            return(structProp);
        }