public void SimulationStep() { //Log.Warning("step: " + NodeId); var currentFrameIndex = Singleton <SimulationManager> .instance.m_currentFrameIndex; if (TimedTrafficLightsActive) { var timedNode = TrafficLightsTimed.GetTimedLight(nodeId); if (timedNode != null) { timedNode.CheckCurrentStep(); } } var node = getNode(); for (var l = 0; l < 8; l++) { var segment = node.GetSegment(l); if (segment == 0) { continue; } if (!TrafficLightsManual.IsSegmentLight(nodeId, segment)) { continue; } var segmentLight = TrafficLightsManual.GetSegmentLight(nodeId, segment); segmentLight.LastChange = (currentFrameIndex >> 6) - segmentLight.LastChangeFrame; } }
public TimedTrafficStep(int minTime, int maxTime, float waitFlowBalance, ushort nodeId, List<ushort> groupNodeIds) { this.nodeId = nodeId; this.minTime = minTime; this.maxTime = maxTime; this.waitFlowBalance = waitFlowBalance; this.timedNode = TrafficLightsTimed.GetTimedLight(nodeId); this.groupNodeIds = groupNodeIds; var node = TrafficLightTool.GetNetNode(nodeId); minFlow = Single.NaN; maxWait = Single.NaN; endTransitionStart = null; stepDone = false; for (var s = 0; s < 8; s++) { var segmentId = node.GetSegment(s); if (segmentId <= 0) continue; addSegment(segmentId); } calcMaxSegmentLength(); }
/// <summary> /// Stops & destroys the traffic light simulation(s) at this node (group) /// </summary> public void Destroy() { var node = getNode(); var timedNode = TrafficLightsTimed.GetTimedLight(nodeId); if (timedNode != null) { foreach (var timedNodeId in timedNode.NodeGroup) { var nodeSim = TrafficPriority.GetNodeSimulation(timedNodeId); // `this` is one of `nodeSim` TrafficLightsTimed.RemoveTimedLight(timedNodeId); if (nodeSim == null) { continue; } nodeSim.TimedTrafficLightsActive = false; nodeSim.TimedTrafficLights = false; } } }