BenPyton / ProceduralDungeon

This is an Unreal Engine 4/5 plugin to generate procedural dungeon.
MIT License
527 stars 64 forks source link

Limit floor count #39

Closed Perpure closed 9 months ago

Perpure commented 11 months ago

Hello, I want to implement functionality to control overall amount of floors. For simplicity let's say I don't want any room to be lower than Z=0 or higher than Z=1, so it will be just a 2-floor dungeon.

As I understand, EventOnRoomAdded won't provide me necessary information about current room position in global space.

I've tried to utilize info about door positon in ChooseNextRoom, but it's also not enough here, since I can't delete current room at this point. The only thing I can do here is simply block doors for stairs that will lead to restricted floor, which is quite an ugly workaround. Or I can remove spawning any stairs rooms from first and last floor, but it won't work with 2-floor dungeon.

Also I had an idea of just marking doors type for stairs as "1st" and "2nd" meaning the floor, but this will require to duplicate all 1-floor rooms to match either floor. Maybe there are any way to have multiple door types for a single door?

So I'm realy running out of options here, what approach can you suggest?

BenPyton commented 11 months ago

Hi @Perpure

It's a really interesting issue you bring to me!

If I would solve this problem currently without modifying the plugin's code, I think I will do something like this:

I know this is considered a workaround, but it should work correctly with the current plugin's version (3.0.1).

However, you can always change the plugin's code to suit your needs if you want a better approach to solve your issue. I will think on my side of a way to add this feature in a future version of the plugin, and if you come with some idea or implementation on your side feel free to share it here if you want! 😉

What I am thinking of as of now, would be:

So, for example, we could use them like that:

This is something I have not tested, so there may be some flaws in that method. But I will try to implement a feature maybe like that in the next version to fix properly your issue.

Best regards.

Perpure commented 11 months ago

Thanks for your detailed response!

I agree with your approach to solving this problem. The ability to define which door from the next room will be used as the connection to the previous is exactly what I was missing. I guess I can implement this, I'll see what I can do.

Perpure commented 11 months ago

Implemented this feature in my fork. By the way you should decide how to handle situations where user has choosen incompatible door. On the one hand it should just be prohibited, on the other hand this will allow user to create custom logic for door types. For example TypeA can be connected with TypeB, but can't be connected with TypeC.

BenPyton commented 11 months ago

Good to hear you solved your issue with this approach!

I think the better thing to do for the door compatibility would be to throw an error message if the returned door index is not compatible or out of range.

And also I thought of making it random like in the current version if the returned index is negative.

Then I could remove the Random Door boolean in the room data assets.

BenPyton commented 9 months ago

The feature has been added to the version 3.1.0 of the plugin.