//MapData can be gathered from Tethealla. xx_xx_o.dat contains the variant object data. //TODO: Support multiple types. Only does object right now static void Main(string[] args) { Console.WriteLine("Enter Filename:"); string fileName = Console.ReadLine(); SerializerService serializer = new SerializerService(); serializer.RegisterType <MapDatFormatGenericBodyModel <MapDataFormatObjectEntry> >(); serializer.Compile(); byte[] bytes = File.ReadAllBytes(fileName); int count = bytes.Length / 68; //TODO: Find a way to deal with count without having to do this bytes = count.Reinterpret().Concat(bytes).ToArray(); Console.WriteLine("Deserializing."); MapDatFormatGenericBodyModel <MapDataFormatObjectEntry> model = serializer.Deserialize <MapDatFormatGenericBodyModel <MapDataFormatObjectEntry> >(bytes); Console.WriteLine("Done Deserializing."); List <string> linesToWrite = new List <string>(count); int index = 0; foreach (var m in model) { string log = $"Index: {index} {m.ToString()}"; Console.WriteLine(log); linesToWrite.Add(log); index++; } File.WriteAllLines($"{Path.GetFileNameWithoutExtension(fileName)}_out.txt", linesToWrite); Console.WriteLine("Press any key to close..."); Console.ReadKey(); }
public MapDatFormatGenericBodyModel <MapDataFormatObjectEntry> LoadObjects(string path) { if (string.IsNullOrWhiteSpace(path)) { throw new ArgumentException("Value cannot be null or whitespace.", nameof(path)); } TextAsset map = Resources.Load <TextAsset>(Path.ChangeExtension(path, null)); if (map == null) { throw new InvalidOperationException($"Unable load map from resources Path: {path}"); } //TODO: Redo sizing MapDatFormatGenericBodyModel <MapDataFormatObjectEntry> entries = Serializer.Deserialize <MapDatFormatGenericBodyModel <MapDataFormatObjectEntry> >(new DefaultStreamReaderStrategy(map.bytes).PreprendWithBytes((map.bytes.Length / 68).Reinterpret())); Resources.UnloadAsset(map); return(entries); }