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 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; } }