Exemplo n.º 1
0
        public static Olo Read(Stream stream)
        {
            Olo olo = new Olo();

            olo.header = BinaryMapping.ReadObject <Header>(stream);

            olo.ObjectList = new List <ObjectName>();
            stream.Seek(olo.header.SpawnObjectsOffset, SeekOrigin.Begin);
            for (int i = 0; i < olo.header.SpawnObjectsCount; i++)
            {
                olo.ObjectList.Add(BinaryMapping.ReadObject <ObjectName>(stream));
            }

            olo.FileList = new List <PathName>();
            stream.Seek(olo.header.FilePathOffset, SeekOrigin.Begin);
            for (int i = 0; i < olo.header.FilePathCount; i++)
            {
                olo.FileList.Add(BinaryMapping.ReadObject <PathName>(stream));
            }

            olo.ScriptList = new List <PathName>();
            stream.Seek(olo.header.ScriptPathOffset, SeekOrigin.Begin);
            for (int i = 0; i < olo.header.ScriptPathCount; i++)
            {
                olo.FileList.Add(BinaryMapping.ReadObject <PathName>(stream));
            }

            olo.MissionNameList = new List <ObjectName>();
            stream.Seek(olo.header.MissionNameOffset, SeekOrigin.Begin);
            for (int i = 0; i < olo.header.MissionNameCount; i++)
            {
                olo.MissionNameList.Add(BinaryMapping.ReadObject <ObjectName>(stream));
            }

            olo.TriggerList = new List <TriggerData>();
            stream.Seek(olo.header.TriggerDataOffset, SeekOrigin.Begin);
            for (int i = 0; i < olo.header.TriggerDataCount; i++)
            {
                olo.TriggerList.Add(BinaryMapping.ReadObject <TriggerData>(stream));
            }

            olo.GroupList = new List <GroupData>();
            stream.Seek(olo.header.GroupDataOffset, SeekOrigin.Begin);
            olo.LayoutList = new List <LayoutData>();
            for (int i = 0; i < olo.header.GroupDataCount; i++)
            {
                stream.Seek(olo.header.GroupDataOffset + (i * 0x30), SeekOrigin.Begin);
                GroupData data = BinaryMapping.ReadObject <GroupData>(stream);
                stream.Seek(data.ObjectLayoutDataOffset, SeekOrigin.Begin);

                for (int j = 0; j < data.ObjectLayoutDataCount; j++)
                {
                    olo.LayoutList.Add(BinaryMapping.ReadObject <LayoutData>(stream));
                }

                olo.GroupList.Add(data);
            }

            return(olo);
        }
Exemplo n.º 2
0
        public static void Write(Stream stream, Olo olo)
        {
            BinaryMapping.WriteObject <Header>(stream, olo.header);

            for (int i = 0; i < olo.header.SpawnObjectsCount; i++)
            {
                BinaryMapping.WriteObject <ObjectName>(stream, olo.ObjectList[i]);
            }

            for (int i = 0; i < olo.header.FilePathCount; i++)
            {
                BinaryMapping.WriteObject <PathName>(stream, olo.FileList[i]);
            }

            for (int i = 0; i < olo.header.ScriptPathCount; i++)
            {
                BinaryMapping.WriteObject <PathName>(stream, olo.ScriptList[i]);
            }

            for (int i = 0; i < olo.header.MissionNameCount; i++)
            {
                BinaryMapping.WriteObject <ObjectName>(stream, olo.MissionNameList[i]);
            }

            for (int i = 0; i < olo.header.TriggerDataCount; i++)
            {
                BinaryMapping.WriteObject <TriggerData>(stream, olo.TriggerList[i]);
            }

            for (int i = 0; i < olo.header.GroupDataCount; i++)
            {
                BinaryMapping.WriteObject <GroupData>(stream, olo.GroupList[i]);
            }

            for (int j = 0; j < olo.LayoutList.Count; j++)
            {
                BinaryMapping.WriteObject <LayoutData>(stream, olo.LayoutList[j]);
            }
        }