Open originalfoo opened 5 years ago
I don't know about other places, but when a traffic light has failed here, it will flash the red light over and over. People must treat it like a 4-way stop until it is back up. In terms of power outages, I'm not sure if they act differently, and I'm also not sure if there is anything in terms of backup power for the lights. I know sometimes the lights will just be out entirely (no lit signals), and in that situation you continue to treat it like a 4-way stop. Technically, it's supposed to be right-of-way, but everyone does 4-way because it makes way more sense.
+1 to the idea though, I fully support it. It'd also be really cool if we could make the street lights go out for a segment with no power
You know what, I'll take on this idea and hopefully make an implementation. I need something to do before the refactor anyways lol
Yes, I'd love the street lights to go out. A proper power cut!
Maybe lights could 'malfunction' (causing flashing yellow or red depending on user preference) if the road is unmaintained for too long? :D
Yes! I could totally see if I could do that. I'm just going to note this here, I think the option name "Road lights are power-dependent" as a toggle (and enabled by default) is a good option name.
Notes:
ElectricityManager
has a method called CheckElectricity
that takes a Vector3 position. We could possibly use that?CommonBuildingAI
uses a method called CheckColor
to determine if it has electricity. Needs more research.For power detection we'd ideally need some way to cache it, it seems wasteful needing to check every frame, and also wasteful to check every segment (there can be 38k segments). I assume the base game has a decent approach to staggering the electricity checking across frames?
It might be worth inspecting source of Real Time mod, as that had to deal with electricity. Specifically, RT would turn lights out at night, but if there was a power cut the game would turn lights back on when power was restored, so Real Time had to handle that scenario.
Since I'm taking finals for my high school right now, I might be able to experiment a bit but I'll focus on this 2-4 weeks from now. Hope that's okay!
@aubergine10, luckily enough, Real Time didn't have to bother with electricity. For the lights out feature, Real Time just semi-deactivates the buildings, the game does the rest. So there is no code for electricity handling or similar things in Real Time, no need to study the code.
Maybe the same approach could be used for the traffic lights too.
My apologies but with my recent increase in real life activities and my lack of participation in TM:PE in recent months, I think this issue would be better suited to someone else. If it's still around when I come back I'd look forward to fixing it, but for now I'm going to unassign myself. Sorry!
Idea spawned from, and dependent upon, #128
If there is power cut (as game can detect for buildings), it would be nice if the traffic signals could fail.
In many cases a failed traffic light will show yellow flashing light (running from battery power or something?) to warn that there is a junction, or just be completely unlit.
Some infos in wikipedia: https://en.wikipedia.org/wiki/Traffic_light_control_and_coordination#Other_types_of_control