void LoadERF(ERFObject obj, string resRef, ResourceType resType, Dictionary <string, ClassDefinition> defs, Compatibility compat, ExistsIn existsIn) { if (!gffTypes.Contains(resType)) { return; } string className = "Aurora" + resType.ToString().ToUpper().Replace(" ", ""); if (!defs.ContainsKey(className)) { defs[className] = new ClassDefinition(); } Stream stream = obj.GetResource(resRef, resType); if (resType == ResourceType.ERF || resType == ResourceType.SAV) { // ERFs can contain ERFs themselves! //Debug.Log("Loading nested ERF file " + resRef); LoadERFObj(new ERFObject(stream), defs, compat, existsIn); //Debug.Log("Finished loading nested ERF file " + resRef); } else { // Load the resource from the ERF GFFObject gffObject = new GFFLoader(stream).GetObject(); // Update the class definition LoadGFF(gffObject, defs, className, compat, existsIn); } }
void LoadERFObj(ERFObject obj, Dictionary <string, ClassDefinition> defs, Compatibility compat, ExistsIn existsIn) { foreach ((string resRef, ResourceType resType) in obj.resourceKeys.Keys) { //Debug.Log("Loading erf object " + resRef); LoadERF(obj, resRef, resType, defs, compat, existsIn); } }
void LoadGFFsFromERF(string filename, Dictionary <string, ClassDefinition> defs, Compatibility compat, ExistsIn existsIn) { // We load every module in the game files // Find the list of module names // TODO: Implement this for KOTOR 2, which uses a different file structure //Debug.Log("Loading " + filename); ERFObject obj = new ERFObject(filename); LoadERFObj(obj, defs, compat, existsIn); }