The Lost Cities

The Lost Cities

59M Downloads

[Suggestion] Support for custom building (or road piece?) generation

Ivorforce opened this issue ยท 15 comments

commented

From Ivorforce/RecurrentComplex#235

My recommendation is creating a double weighted registry (vanilla uses ints but feel free to use https://github.com/Ivorforce/IvToolkit/blob/master/src/main/java/ivorius/ivtoolkit/random/WeightedSelector.java) to register structure generators. Your default pipeline would have weight 1.0.

It's notable that I would much rather generate during chunk population (or both), while your generation happens during chunk prime, so it optimally support both.

commented

I'm not sure I understand. What would the purpose of that registry be? For what would I use it? I'm not familiar with this structure

commented

Hey McJty - this was in reference to an issue I opened with Ivorius about creating a way to "snap" recurrent complex structures to chunk borders, enabling better worldgen with lost cities. If you click through to the link, my original issue is there.

commented

The registry would manage building creation. Right now your code generates all the building chunks, but if I could add my own weighted generator, it would be possible to randomly include buildings that players created in the world.
For you it would make no difference, but it would be part of the API - if someone wants to use it to replace generation functionality.

commented

I'll try to check this out today

commented

It is not that simple for me though. I cannot just use the weighted registry for both my and custom buildings as my buildings have to be treated in a special manner. i.e. buildings are made out of 6 height parts and possibly doorways are generated in code to connect them. In other words, my building structures have to follow very specific rules. That will most likely not work for custom buildings. So not 100% sure how to actually handle this. Having custom structures spawn on chunk boundary is actually something that has to be handled on the structure generation mod and not by Lost Cities and also such a structure generation mod can already check if there are buildings in some chunk by using the API. So at this moment I'm uncertain on what to do here.

commented

Hey McJty - I was wondering if you had a chance to consider this. At some point soon I would love to use Recurrent Complex buildings I'm designing and have them spawn in the world, but at best right now the generation is spotty and often RC buildings will collide with the buildings in Lost Cities. I think this might add a lot of value for other users as well!

commented

You just need to give me (or rather the generator) some information - usually enough would be 'this x, y, z', road is facing west' and I can handle the rest. I don't know what kind of connections or whatever you usually make but this can all be either be specifically ignored, or implemented by the structures' authors. To be honest I don't see the problem here really.

commented

Well it is fairly complicated. For example, if two buildings (in two separate chunks) are adjacent to each other then it is possible that these buildings will have connections between them. i.e. doorways connecting floors of the first building with the other building. I can do this for my buildings because every floor is at a multiple of 6 and I know how high every building is. I also design my buildings so that the place where a door can be 'carved out' is suitable for this. When a doorway is made between two buildings this affects both buildings obviously since at both chunks something will have to be carved out.

Obviously this only works nicely if the two buildings have floors at the same height.

It is possible to make an API to make this all possible but this is getting rather complicated and I have to think about this a bit better. For example, a problem here is that the api has to be two way. The structure generator would have to be able to ask my mod: 'is there a doorway at this level in the adjacent building' and otherwise Lost Cities would have to be able to ask the same from the structure generator mod (i.e. 'can I make a connection at this level')

commented

I can make it easier and just allow generation of custom buildings (by other mods) in 'street' sections of the city. That way they will not be considered buildings by Lost Cities and so they will be seen as independent. But in this scenario LC buildings are considered separate from buildings generated by other mods. I cannot use the same system for them

commented

Well it is fairly complicated. For example, if two buildings (in two separate chunks) are adjacent to each other then it is possible that these buildings will have connections between them. i.e. doorways connecting floors of the first building with the other building. I can do this for my buildings because every floor is at a multiple of 6 and I know how high every building is. I also design my buildings so that the place where a door can be 'carved out' is suitable for this. When a doorway is made between two buildings this affects both buildings obviously since at both chunks something will have to be carved out.

For this you can easily implement a boolean getter - something like isNormalSkyscraper and if I return false, you aren't allowed to make any of those kinds of assumptions. Think stuff like gas stations or family homes. Those wouldn't have these kinds of connections.

Obviously this only works nicely if the two buildings have floors at the same height.

Of course, but this is not in your responsibility to check. Yes, you can make a whole API out of this check if buildings do have these parameters, but if your buildings are limited to 6-story same height buildings, why not just expect the same of user-made sky scrapers? Or maybe something simpler like a getStories getter.

It is possible to make an API to make this all possible but this is getting rather complicated and I have to think about this a bit better. For example, a problem here is that the api has to be two way. The structure generator would have to be able to ask my mod: 'is there a doorway at this level in the adjacent building' and otherwise Lost Cities would have to be able to ask the same from the structure generator mod (i.e. 'can I make a connection at this level')

I'd rather not offload the generation of connections or whatever else you have in store to the other mod. Why not just ask its compatibility parameters (like, again, how many stories has this building or how tall is it), and decide based on that what other features you may generate? It can be as simple as a boolean covering all features if you don't want to implement any more, but even that would be very helpful.

I can make it easier and just allow generation of custom buildings (by other mods) in 'street' sections of the city. That way they will not be considered buildings by Lost Cities and so they will be seen as independent. But in this scenario LC buildings are considered separate from buildings generated by other mods. I cannot use the same system for them

Overwriting streets can also be an interesting feat, but I'd rather not generate structures (as in, buildings) on them.

commented

I will have to postpone this a bit. There are more complications then I first thought (buildings spanning multiple chunks, the fact that building selection should depend on the city style, and so on).

commented

Thanks for your attention on this, guys. From my perspective, spawning on streets should not be a problem, Ivorius, so long as not EVERY street contains an RC building (I don't think that's whats meant). I can increase or decrease the chance of a chunk being a building in the cfg (S:buildingChance=0.3).

If I read this correctly, if it seems that there are enough streets and too many buildings (RC structures and City structures) I can simply lower the chance of a given chunk being a building (thereby making more streets)? Does that sound right, McJty? Let us know when/if you can consider this again.

Here's some more recent screenshots - there's even one featuring my city's "reptile house" from recurrent complex.
http://imgur.com/a/CTmTB

commented

Ok, I decided to go with a forge style event system. Next release you will have the following events:

https://github.com/McJty/LostCities/blob/master/src/main/java/mcjty/lostcities/api/LostCityEvent.java

Using these it should be possible for another mod to change how a chunk has to be generated. This is the first proposal for this api. Let me knows if that would work for you. Version 0.0.18beta will support this new api. (about to be released later today)

commented

I'm not the biggest fan of the Forge events because they don't allow for weighted selection, but as long as not too many mods use the event at once it will work just as well.

I'll probably play around with it a bit soon-ish and let you know if I can get some good use out of it. Cheers! :)

commented

Let me know if you find any issues. In a few days I will leave for vacation so if there are any problems after that it will have to wait a bit until I return.