This week I had to improve roads created last week and lay down rail tracks on them.
Performance Issues
Last week's roads severely impacted performance. To get to the bottom of this, I used VisualVM to check which methods were taking the most time. It was Lakes. Unfortunately facet configuration for Lakes doesn't work right now so I cannot disable Lakes. I had to completely remove it from the module.
insert photo of lava lakes
Another improvement is not connecting every city with every other city. So if we have cities A and B when city C is created, a rail will be laid down from C to either A or B depending on which is closer and not both.
Rails
The construction system uses a RoadRasterizer
to lay down actual blocks for the road. All I needed to do was create a custom RailRasterizer
in MetalRenegades which inherits from the default RoadRasterizer
in DynamicCities. I also needed a RoadManager
in MetalRenegades to pass this custom rasterizer to the construction system.
For the actual placement of rails within the road segment, I decided to keep it simple. Rails are only placed on two sides, along the border of the segment, as shown below:
insert an image here
I originally thought of filling segments with gravel and then placing rails on top, but that would again severely impact performance so it is left for later. What I still need to fix are some minor issues at segment borders where rails cannot connect properly.
PRs
To Do
- Fix these issues with rail borders
- Clean up and finish remaining PRs
- Move on to rail carts and AdvancedRails