CitiesSkylinesMods / TMPE

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

Button to remove / disable all traffic lights #320

Closed Sqoops closed 4 years ago

Sqoops commented 5 years ago

Is it possible to implement a button that removes all traffic lights in your entire city?

I tried implementing it myself but I can't figure out how to iterate the "ref NetNode node" from 0 to max and have it in a nested loop with for (ushort nodeId = 0; nodeId < NetManager.MAX_NODE_COUNT; ++nodeId)

FireController1847 commented 5 years ago

I mean, it's certainly possible, but is it worth adding such a mundane feature to take up more screen space? I'm not sure what the use case for this would be...

originalfoo commented 5 years ago

@FireController1847 I assume this is due to the fact that Toggle Traffic Lights mod is incompatible with TM:PE (it breaks some of our traffic light stuff for an as-yet unknown reason).

@Sqoops Is it removal of traffic lights that's the most important thing, or an option to disable new traffic lights being automatically added at junctions that would normally get them?

Sqoops commented 5 years ago

@FireController1847 I've implemented a button already like this picture which doesn't seem to waste that much space.

Edit by aubergine10: Inlined the image for posterity 2qUYmcR

@aubergine10 an option to disable new traffic lights being automatically added to new junctions would be good enough for me.


I just figured out how to remove all traffic lights with just the for loop that I've posted before.

for (ushort nodeId = 0; nodeId < NetManager.MAX_NODE_COUNT; ++nodeId)
{
    if (!Flags.mayHaveTrafficLight(nodeId))
        continue;

    bool? hasTrafficLight = Flags.isNodeTrafficLight(nodeId);
    if (hasTrafficLight == null)
        continue;

    if ((bool)hasTrafficLight)
        Flags.setNodeTrafficLight(nodeId, false);
}
webfischi commented 5 years ago

I have TTL still installed with game version 1.11 and TM:PE 10.18, if you just use the checkbox "Disable Traffic Lights" it works fine. So there shouldn't be an issue adding the feature, it could even use the original code from the mod, because it doesn't touch existing traffic lights.

originalfoo commented 4 years ago

Implemented in v11.0-alpha9