CitiesSkylinesMods / TMPE

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

TTL skip right flow #1580

Open kianzarrin opened 2 years ago

kianzarrin commented 2 years ago

image when setting up TTL for example by control+clicking , right turn is activated for two cycles. there is no need to remain to stay in the current traffic light step for the cars that are turning right if right turn is green in the next step too.

Therefore I think we need an option to skip right turn in flow/wait calculations.

kianzarrin commented 2 years ago

this diff will do it. Just need UI to make it optional.

diff --git a/TLM/TLM/TrafficLight/Impl/TimedTrafficLightsStep.cs b/TLM/TLM/TrafficLight/Impl/TimedTrafficLightsStep.cs
index 2b5be2a7..dd1970d7 100644
--- a/TLM/TLM/TrafficLight/Impl/TimedTrafficLightsStep.cs
+++ b/TLM/TLM/TrafficLight/Impl/TimedTrafficLightsStep.cs
@@ -931,6 +931,8 @@ namespace TrafficManager.TrafficLight.Impl {
                             bool addToFlow = false;
+                            bool ignore = false;
+                            const bool ignoreRight = true; // TODO: make optional

                             switch (dir) {
                                 case ArrowDirection.Turn: {
@@ -946,7 +948,11 @@ namespace TrafficManager.TrafficLight.Impl {
                                 }

                                 case ArrowDirection.Right: {
-                                    addToFlow = segLight.IsRightGreen();
+                                    if (ignoreRight) {
+                                        ignore = true;
+                                    } else {
+                                        addToFlow = segLight.IsRightGreen();
+                                    }
                                     break;
                                 }

@@ -965,7 +971,7 @@ namespace TrafficManager.TrafficLight.Impl {
                                     () => "TimedTrafficLightsStep.calcWaitFlow: ## Vehicles @ " +
                                     $"lane {laneIndex}, seg. {sourceSegmentId} going to seg. " +
                                     $"{targetSegmentId}: COUTING as FLOWING -- numMovingVehicles={numMovingVehicles}");
-                            } else {
+                            } else if(!ignore) {
                                 curTotalLaneWait += numVehicles;
                                 ++numLaneWaits;