/// <summary> /// How many new rooms in region, read from world file /// </summary> private static int Region_NumberOfRoomsInRegion(On.Region.orig_NumberOfRoomsInRegion orig, string name) { bool customRegion = false; int totalRooms = 0; foreach (KeyValuePair <string, string> keyValues in CustomWorldMod.activatedPacks) { string worldFilePath = CRExtras.BuildPath(keyValues.Value, CRExtras.CustomFolder.RegionID, regionID: name, file: "world_" + name + ".txt"); if (File.Exists(worldFilePath)) { customRegion = true; string[] array = File.ReadAllLines(worldFilePath); bool flag = false; int num = 1; for (int i = 0; i < array.Length; i++) { if (array[i] == "END ROOMS") { break; } if (flag) { num++; } if (array[i] == "ROOMS") { flag = true; } } totalRooms += num; } } if (customRegion) { return(totalRooms); } return(orig(name)); }
/// <summary> /// How many new rooms in region, read from properties /// </summary> private static int Region_NumberOfRoomsInRegion(On.Region.orig_NumberOfRoomsInRegion orig, string name) { //if (!enabled) { return orig(self); } bool customRegion = false; int totalRooms = 0; foreach (KeyValuePair <string, string> keyValues in CustomWorldMod.activatedPacks) { //CustomWorldMod.CustomWorldLog($"Custom Regions: Counting total rooms for {keyValues.Value} in {name}"); string path = CustomWorldMod.resourcePath + keyValues.Value + Path.DirectorySeparatorChar; string test = string.Concat(new object[] { Custom.RootFolderDirectory(), path.Replace('/', Path.DirectorySeparatorChar), "World", Path.DirectorySeparatorChar, "Regions", Path.DirectorySeparatorChar, name, Path.DirectorySeparatorChar, "world_", name, ".txt" }); if (File.Exists(test)) { customRegion = true; string[] array = File.ReadAllLines(test); bool flag = false; int num = 1; for (int i = 0; i < array.Length; i++) { if (array[i] == "END ROOMS") { break; } if (flag) { num++; } if (array[i] == "ROOMS") { flag = true; } } //CustomWorldMod.CustomWorldLog($"Custom Regions: {keyValues.Value} had {num} rooms-connections in region [{name}]."); totalRooms += num; } } if (customRegion) { return(totalRooms); } return(orig(name)); /* * else * { * return orig(name); * } */ }