Closed Duke02 closed 7 years ago
I like this idea, but there are some things to figure out. The generate() method definitely works over all of them, no question, but for at least SectionDungeonGenerator (probably also ThinDungeonGenerator), the addDoors(), addWater(), and similar methods take an extra parameter for what dungeon areas (room, corridor, or cave) should be affected. There could be a standard IDungeonGenerator method that always means "apply to all possible cells", which is the only option in DungeonGenerator, and can also be done in SectionDungeonGenerator by using the existing methods and passing a specific environment type. This would be harder to connect to addLake() and addMaze(), which aren't in DungeonGenerator. If the only methods are related to generating a dungeon and getting the last generated dungeon, then this would need almost no code to implement, plus it lets the existing implementations add extra features that make sense in their own context but not others (ThinDungeonGenerator especially needs this to handle its unusual map requirements). So, I'll make a simple interface with just:
char[][] generate();
char[][] getDungeon();
Since all the dungeon generators can for sure do those two things, anything else can be specially assigned to a specific instance, but the general usage as a generator works for all of them.
@tommyettinger> the "add" methods in IDungeonGenerator could return a boolean indicating if the request could be honored. Dungeon generators that do not know lakes and mazes would return false for these methods.
I think I will close this for now, since c054fae74f3ab239aab0d5df9ec34890e6c0e530 covers the basic "can it generate a 2D char array" function for a lot of classes, but I am happy to reopen it if there's some specific functionality that should be wrapped in this or a similar interface, maybe for a smaller subset of classes that also share methods.
We could have an interface that all dungeon generators implement from. The interface could be something like this -
and potentially other functions if the need arises. This would entail some renaming of most dungeon generators.
This interface could then be used for flexible dungeon generation, such as -