Example #1
0
        static void WriteHead(IOMemoryStream ms, DotArkFile f, DotArkSerializerInstance si, DotArkGameObject go, long propertyOffset)
        {
            //Write data according to https://us-central.assets-static-2.romanport.com/ark/#gameobject+base_header
            ms.WriteBytes(go.guid.ToByteArray());   //Write the GUID
            ms.WriteArkClassname(go.classname, si); //Write classname
            ms.WriteIntBool(go.isItem);

            //Write classname array
            ms.WriteInt(go.names.Count);
            foreach (var n in go.names)
            {
                ms.WriteArkClassname(n, si);
            }

            //Write unknowns
            ms.WriteIntBool(go.unknownData1);
            ms.WriteInt(go.unknownData2);

            //Write position data if it exists.
            ms.WriteIntBool(go.locationData != null);
            if (go.locationData != null)
            {
                ms.WriteLocationData(go.locationData);
            }

            //Write the offset to the properties data
            ms.WriteInt((int)propertyOffset);

            //Write last unknown data
            ms.WriteInt(go.unknownData3);
        }
        public static IOMemoryStream WriteEmbeddedBinaryDataArray(DotArkFile f, DotArkSerializerInstance si)
        {
            //I'm really not sure what this is. Spec: https://us-central.assets-static-2.romanport.com/ark/#embeded+binary+data_header

            //Open straem
            IOMemoryStream ms = new IOMemoryStream(true);

            //Get source data
            var s = f.meta.embededBinaryData;

            //Write number of blobs
            ms.WriteInt(s.Length);

            //Write each
            for (int i = 0; i < s.Length; i++)
            {
                var ss = s[i];

                //Write path
                ms.WriteUEString(ss.path);

                //Write number of parts
                ms.WriteInt(ss.data.Length);

                //Write parts
                for (int j = 0; j < ss.data.Length; j++)
                {
                    var ssb = ss.data[j];

                    //Write number of inner blobs
                    ms.WriteInt(ssb.Length);

                    //Write each inner blob
                    for (int n = 0; n < ssb.Length; n++)
                    {
                        var ssbb = ssb[i];
                        ms.WriteInt(ssbb.Length / 4);
                        ms.WriteBytes(ssbb);
                    }
                }
            }

            //Return stream
            return(ms);
        }