Closed Craxy closed 7 years ago
Possible solution: Attach to RoadBaseAI.UpdateNodeFlags
and update traffic lights state (NetNode.Flags.TrafficLights
and NetNode.Flags.CustomTrafficLights
) after the methods finished.
Detour only allows replacing method calls, but not calling the source method. Harmony can add a postfix method. But: Harmony is rather big: a lot of cs-files instead of just one small file. And it doesn't support undo a patch (There's (this pull request)[https://github.com/pardeike/Harmony/pull/26] that enables undoing).
Problem with attaching to RoadBaseAI.UpdateNodeFlags
: If custom roads implement a custom RoadAI and override RoadBaseAI.UpdateNodeFlags
, it might not get called (no base.UpdateNodeFlags(...)
call).
Adds an option to disable traffic lights to Traffic Lights / Junctions Tab: When enabled new junctions are always created without traffic lights. Existing Traffic Lights aren't touched neither does it prevent manual changing the lights. All it does is ensure all newly created junctions don't have traffic lights.
The Option is set on a per savegame basis and is not a global option.
But there's an issue: To disable Traffic Lights creation,
RoadBaseAI.m_trafficLights
is changed (and when lights are enabled again, that's reset to their default state). But while junction creation that only addsNetNode.Flags.TrafficLights
but notNetNode.Flags.CustomTrafficLights
. Forcing a recalculation of traffic lights (like it's done by loading a save game) resets the lights to their default state when Traffic Lights are enabled. That's unexpected because before there weren't any and now -- without any changes -- there are lights.