/// <summary> /// Parsing IDE files<para/> /// Разбор файлов IDE /// </summary> public static void ReadDefinitions() { Definitions = new ItemDefinition[8192]; int totalEntries = 0; foreach (string IDE in FileManager.DefinitionFiles) { TextFile f = new TextFile(PathManager.GetAbsolute(IDE), true, true); foreach (TextFile.Line p in f.Lines) { switch (p.Section.ToLower()) { // Common objects // Обычные объекты case "objs": ItemDefinition d = new ItemDefinition() { ID = p.Text[0].ToInt(), ModelName = p.Text[1].ToLower(), TexDictionary = p.Text[2].ToLower(), DrawDistance = new float[p.Text[3].ToInt()], IsTimed = false, Flags = new ItemDefinition.FlagsContainer(p.Text[p.Text.Length - 1].ToUInt()) }; for (int i = 0; i < d.DrawDistance.Length; i++) { d.DrawDistance[i] = p.Text[4 + i].ToFloat(); } Definitions[d.ID] = d; totalEntries++; break; // Timed objects // Временные объекты case "tobj": d = new ItemDefinition() { ID = p.Text[0].ToInt(), ModelName = p.Text[1].ToLower(), TexDictionary = p.Text[2].ToLower(), DrawDistance = new float[p.Text[3].ToInt()], IsTimed = true, Flags = new ItemDefinition.FlagsContainer(p.Text[p.Text.Length - 3].ToUInt()), TimeOn = p.Text[p.Text.Length - 2].ToInt(), TimeOff = p.Text[p.Text.Length - 1].ToInt() }; for (int i = 0; i < d.DrawDistance.Length; i++) { d.DrawDistance[i] = p.Text[4 + i].ToFloat(); } Definitions[d.ID] = d; totalEntries++; break; default: break; } // Operation is threadable, so sleep for a while // Операция потоковая, поэтому отдадим времени основному процессу System.Threading.Thread.Sleep(0); } } Dev.Console.Log("[ObjectManager] Parsed " + FileManager.DefinitionFiles.Length + " definition files (" + totalEntries + " entries)"); }
/// <summary> /// Initialize Timecyc.dat file<para/> /// Чтение файла Timecyc /// </summary> public static void Init() { if (weatherParams == null) { Entry[,] ea = new Entry[7, 24]; TextFile f = new TextFile(PathManager.GetAbsolute("data/Timecyc.dat"), false, false); int w = 0, h = 0; foreach (TextFile.Line l in f.Lines) { Entry e = new Entry(); e.AmbientStatic = new Vector3( l.Text[0].ToFloat() / 255f, l.Text[1].ToFloat() / 255f, l.Text[2].ToFloat() / 255f ); e.AmbientDynamic = new Vector3( l.Text[3].ToFloat() / 255f, l.Text[4].ToFloat() / 255f, l.Text[5].ToFloat() / 255f ); e.DiffuseStatic = new Vector3( l.Text[6].ToFloat() / 255f, l.Text[7].ToFloat() / 255f, l.Text[8].ToFloat() / 255f ); e.DiffuseDynamic = new Vector3( l.Text[9].ToFloat() / 255f, l.Text[10].ToFloat() / 255f, l.Text[11].ToFloat() / 255f ); e.DirectLight = new Vector3( l.Text[12].ToFloat() / 255f, l.Text[13].ToFloat() / 255f, l.Text[14].ToFloat() / 255f ); e.SkyTop = new Vector3( l.Text[15].ToFloat() / 255f, l.Text[16].ToFloat() / 255f, l.Text[17].ToFloat() / 255f ); e.SkyBottom = new Vector3( l.Text[18].ToFloat() / 255f, l.Text[19].ToFloat() / 255f, l.Text[20].ToFloat() / 255f ); e.CameraClip = l.Text[33].ToFloat(); e.FogDistance = l.Text[34].ToFloat(); // Storing data // Сохранение данных ea[w, h] = e; h++; if (h>23) { h = 0; w++; } } weatherParams = ea; } }
/// <summary> /// Open GTA_VC.dat and default.dat<para/> /// Чтение GTA_VC.dat и default.dat /// </summary> static void ReadDataFiles() { List<string> ide = new List<string>(), ipl = new List<string>(), col = new List<string>(), tex = new List<string>(), mod = new List<string>(), img = new List<string>(); TextFile d; for (int i = 0; i < 2; i++) { // First gta_vc, then default // Сначала gta_vc, потом default if (i == 0) { d = new TextFile(PathManager.GetAbsolute("data/gta_vc.dat"), false, false); } else { d = new TextFile(PathManager.GetAbsolute("data/default.dat"), false, false); } // Parsing directives // Обработка директив foreach (TextFile.Line l in d.Lines) { switch (l.Text[0].ToLower()) { // Item Definition // Файл IDE case "ide": ide.Add(l.Text[1]); col.Add(System.IO.Path.ChangeExtension(l.Text[1], ".col")); break; // Item placement // Файл IPL case "ipl": ipl.Add(l.Text[1]); break; // Collision files // Файлы коллизий case "colfile": col.Add(l.Text[2]); break; // Texture dictionary // Тектстурный архив case "texdiction": tex.Add(l.Text[1]); break; // Generic DFF file // DFF файл case "modelfile": mod.Add(l.Text[1]); break; // Additive IMG archive // Дополнительный IMG-архив case "cdimage": img.Add(l.Text[1]); break; // Splash image (skip) // Сплэш (пропускаем) case "splash": break; default: throw new Exception("[FileManager] Unknown directive in data file: " + l.Text[0]); } } } // Saving data // Сохранение данных DefinitionFiles = ide.ToArray(); PlacementFiles = ipl.ToArray(); CollisionFiles = col.ToArray(); ModelFiles = mod.ToArray(); TextureFiles = tex.ToArray(); ArchiveFiles = img.ToArray(); }
/// <summary> /// Parsing IPL files<para/> /// Разбор файлов IPL /// </summary> public static void ReadPlacements() { List<ItemPlacement> pl = new List<ItemPlacement>(); foreach (string IPL in FileManager.PlacementFiles) { TextFile f = new TextFile(PathManager.GetAbsolute(IPL), true, true); foreach (TextFile.Line p in f.Lines) { switch (p.Section.ToLower()) { // Object installation // Расстановка объектов case "inst": ItemPlacement g = new ItemPlacement() { ID = p.Text[0].ToInt(), ModelName = p.Text[1], InteriorID = ItemPlacement.Interior.World, Position = new Vector3(p.Text[p.Text.Length - 10].ToFloat(), p.Text[p.Text.Length - 8].ToFloat(), p.Text[p.Text.Length - 9].ToFloat()), Scale = new Vector3(p.Text[p.Text.Length - 7].ToFloat(), p.Text[p.Text.Length - 5].ToFloat(), p.Text[p.Text.Length - 6].ToFloat()), Angle = new Quaternion(-p.Text[p.Text.Length - 4].ToFloat(), -p.Text[p.Text.Length - 2].ToFloat(), -p.Text[p.Text.Length - 3].ToFloat(), -p.Text[p.Text.Length - 1].ToFloat()), }; if (p.Text.Length>12) { g.InteriorID = (ItemPlacement.Interior)p.Text[2].ToInt(); } pl.Add(g); break; } // Operation is threadable, so sleep for a while // Операция потоковая, поэтому отдадим времени основному процессу System.Threading.Thread.Sleep(0); } } Placements = pl.ToArray(); Dev.Console.Log("[ObjectManager] Parsed " + FileManager.PlacementFiles.Length + " placement files (" + pl.Count + " entries)"); }