Ejemplo n.º 1
0
        // this implements the Update method of MonoBehaviour
        public void Update()
        {
            //Log.Warning("CustomRoadAI: Update called");
            var currentFrameIndex = Singleton <SimulationManager> .instance.m_currentFrameIndex >> 6;

            if (_lastFrame < currentFrameIndex)
            {
                _lastFrame = currentFrameIndex;

                if (TrafficLightTool.getToolMode() != ToolMode.AddPrioritySigns)
                {
                    TrafficPriority.housekeeping();
                }
            }

            try {
                foreach (KeyValuePair <ushort, TrafficLightSimulation> e in TrafficPriority.LightSimByNodeId)
                {
                    var nodeSim = e.Value;
                    nodeSim.SimulationStep();
                }
            } catch (Exception) {
                // TODO the dictionary was modified (probably a segment connected to a traffic light was changed/removed). rework this
            }
        }
Ejemplo n.º 2
0
        public void CustomSimulationStep(ushort nodeId, ref NetNode data)
        {
            if (TrafficLightTool.getToolMode() != ToolMode.AddPrioritySigns)
            {
                TrafficPriority.housekeeping();
            }

            var nodeSim = TrafficPriority.GetNodeSimulation(nodeId);

            if (nodeSim != null && nodeSim.FlagTimedTrafficLights && nodeSim.TimedTrafficLightsActive)
            {
                nodeSim.SimulationStep();
            }
            else if (nodeSim == null || (nodeSim.FlagTimedTrafficLights && !nodeSim.TimedTrafficLightsActive))
            {
                OriginalSimulationStep(nodeId, ref data);
            }
        }