by @Strdate
Hi, I found this thread by accident. My Roundabout Builder mod sure has integration with TMPE, but uses a little cheat to apply the restrictions. After a segment is built, TMPE waits for some time before setting it up, thus I cannot apply the restrictions right away, as they would be removed right after. Thus I added a stopwatch to wait for some time and then apply them, but I am not too happy about it. It would be probably better to wait for a given number of simulation steps because it sometimes happens that the stopwatch goes off too quickly. Anyway, if you have any advice how to integrate it with TMPE better please tell me
Related to #426
Suggested action:
Nice. The simplest thing would be if TMPE fired an event when segment setup is done. I've already looked through the tmpe code, but that was 3 months ago, now I don't have much idea where to find it.
Of course I the responsibility of handling the settings queue would be on the external mod, which would not be ideal, but it could be a start.
You can see how it is done now in my mod - link
There is 500ms timer, after which this block of code runs - link. (It deos not run directly in the timer callback, as I am unsure about thread safety)
The Action object is simply the queue of the tmpe settings.
We can have a chat about it if you would like to. I have other things on my mind as well. I was browsing tmpe repo because I wanted something about pathfinding. I will probably create a separate issue then. You can add me on steam
First we should determine why there's a delay between updating roads and TMPE acting upon that. I assume it's something to do with events?
If the delay is always there, maybe an alternate approach is for external mod to send TMPE a message with details of the nodes/segments and what needs to happen to them, so that when TMPE comes to do its normal stuff it first checks to see if there's a to-do list from external mod?
Also, tagging #288
In GeometryManager there is something like updated segment list.
I think that segments appear there when Recalculate method is called in ExtSegmentManager.
The updated segments are handled in next? simulation step. But I have no idea how it works.
Recently played with TM:PE 11 alpha and with Roundabout Builder, apparently the mod interaction is broken: For me it was setting only one Entering Blocked Junction on the outer side, and never set any other features for a roundabout. I'll see what can be done about this, a simple prototype API maybe, which @Strdate can use safely or fall back to the old method with timers (unreliable).
The features to support via this API:
I think you should support more actions in the API even though they are not needed for the roundabout builder.
I am not including the timed traffic lights because they seem too complex for an addition. I think it's better to have that later on with more time to think how to define them.
@kvakvs How did you implement it in the TMPE logic?
I did not do it yet, there is no pull request.
You could find the TM:PE plugin assembly and call something on it (not reliable because more than 1 can be loaded). Or maybe you could find a Unity scene object and send a message to it - quite slow but more or less reliable.
@Strdate just call NetSegment.Calcualte() to force early calculations. it works well for move it mod. also I do this when placing intersection in TMPE (#990)
I am closing this because I have offered the solution.
If you really don't want to force early calculations - and there is no reason not to - you need to patch CalculateSegment and to know when to apply TMPE rules. roundabout builder does not use harmony.
Ok, can you create an issue in Roundabout builder? Otherwise I will forget about it. Thanks for doing my work :D