Ejemplo n.º 1
0
        public static FPropertyTag PropertyVisitor(BinaryReader reader, FPropertyTag baseTag, FPackageFileSummary summary)
        {
            UStructProperty uStructProperty = LSerializer.Deserialize <UStructProperty>(reader);

            uStructProperty.Ref(summary);
            uStructProperty.Struct = (((object)VisitorFactory.VisitStruct(reader, uStructProperty.StructName.Name, summary)) ?? ((object)new UObject(reader, summary, pad: false)));
            return(uStructProperty);
        }
Ejemplo n.º 2
0
        public override void UpdateFromJSON(object data, FPackageFileSummary summary)
        {
            if ((string)ArrayType == "StructProperty")
            {
                object[]        data2           = JsonConvert.DeserializeObject <object[][]>(data.ToString()).FirstOrDefault();
                object          obj             = Entries.First();
                UStructProperty uStructProperty = obj as UStructProperty;
                if (uStructProperty != null)
                {
                    uStructProperty.UpdateFromJSON(data2, summary);
                    ArraySize = ((!uStructProperty.Struct.GetType().IsArray) ? 1 : (uStructProperty.Struct as object[]).Length);
                    base.Size = uStructProperty.GetSize() + 4;
                }
                else if (obj is UObject)
                {
                    throw new NotImplementedException("Uobject as Array entry for StructProperty array not supported");
                }
                return;
            }
            object[] array = JsonConvert.DeserializeObject <object[]>(data.ToString());
            if (isFNameEntries && !UAsset.Options.ForceArrays)
            {
                return;
            }
            if (UAsset.Options.ForceArrays && UAsset.Options.ForceArrays)
            {
                Console.WriteLine("Forcefully updating array " + base.Name?.Name + " with name entries, integrity may suffer");
            }
            List <object> list = new List <object>();
            int           num  = 0;

            for (int i = 0; i < array.Length; i++)
            {
                object obj2 = null;
                switch ((string)ArrayType)
                {
                case "ByteProperty":
                case "NameProperty":
                case "EnumProperty":
                    obj2 = new FName();
                    (obj2 as FName).UpdateName(array[i].ToString(), summary);
                    num = 8;
                    break;

                case "IntProperty":
                    obj2 = Convert.ToInt32(array[i].ToString());
                    num  = 4;
                    break;

                case "UInt32Property":
                    obj2 = Convert.ToUInt32(array[i].ToString());
                    num  = 4;
                    break;

                case "FloatProperty":
                    obj2 = Convert.ToSingle(array[i].ToString());
                    num  = 4;
                    break;

                default:
                    throw new NotImplementedException($"No converter for {ArrayType}");
                }
                if (obj2 != null)
                {
                    list.Add(obj2);
                }
            }
            ArraySize = list.Count;
            base.Size = ArraySize * num + 4;
            Entries   = list;
        }