public void ReadFromFile(BinaryReader reader) { if (reader.ReadInt16() != Magic) { return; } ushort animalInsCount = reader.ReadUInt16(); instances = new AnimalTrafficInstance[animalInsCount]; if (reader.ReadInt32() != Version) { return; } for (int i = 0; i < animalInsCount; i++) { AnimalTrafficInstance instance = new AnimalTrafficInstance(); instance.Name = new HashName(); instance.Name.ReadFromFile(reader); instances[i] = instance; } ushort pathCount = reader.ReadUInt16(); paths = new AnimalTrafficPath[pathCount]; for (int i = 0; i < pathCount; i++) { AnimalTrafficPath path = new AnimalTrafficPath(); byte pathSize = reader.ReadByte(); byte count1 = reader.ReadByte(); byte count2 = reader.ReadByte(); byte count3 = reader.ReadByte(); path.Data0 = reader.ReadBytes(count1); path.Data1 = reader.ReadBytes(count2); path.Data2 = reader.ReadBytes(count3); path.BoundingBox = BoundingBoxExtenders.ReadFromFile(reader); path.Hash = new HashName(); path.Hash.ReadFromFile(reader); //decompiled exe says this is a hash but its always empty path.Unk0 = reader.ReadSingle(); //5 path.Unk1 = reader.ReadSingle(); //15 path.Unk2 = reader.ReadByte(); //1 257 or 513. path.Unk3 = reader.ReadBytes(path.Unk2); path.Vectors = new PathVectors[pathSize]; for (int x = 0; x < pathSize; x++) { PathVectors vector = new PathVectors(); vector.Position = Vector3Utils.ReadFromFile(reader); //Very large differences between these two vector.Rotation = Vector3Utils.ReadFromFile(reader); //2nd one could be rotation, in radians. vector.Unk0 = reader.ReadByte(); //7 or 4 path.Vectors[x] = vector; } paths[i] = path; } }
public void WriteToFile() { using (BinaryWriter writer = new BinaryWriter(File.Open(file.FullName + "1", FileMode.Create))) { writer.Write((ushort)21569); //magic writer.Write((ushort)instances.Length); writer.Write(1595612873); for (int i = 0; i < instances.Length; i++) { instances[i].Name.WriteToFile(writer); } writer.Write((ushort)paths.Length); for (int i = 0; i < paths.Length; i++) { AnimalTrafficPath path = paths[i]; writer.Write(path.numPaths); writer.Write((byte)path.unkSet0.Length); writer.Write((byte)path.unkSet1.Length); writer.Write((byte)path.unkSet2.Length); writer.Write(path.unkSet0); writer.Write(path.unkSet1); writer.Write(path.unkSet2); BoundingBoxExtenders.WriteToFile(path.bbox, writer); path.unkHash.WriteToFile(writer); writer.Write(path.Unk0); writer.Write(path.Unk1); writer.Write(path.Unk2); for (int x = 0; x < path.numPaths; x++) { Vector3Extenders.WriteToFile(path.vectors[x].vectors[0], writer); Vector3Extenders.WriteToFile(path.vectors[x].vectors[1], writer); writer.Write(path.vectors[x].unk0); } if (path.Unk2 == 2) { writer.Write(path.unk3); } } } }
public void WriteToFile() { using (BinaryWriter writer = new BinaryWriter(File.Open(file.FullName + "1", FileMode.Create))) { writer.Write(Magic); //magic writer.Write((ushort)instances.Length); writer.Write(Version); for (int i = 0; i < instances.Length; i++) { instances[i].Name.WriteToFile(writer); } writer.Write((ushort)paths.Length); for (int i = 0; i < paths.Length; i++) { AnimalTrafficPath path = paths[i]; writer.Write((byte)path.Vectors.Length); writer.Write((byte)path.Data0.Length); writer.Write((byte)path.Data1.Length); writer.Write((byte)path.Data2.Length); writer.Write(path.Data0); writer.Write(path.Data1); writer.Write(path.Data2); BoundingBoxExtenders.WriteToFile(path.BoundingBox, writer); path.Hash.WriteToFile(writer); writer.Write(path.Unk0); writer.Write(path.Unk1); writer.Write(path.Unk2); writer.Write(path.Unk3); for (int x = 0; x < path.Vectors.Length; x++) { Vector3Utils.WriteToFile(path.Vectors[x].Position, writer); Vector3Utils.WriteToFile(path.Vectors[x].Rotation, writer); writer.Write(path.Vectors[x].Unk0); } } } }
public void ReadFromFile(BinaryReader reader) { if (reader.ReadInt16() != 21569) { return; } ushort animalInsCount = reader.ReadUInt16(); instances = new AnimalTrafficInstance[animalInsCount]; if (reader.ReadInt32() != 1595612873) { return; } for (int i = 0; i < animalInsCount; i++) { AnimalTrafficInstance instance = new AnimalTrafficInstance(); instance.Name = new Hash(); instance.Name.ReadFromFile(reader); instances[i] = instance; } ushort pathCount = reader.ReadUInt16(); paths = new AnimalTrafficPath[pathCount]; for (int i = 0; i < pathCount; i++) { AnimalTrafficPath path = new AnimalTrafficPath(); path.numPaths = reader.ReadByte(); byte count1 = reader.ReadByte(); byte count2 = reader.ReadByte(); byte count3 = reader.ReadByte(); path.unkSet0 = reader.ReadBytes(count1); path.unkSet1 = reader.ReadBytes(count2); path.unkSet2 = reader.ReadBytes(count3); path.bbox = BoundingBoxExtenders.ReadFromFile(reader); path.unkHash = new Hash(); path.unkHash.ReadFromFile(reader); //decompiled exe says this is a hash but its always empty path.Unk0 = reader.ReadSingle(); //5 path.Unk1 = reader.ReadSingle(); //15 path.Unk2 = reader.ReadInt16(); //1 257 or 513. path.vectors = new PathVectors[path.numPaths]; for (int x = 0; x < path.numPaths; x++) { PathVectors vector = new PathVectors(); vector.vectors = new Vector3[2]; vector.vectors[0] = Vector3Extenders.ReadFromFile(reader); //Very large differences between these two vector.vectors[1] = Vector3Extenders.ReadFromFile(reader); //2nd one could be rotation, in radians. vector.unk0 = reader.ReadByte(); //7 or 4 path.vectors[x] = vector; } if (path.Unk2 == 2) { path.unk3 = reader.ReadByte(); } paths[i] = path; } }