Open marcin7848 opened 1 year ago
Thanks for feature suggestion.
I see couple of quite complex challenges and I'm pretty sure I already pointed out few of them but I'll repeat;
segment lane connection
(game can connect additional node(s) and segments to the segment - invisible connection)
Hi, the feature I'm going to present here I've already discussed with @krzychu124. He made some very good suggestions. While I'm trying to learn how to make mods and create this one, maybe someone more experienced is willing to pick it up, maybe discuss the usage and potential issues, so I'm putting it here.
If I understood everything correctly, the current way of working with TM:PE Road restrictions look like this:
And now the new feature I suggest. Instead of restricting segments for every truck (or any other kind of vehicle), let's make it per building/district.
Firstly, I made a very simple paint example of usage of this feature:![tmperest1](https://user-images.githubusercontent.com/26604617/204110884-b98b97f1-16cb-4f64-8548-41b18d111a44.png)
How do I see it working?
5a. If the segment X is already restricted for other buildingIDs, for e.g.:
[X][0][2][5,8,10] -> 2
instead of adding a new row, it adds a new element to [3] element of the variable, so for building 121 this row will looks like this now:[X][0][2][5,8,10,121] -> 2
5b. If you restrict the road for the district instead of building, we make another storage for blocked districts like:
[segment][bus-lane mode (3 options)][segment lane count][districtIDs] -> Vehicle Type (combined bit flag)
The new (or edited) row is added to the database
The truck from the {buildingID: 121} spawns and runs the pathfinding algorithm
The data provided at the beginning of the pathfinding algorithm: {buildingID: 121} and every districtIDs where this building is located, for e.g.: {districtID: 5} and {districtID: 12}
While finding the correct path, the data with restricted segments by standard TM:PE is loaded, it could look like this:
Now the data with restricted segments for specific buildings is loaded:
10a. If we can do filtering while fetching the data from the database, we provide to the query the {buildingID: 121} and we get:
[X][0][2][5,8,10,121] -> 2
10b. If we cannot do filtering while fetching the data, we load everything:
10c. If we load everything (10b), we filter the data after the loading, so instead of 10b. rows, we get only:
[X][0][2][5,8,10,121] -> 2
why? Because we don't need another segments for our {buildingID: 121}, no other segment contains it, so we remove them12a. You have prepared data from the 9 and 10 point, the 11 needs to be made. You provided the districtIDs where the {buildingID: 121} is located (look 8.), so it's {districtID: 5} and {districtID: 12} While getting the data in 11. point or now, we filter the data from 11. to get only segments where the {districtID: 5} and {districtID: 12} are restricted, so we get for example:
Different 3 rules decide to avoid the segments: A, C, X and Z for the truck when the source of it is the {buildingID: 121}.
To check: If the source of the truck changes when it reaches the train station (and other way of travel) So for e.g. when the truck from an Oil Industry Pomp -> goes to train station -> and leaves at another train station (is the truck building source still the Oil Industry Pomp or is it the train station where it leaves? - if the second one, make the possibility of restricting roads for trains stations etc. so we block a segment for a truck when its source is the train station)
The feature seems not so hard to make. It would use most of the tools that already exists in the TM:PE. The biggest "if" is in the 8. point, so providing the building id and district id to the pathfinding algorithm while the car is spawned (so where to get that data?).
The example I've just shown is for trucks and - in general - cargo, but - of course - it could be used for any other vehicle, like cars or service vehicles. The potential huge usage is for cars but it would require additional work to make an ability to restrict roads (sidewalks) for pedestrians because if we restrict all roads for cars to force citizens to use a tram station, there is currently no way to prevent them from just walking to their destination.