Exemplo n.º 1
0
        public void ReadBinary(ArkArchive archive, ReadingOptions options)
        {
            readBinaryHeader(archive);

            if (SaveVersion > 5)
            {
                // Name table is located after the objects block, but will be needed to read the objects block
                readBinaryNameTable(archive);
            }

            readBinaryDataFiles(archive, options);
            readBinaryEmbeddedData(archive, options);
            readBinaryDataFilesObjectMap(archive, options);
            readBinaryObjects(archive, options);
            readBinaryObjectProperties(archive, options);

            if (SaveVersion > 6)
            {
                readBinaryHibernation(archive, options);
            }



            //Now parse out cryo creature data
            foreach (var cryo in this.Objects.Where(x => x.ClassName.ToString().Contains("Cryop")).Where(x => x.HasAnyProperty("CustomItemDatas")).ToList())
            {
                var contents =
                    (((((cryo.GetTypedProperty <PropertyArray>("CustomItemDatas").Value as ArkArrayStruct).First() as
                        StructPropertyList).GetTypedProperty <PropertyStruct>("CustomDataBytes")
                       .Value as StructPropertyList).GetTypedProperty <PropertyArray>("ByteArrays")
                      .Value as ArkArrayStruct).First() as StructPropertyList)
                    .GetTypedProperty <PropertyArray>("Bytes")
                    .Value as ArkArrayInt8;

                var cryoStream = new System.IO.MemoryStream(contents.ToArray <Byte>());

                using (ArkArchive cryoArchive = new ArkArchive(cryoStream))
                {
                    cryoArchive.ReadBytes(4);
                    var dino         = new GameObject(cryoArchive);
                    var statusobject = new GameObject(cryoArchive);
                    dino.LoadProperties(cryoArchive, new GameObject(), 0);
                    statusobject.LoadProperties(cryoArchive, new GameObject(), 0);
                    dino.IsCryo = true;

                    addObject(dino, true);
                    addObject(statusobject, true);

                    //hack the id's so that the dino points to the appropriate dinostatuscomponent
                    var statusComponentRef = dino.GetTypedProperty <PropertyObject>("MyCharacterStatusComponent");
                    statusComponentRef.Value.ObjectId = statusobject.Id;
                }
            }


            OldNameList    = archive.HasUnknownNames? archive.NameTable: null;
            HasUnknownData = archive.HasUnknownData;
        }
Exemplo n.º 2
0
        public void ReadBinary(ArkArchive archive, ReadingOptions options)
        {
            readBinaryHeader(archive);

            if (SaveVersion > 5)
            {
                // Name table is located after the objects block, but will be needed to read the objects block
                readBinaryNameTable(archive);
            }

            readBinaryDataFiles(archive, options);
            readBinaryEmbeddedData(archive, options);
            readBinaryDataFilesObjectMap(archive, options);
            readBinaryObjects(archive, options);
            readBinaryObjectProperties(archive, options);

            if (SaveVersion > 6)
            {
                readBinaryHibernation(archive, options);
            }

            // Now parse cryo creature data
            foreach (GameObject cryo in Objects.Where(x => x.ClassName.ToString().Contains("Cryop")).ToList())
            {
                StructPropertyList customData      = cryo.GetPropertyValue <IArkArray, ArkArrayStruct>("CustomItemDatas")?.FirstOrDefault() as StructPropertyList;
                PropertyStruct     customDataBytes = customData?.Properties.FirstOrDefault(p => p.NameString == "CustomDataBytes") as PropertyStruct;
                PropertyArray      byteArrays      = (customDataBytes?.Value as StructPropertyList)?.Properties.FirstOrDefault(property => property.NameString == "ByteArrays") as PropertyArray;
                ArkArrayStruct     byteArraysValue = byteArrays?.Value as ArkArrayStruct;
                ArkArrayUInt8      creatureBytes   = ((byteArraysValue?[0] as StructPropertyList)?.Properties.FirstOrDefault(p => p.NameString == "Bytes") as PropertyArray)?.Value as ArkArrayUInt8;
                if (creatureBytes == null)
                {
                    continue;
                }

                MemoryStream cryoStream = new MemoryStream(creatureBytes.ToArray <byte>());

                using (ArkArchive cryoArchive = new ArkArchive(cryoStream)) {
                    cryoArchive.ReadBytes(4);
                    GameObject dino         = new GameObject(cryoArchive);
                    GameObject statusObject = new GameObject(cryoArchive);
                    dino.LoadProperties(cryoArchive, new GameObject(), 0);
                    statusObject.LoadProperties(cryoArchive, new GameObject(), 0);
                    dino.IsCryo = true;

                    addObject(dino, true);
                    addObject(statusObject, true);

                    //hack the id's so that the dino points to the appropriate dino status component
                    PropertyObject statusComponentRef = dino.GetTypedProperty <PropertyObject>("MyCharacterStatusComponent");
                    statusComponentRef.Value.ObjectId = statusObject.Id;
                }
            }

            OldNameList    = archive.HasUnknownNames ? archive.NameTable : null;
            HasUnknownData = archive.HasUnknownData;
        }