Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modifying the LevelGraph data at runtime #101

Open
sjuzwicki opened this issue Aug 3, 2021 · 1 comment
Open

Modifying the LevelGraph data at runtime #101

sjuzwicki opened this issue Aug 3, 2021 · 1 comment
Labels

Comments

@sjuzwicki
Copy link

Hi,

I would like to ask whether it is possible to manipulate the data for the level graph just before generating the dungeon.

My specific case: I want to be able to select a LevelGraph and a RoomTemplateSet via code just before generating a dungeon. The rationale is that the player will decide whether to generate a "long" or "short" dungeon (represented by different level graphs) and which biome (let's say "desert", "ice", "jungle", etc - represented by different room template sets).

I have been able to do both of the above by simply accessing the DungeonGenerator object and setting my desired values at runtime, but I ran into a problem with different biomes. All works perfectly well for normal rooms, but I have a spawn room in my level graphs which uses a room-specific template - so I need to set the template for that room as well, otherwise it will not match the biome.

I found that I would need to access the RoomBase children of the LevelGraph I am using (and I found which room to actually modify), but from what I can see that class only has getters and no visible way to actually set something. Would be grateful if you can correct me here :)

Of course what I can theoretically do is simply forget setting the biomes on the room template level and prepare separate level graphs for each biome. The issue is that then I would need a lot more level graphs (number of size options multiplied by number of biomes) so if possible I would prefer to avoid it.

@OndrejNepozitek
Copy link
Owner

Hello,
do you by any chance have the PRO version of the plugin? Because this whole scenario is quite simple there as you can implement custom input tasks. With them, you no longer have to prepare (assign) your room templates at design time. Instead, you can use the level graph only for the graph structure and then based on individual room types you implement a method that picks the correct room templates. So if you have a variable that indicates the current biome, you can just add an if statement that picks the correct spawn room for that biome.

If you don't have the PRO version, you can probably continue with what you're trying. If you found the correct RoomBase class, you should be able to just cast it to Room and access the room templates there. The RoomBase class is just the common ancestor for all the rooms (you can have custom room classes in the PRO version) and the concrete implementation in the free version is the Room class.

Let me know if this helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants