Beispiel #1
0
                public void WriteToFile(BinaryWriter writer)
                {
                    writer.Write(header.ToCharArray());
                    writer.Write(unk02);
                    writer.Write(unk03);
                    writer.Write(unk04);
                    writer.Write(unk05);
                    writer.Write(unk06);
                    writer.Write(unk07);
                    writer.Write(unk08);
                    writer.Write(unk09);
                    writer.Write(numEntities);

                    foreach (var Entity in entities)
                    {
                        writer.Write(126); //Header for types is 126.

                        long sizePosition = writer.BaseStream.Position;
                        writer.Write(-1);
                        writer.Write((int)Entity.GetEntityType());

                        using (MemoryStream stream = new MemoryStream())
                        {
                            // Write Entity to the Stream
                            CutsceneEntityFactory.WriteAnimEntityToFile(stream, Entity);
                            writer.Write(stream.ToArray());

                            // Update Size.
                            long currentPosition = writer.BaseStream.Position;
                            writer.BaseStream.Seek(sizePosition, SeekOrigin.Begin);
                            writer.Write((uint)stream.Length + 12);
                            writer.BaseStream.Seek(currentPosition, SeekOrigin.Begin);
                        }
                    }

                    foreach (var Entity in entities)
                    {
                        using (MemoryStream EntityStream = new MemoryStream())
                        {
                            bool isBigEndian = false;
                            Entity.AnimEntityData.WriteToFile(EntityStream, isBigEndian);

                            EntityStream.Seek(4, SeekOrigin.Begin);
                            EntityStream.Write((uint)EntityStream.Length, isBigEndian);
                            EntityStream.Seek(0, SeekOrigin.End);

                            writer.Write(EntityStream.ToArray());
                        }
                    }

                    writer.Write(unk10);
                    writer.Write(unk11);
                    writer.Write(unk12);
                    writer.Write(unk13);
                    writer.Write(unk14);
                }
Beispiel #2
0
                public void WriteToFile(BinaryWriter Writer)
                {
                    Writer.Write(1000); // Magic
                    long SPDSizePosition = Writer.BaseStream.Position;

                    Writer.Write(Size);
                    Writer.Write(0x21445053);
                    Writer.Write(Unk01);
                    Writer.Write(Unk02);
                    Writer.Write(EntityDefinitions.Length);

                    foreach (var Entity in EntityDefinitions)
                    {
                        Writer.Write(126); //Header for types is 126.

                        long sizePosition = Writer.BaseStream.Position;
                        Writer.Write(-1);
                        Writer.Write((int)Entity.GetEntityType());

                        using (MemoryStream EntityStream = new MemoryStream())
                        {
                            CutsceneEntityFactory.WriteAnimEntityToFile(EntityStream, Entity);
                            Writer.Write(EntityStream.ToArray());

                            long currentPosition = Writer.BaseStream.Position;
                            Writer.BaseStream.Seek(sizePosition, SeekOrigin.Begin);
                            Writer.Write((uint)EntityStream.Length + 12);
                            Writer.BaseStream.Seek(currentPosition, SeekOrigin.Begin);
                        }
                    }

                    foreach (var Entity in EntityDefinitions)
                    {
                        using (MemoryStream EntityStream = new MemoryStream())
                        {
                            bool isBigEndian = false;
                            Entity.AnimEntityData.WriteToFile(EntityStream, isBigEndian);

                            EntityStream.Seek(4, SeekOrigin.Begin);
                            EntityStream.Write((uint)EntityStream.Length, isBigEndian);
                            EntityStream.Seek(0, SeekOrigin.End);

                            Writer.Write(EntityStream.ToArray());
                        }
                    }

                    Writer.Seek((int)SPDSizePosition, SeekOrigin.Begin);
                    uint SPDSize = (uint)(Writer.BaseStream.Length - SPDSizePosition) + 4;

                    Writer.Write(SPDSize);
                    Writer.Seek(0, SeekOrigin.End);
                }