CitiesSkylinesMods / TMPE

Cities: Skylines Traffic Manager: President Edition
https://steamcommunity.com/sharedfiles/filedetails/?id=1637663252
MIT License
576 stars 85 forks source link

LaneArrowManager lane grouping enhancements #1590

Open Elesbaan70 opened 2 years ago

Elesbaan70 commented 2 years ago

This issue depends on #1589.

Existing Arrows

The default lane arrow behavior in LaneArrowManager will change in certain lane grouping scenarios:

If the combination of incoming and outgoing lane counts makes these rules impossible to follow, the code will just try to behave as sensibly as possible.

Express and Service Lanes

  1. When there is a single segment in the far-turn direction and that segment has express/service lanes, the default number of far turn lanes will not exceed the number of outgoing express lanes in the target segment.
  2. When there is a single segment in the near-turn direction and that segment has express/service lanes, the default number of near turn lanes will not exceed the number of outgoing service lanes in the target segment.
  3. When the incoming segment has express/service lanes, express lanes will never be near-turn lanes, and service lanes will never be far-turn lanes.

image


Outer Displaced Lanes

  1. An outer displaced lane will never be a near-turn lane.
  2. When an outgoing segment has outer displaced lanes, at least one non-displaced far-turn lane will always be provided.
  3. When there is exactly one segment in the far-turn direction and it has outgoing outer displaced lanes, the number of far-turn lanes will always be at least one more than the number of outgoing displaced lanes.

image


Inner Displaced Lanes

  1. When there is a single segment in the far-turn direction and that segment has inner displaced lanes, the default number of far turn lanes will not exceed the number of outgoing displaced lanes in the target segment.
  2. When there is a single segment in the near-turn direction and that segment has inner displaced lanes, the default number of near turn lanes will not exceed the number of outgoing non-displaced lanes in the target segment.
  3. When the incoming segment has inner displaced lanes and a far turn is available, all incoming displaced lanes will be far-turn only.

image

New Arrows

A new enumeration, ExtLaneArrows, will provide extended arrows. Each extended arrow will be a special case of a basic directional arrow. LaneArrows will not be deprecated; both enumerations will coexist to ensure that we play as nicely as possible with anything that doesn't understand the extended arrows.

Explicit extended arrows are seen and selected by the user. It might not be immediately obvious to the user that these are just special cases of directional arrows, and that's okay.

Implicit extended arrows are not directly selected by the user, though timed traffic lights will reveal their existence because they can be controlled separately. When configuring lane arrows, the user will simply see a basic directional arrow.

Extended Arrow Special Case Of Applies To Meaning
CrossLeft Forward, explicitly RHT and LHT Forward traffic crosses leftward across a median or oncoming traffic
CrossRight Forward, explicitly RHT and LHT Forward traffic crosses rightward across a median or oncoming traffic
ExpressForward Forward, implicitly RHT and LHT Forward traffic moves from one express or displaced lane into another
ExpressLeft Left, implicitly RHT only Left-turning traffic leaves and/or enters a displaced outer lane
ExpressRight Right, implicitly LHT only Right-turning traffic leaves and/or enters a displaced outer lane

Lane Direction Calculation

Every possible lane transition will have a LaneArrow direction. This does not change.

In addition, every possible lane transition will have an ExtLaneArrow. This will be the same as its LaneArrow direction except in the following cases:

Forward Rules

The following rules apply when LaneArrow is Forward.

Incoming Lane Outgoing Lane Additional Rules ExtLaneArrow (RHT) ExtLaneArrow (LHT)
Outer, Inner DisplacedInner CFI Rule: Incoming segment has DisplacedInner and the incoming and outgoing segments are inverted in relation to each other, such that the "start node" flag is the same on both segment ends Forward Forward
Outer, Inner DisplacedInner Default behavior CrossLeft CrossRight
DisplacedInner Outer, Inner CrossRight CrossLeft
DisplacedInner DisplacedInner ExpressForward ExpressForward
DisplacedOuter DisplacedOuter ExpressForward ExpressForward
Inner Inner ExpressForward ExpressForward
Outer Inner CrossLeft CrossRight
Inner Outer CrossRight CrossLeft
DisplacedOuter not DisplacedOuter *misconfigured arrows/lane connections CrossRight CrossLeft
not DisplacedOuter DisplacedOuter *misconfigured arrows/lane connections CrossLeft CrossRight

Express Turn Rule

The express turn rule applies when the following conditions are true:

  1. Either the incoming or the outgoing lane, or both, are DisplacedOuter.
  2. LaneArrow is a Far Turn.
  3. The outgoing lane is in the nearest outgoing lane group in the direction of that turn.

When this rule is applied, ExtLaneArrow is the Express turn that corresponds to the turn's LaneArrow. i.e., ExpressLeft for RHT, or ExpressRight for LHT.

Note that it is impossible for ExpressRight to occur in right-hand traffic, or for ExpressLeft to occur in left-hand traffic.

Elesbaan70 commented 2 years ago

@kianzarrin When this reaches a working state, I'd like to collaborate on getting these arrows included as flags in AN, to facilitate road decals, etc.

kianzarrin commented 2 years ago

Sure. we can save space doing things like:

DisplacedInner = Displaced | Inner
Elesbaan70 commented 2 years ago

Sure. we can save space doing things like:

DisplacedInner = Displaced | Inner

In AN that may be a good optimization. It won't work here though, because the flags get aggregated, so they all have to be distinct.

Elesbaan70 commented 2 years ago

But having said that, I don't think those flags would be very useful in asset creation anyway. I think CrossLeft, CrossRight, and the express forward/left/right, will be the most useful.