/// <summary> /// Adds a model info to the record if it's not already there. /// </summary> /// <param name="ModelId"></param> /// <returns></returns> public void AddAllRecords() { int MaxModelID = 120000; record = new List <DfModelRecord>(); int ModelId = 0; uint uModelId; InitArchFile(); while (ModelId < MaxModelID) { uModelId = (uint)ModelId; // Test if model is actually in BSA database and has a mesh. If not skip int index = arch3dFile.GetRecordIndex(uModelId); if (index != -1) { DfModelRecord dfMod = new DfModelRecord(); dfMod.ModelID = ModelId; dfMod.Labels = new List <string>(); record.Add(dfMod); } ModelId++; if (ModelId % 1000 == 0) { Debug.Log("Imported Records: " + ModelId.ToString()); } } }
/// <summary> /// Adds a model info to the record if it's not already there. /// </summary> /// <param name="ModelId"></param> /// <returns></returns> public bool AddRecordById(int ModelId) { //if (ModelId > 65500) return false; InitArchFile(); uint uModelId = (uint)ModelId; // Test if model is actually in BSA database and has a mesh. If not skip int index = arch3dFile.GetRecordIndex(uModelId); if (index == -1) { Debug.Log("ModelId " + ModelId.ToString() + " not found in Daggerfall database"); return(false); } // Go reverse order down, and add successfully if you've found nothing until the point you find it's model-1 number in the index // Counts the least records this way // eg 1000 records, ask for ModelID 20000 assuming highest is 5000, then add // ModelID can never be lower than records // Check to ensure ID doesn't already exist. //if (record.Count <= ModelId) for (int i = record.Count - 1; i >= 0; i--) { if (record[i].ModelID >= ModelId) { return(false); } else if (record[i].ModelID < ModelId) { break; // Smaller than the highest model number. Perhaps you missed it? } } /* * foreach (DfModelRecord df in record) * { * if (df.ModelID == ModelId) * { * return false; * } * * * } */ DfModelRecord dfMod = new DfModelRecord(); dfMod.ModelID = ModelId; dfMod.Labels = new List <string>(); record.Add(dfMod); return(true); }