Пример #1
0
        public override void UpdateFromJSON(object data, FPackageFileSummary summary)
        {
            if (!Struct.GetType().IsArray)
            {
                SingleStruct(data, summary);
                return;
            }
            object[] array  = Struct as object[];
            object[] array2 = data as object[];
            object[] array3 = new object[array2.Length];
            if (UAsset.Options.Verbose && array.Length != array2.Length)
            {
                Console.WriteLine("Array size difference between base and JSON: " + base.Name?.Name + " -> " + StructName.Name);
            }
            VisitorFactory.StructVisitor value;
            bool flag = VisitorFactory.StructVisitors.TryGetValue(StructName.Name, out value);
            Type type = flag ? value.Target.GetType() : null;

            if (!flag && !UAsset.Options.ForceArrays)
            {
                return;
            }
            if (UAsset.Options.ForceArrays && UAsset.Options.Verbose)
            {
                Console.WriteLine("Forcing array " + base.Name?.Name + " -> " + StructName.Name + " with UObjects, integrity warning!");
            }
            base.Size = 0;
            for (int i = 0; i < array2.Length; i++)
            {
                if (flag)
                {
                    object obj = JsonConvert.DeserializeObject(array2[i].ToString(), type);
                    array3[i]  = (obj as IStructObject);
                    base.Size += (obj as IStructObject).GetSize();
                    continue;
                }
                JObject jObject = JObject.Parse(array2[i].ToString());
                List <KeyValuePair <string, object> > list = new List <KeyValuePair <string, object> >(jObject.Count - 1);
                string[] array4 = new string[jObject.Count - 1];
                foreach (JProperty item in jObject.Properties())
                {
                    if (item.Name != "UTTypes")
                    {
                        list.Add(new KeyValuePair <string, object>(item.Name, item.Value));
                    }
                    else
                    {
                        array4 = item.Value.ToString().Split(',').ToArray();
                    }
                }
                UObject uObject = new UObject();
                for (int j = 0; j < list.Count; j++)
                {
                    uObject.Add(JsonToProperty(list[j].Key, array4[j], list[j].Value, summary));
                }
                array3[i]  = uObject;
                base.Size += uObject.GetSize();
            }
            Struct = array3;
        }