public override void Read(AssetBinaryReader reader, bool includeHeader, long leng1, long leng2 = 0)
        {
            if (includeHeader)
            {
                ArrayType    = reader.ReadFName();
                PropertyGuid = reader.ReadPropertyGuid();
            }

            int numEntries = reader.ReadInt32();

            if (ArrayType.Value.Value == "StructProperty" && ShouldSerializeStructsDifferently)
            {
                var results = new PropertyData[numEntries];

                FName name         = this.Name;
                long  structLength = 1;
                FName fullType     = new FName("Generic");
                Guid  structGUID   = new Guid();

                if (reader.Asset.EngineVersion >= UE4Version.VER_UE4_INNER_ARRAY_TAG_INFO)
                {
                    name = reader.ReadFName();
                    if (name.Value.Value.Equals("None"))
                    {
                        Value = results;
                        return;
                    }

                    FName thisArrayType = reader.ReadFName();
                    if (thisArrayType.Value.Value.Equals("None"))
                    {
                        Value = results;
                        return;
                    }

                    if (thisArrayType.Value.Value != ArrayType.Value.Value)
                    {
                        throw new FormatException("Invalid array type: " + thisArrayType.ToString() + " vs " + ArrayType.ToString());
                    }

                    structLength = reader.ReadInt64(); // length value
                    fullType     = reader.ReadFName();
                    structGUID   = new Guid(reader.ReadBytes(16));
                    reader.ReadPropertyGuid();
                }

                if (numEntries == 0)
                {
                    DummyStruct = new StructPropertyData(name, fullType)
                    {
                        StructGUID = structGUID
                    };
                }
                else
                {
                    for (int i = 0; i < numEntries; i++)
                    {
                        var data = new StructPropertyData(name, fullType);
                        data.Offset = reader.BaseStream.Position;
                        data.Read(reader, false, structLength);
                        data.StructGUID = structGUID;
                        results[i]      = data;
                    }
                    DummyStruct = (StructPropertyData)results[0];
                }
                Value = results;
            }
            else
            {
                var results = new PropertyData[numEntries];
                if (numEntries > 0)
                {
                    int averageSizeEstimate1 = (int)(leng1 / numEntries);
                    int averageSizeEstimate2 = (int)((leng1 - 4) / numEntries);
                    for (int i = 0; i < numEntries; i++)
                    {
                        results[i]        = MainSerializer.TypeToClass(ArrayType, new FName(i.ToString(), int.MinValue), reader.Asset);
                        results[i].Offset = reader.BaseStream.Position;
                        if (results[i] is StructPropertyData)
                        {
                            ((StructPropertyData)results[i]).StructType = new FName("Generic");
                        }
                        results[i].Read(reader, false, averageSizeEstimate1, averageSizeEstimate2);
                    }
                }
                Value = results;
            }
        }
        protected override void HandleCloned(PropertyData res)
        {
            UnknownPropertyData cloningProperty = (UnknownPropertyData)res;

            cloningProperty.SerializingPropertyType = (FName)SerializingPropertyType.Clone();
        }
 public ArrayPropertyData(FName name) : base(name)
 {
     Value = new PropertyData[0];
 }
 public ArrayPropertyData()
 {
     Value = new PropertyData[0];
 }
Exemple #5
0
        public override void Read(BinaryReader reader, bool includeHeader, long leng)
        {
            if (includeHeader)
            {
                ArrayType = Asset.GetHeaderReference((int)reader.ReadInt64());
                reader.ReadByte(); // null byte
            }

            int numEntries = reader.ReadInt32();

            if (ArrayType == "StructProperty")
            {
                var    results = new PropertyData[numEntries];
                string name    = Asset.GetHeaderReference((int)reader.ReadInt64());
                if (name.Equals("None"))
                {
                    Value = results;
                    return;
                }

                if (Asset.GetHeaderReference((int)reader.ReadInt64()) != ArrayType)
                {
                    throw new FormatException("Invalid array type");
                }
                reader.ReadInt64(); // length value

                string fullType   = Asset.GetHeaderReference((int)reader.ReadInt64());
                Guid   structGUID = new Guid(reader.ReadBytes(16));
                reader.ReadByte();

                if (numEntries == 0)
                {
                    DummyStruct = new StructPropertyData(name, Asset, fullType)
                    {
                        StructGUID = structGUID
                    };
                }
                else
                {
                    for (int i = 0; i < numEntries; i++)
                    {
                        var data = new StructPropertyData(name, Asset, fullType);
                        data.Read(reader, false, 0);
                        data.StructGUID = structGUID;
                        results[i]      = data;
                    }
                }
                Value = results;
            }
            else
            {
                var results = new PropertyData[numEntries];
                if (numEntries > 0)
                {
                    int averageSize = (int)(leng / numEntries);
                    for (int i = 0; i < numEntries; i++)
                    {
                        results[i] = MainSerializer.TypeToClass(ArrayType, Name, Asset);
                        results[i].Read(reader, false, averageSize);
                    }
                }
                Value = results;
            }
        }
Exemple #6
0
 public ArrayPropertyData()
 {
     Type  = "ArrayProperty";
     Value = new PropertyData[0];
 }
Exemple #7
0
 public ArrayPropertyData(string name, AssetReader asset) : base(name, asset)
 {
     Type  = "ArrayProperty";
     Value = new PropertyData[0];
 }
Exemple #8
0
 protected virtual void HandleCloned(PropertyData res)
 {
     // Child classes can implement this for custom cloning behavior
 }
        protected override void HandleCloned(PropertyData res)
        {
            EnumPropertyData cloningProperty = (EnumPropertyData)res;

            cloningProperty.EnumType = (FName)this.EnumType?.Clone();
        }