Tmpe: Prototype a signal engine and cooperate with Roundabout Builder mod

Created on 31 Jul 2019  路  9Comments  路  Source: CitiesSkylinesMods/TMPE

Description

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

Sources / Links (Optional)

Additional Info

Related to #426

Suggested action:

  • [ ] Prototype a simple cross-mod event intake. Taking lists of strings and numbers, as a command. Or something simple like that.
  • [ ] Allow an external mod to place road restriction commands in that queue, and let TM:PE handle them by applying the road restrictions.
  • [ ] Design some reasonable expiration rules in case the road modification command is not relevant anymore.
API COMPATIBILITY EXTERNAL feature technical

All 9 comments

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:

  • [ ] Entering Blocked Junction Allowed Action
  • [ ] No Crossings Action
  • [ ] No Parking Action
  • [ ] Yield Sign Action
  • Extra:

    • [ ] Speed limits

    • [ ] Default traffic lights (ON/OFF/AUTO)

    • [ ] Lane arrows (Maybe an array with identification for each lane is enough)

    • [ ] Lane connectors (for intersections)

    • [ ] Vehicle restrictions (for each kind: INHERIT(Default)/ALLOWED/FORBIDDEN)

I think you should support more actions in the API even though they are not needed for the roundabout builder.

  1. Speed limits
  2. Default traffic lights (ON/OFF/AUTO)
  3. Lane arrows (Maybe an array with identification for each lane is enough)
  4. Lane connectors (for intersections)
  5. Vehicle restrictions (for each kind: INHERIT(Default)/ALLOWED/FORBIDDEN)

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kianzarrin picture kianzarrin  路  53Comments

aubergine10 picture aubergine10  路  33Comments

aubergine10 picture aubergine10  路  39Comments

scottmcm picture scottmcm  路  29Comments

kianzarrin picture kianzarrin  路  32Comments