Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// When overwritten, this function will write the prop
        /// </summary>
        /// <param name="s"></param>
        /// <param name="go"></param>
        /// <param name="f"></param>
        /// <param name="ms"></param>
        public virtual void WriteProp(DotArkSerializerInstance s, DotArkGameObject go, DotArkFile f, IOMemoryStream ms)
        {
            //Write the header data
            ms.WriteArkClassname(name, s);
            ms.WriteArkClassname(type, s);
            ms.WriteInt(size);
            ms.WriteInt(index);

            //Now, the overwritten function will run.
        }
Ejemplo n.º 3
0
        public override void WriteProp(DotArkSerializerInstance s, DotArkGameObject go, DotArkFile f, IOMemoryStream ms)
        {
            base.WriteProp(s, go, f, ms);

            //If the length is four, just write the objectID
            //TODO: Track the referenced GameObject so changing the index doesn't break this.
            if (size == 4)
            {
                ms.WriteInt(objectId);
            }
            else if (size >= 8)
            {
                //Write the type
                ms.WriteInt((int)objectRefType);

                //Depending on the type, write it
                if (objectRefType == ObjectPropertyType.TypeID)
                {
                    ms.WriteInt(objectId);
                }
                else if (objectRefType == ObjectPropertyType.TypePath)
                {
                    ms.WriteArkClassname(className, s);
                }
                else
                {
                    throw new Exception("Unknown type of ObjectProperty.");
                }
            }
            else
            {
                throw new Exception($"Unknown ObjectProperty length, {size}. Cannot write.");
            }
        }
Ejemplo n.º 4
0
        public override void WriteProp(DotArkSerializerInstance s, DotArkGameObject go, DotArkFile f, IOMemoryStream ms)
        {
            base.WriteProp(s, go, f, ms);

            //Get name table entry
            ms.WriteArkClassname((ArkClassName)data, s);
        }
Ejemplo n.º 5
0
        public override void WriteProp(DotArkSerializerInstance s, DotArkGameObject go, DotArkFile f, IOMemoryStream ms)
        {
            base.WriteProp(s, go, f, ms);

            //Write enum name
            ms.WriteArkClassname(enumName, s);

            //If this is a normal byte, write the byte value. Else, write the classname
            if (isNormalByte)
            {
                ms.ms.WriteByte(byteValue);
            }
            else
            {
                ms.WriteArkClassname(enumValue, s);
            }
        }
Ejemplo n.º 6
0
        public override void WriteProp(DotArkSerializerInstance s, DotArkGameObject go, DotArkFile f, IOMemoryStream ms)
        {
            base.WriteProp(s, go, f, ms);

            //Write the struct type
            ms.WriteArkClassname(structType, s);

            //Write the struct data.
            structData.WriteStruct(s, go, f, ms);
        }
Ejemplo n.º 7
0
        public override void WriteProp(DotArkSerializerInstance s, DotArkGameObject go, DotArkFile f, IOMemoryStream ms)
        {
            //For now, fake this and pretend this is an empty array
            //TODO: Add ArrayProperty to saveable properties.
            size = 4;

            base.WriteProp(s, go, f, ms);
            ms.WriteArkClassname(arrayType, s);
            ms.WriteInt(0);
        }
        static void WriteSingleGameObjectBody(IOMemoryStream ms, DotArkFile f, DotArkGameObject o, DotArkSerializerInstance si)
        {
            //Just start writing properties
            foreach (var prop in o.props)
            {
                prop.WriteProp(si, o, f, ms);
            }

            //Finally, write a None name to tell Ark that this is the end of the list of props.
            ms.WriteArkClassname(new ArkClassName
            {
                classname = "None",
                index     = 0
            }, si);
        }
Ejemplo n.º 9
0
        public override void WriteStruct(DotArkSerializerInstance s, DotArkGameObject go, DotArkFile f, IOMemoryStream ms)
        {
            //Write all of the props in the dict
            foreach (var p in props)
            {
                //Write property
                p.Value.WriteProp(s, go, f, ms);
            }

            //Finally, write a None type to stop Ark
            ms.WriteArkClassname(new ArkClassName
            {
                classname = "None",
                index     = 0
            }, s);
        }