public static void GetTrafficLightState(ushort vehicleId, ref Vehicle vehicleData, ushort nodeId, ushort fromSegmentId, ushort toSegmentId, ref NetSegment segmentData, uint frame, out RoadBaseAI.TrafficLightState vehicleLightState, out RoadBaseAI.TrafficLightState pedestrianLightState) { TrafficLightSimulation nodeSim = TrafficLightSimulation.GetNodeSimulation(nodeId); if (nodeSim == null || !nodeSim.IsSimulationActive()) { RoadBaseAI.GetTrafficLightState(nodeId, ref segmentData, frame, out vehicleLightState, out pedestrianLightState); } else { GetCustomTrafficLightState(vehicleId, ref vehicleData, nodeId, fromSegmentId, toSegmentId, out vehicleLightState, out pedestrianLightState, nodeSim); } }
public static void OriginalSetTrafficLightState(bool customCall, ushort nodeID, ref NetSegment segmentData, uint frame, RoadBaseAI.TrafficLightState vehicleLightState, RoadBaseAI.TrafficLightState pedestrianLightState, bool vehicles, bool pedestrians) { /// NON-STOCK CODE START /// TrafficLightSimulation nodeSim = TrafficLightSimulation.GetNodeSimulation(nodeID); if (nodeSim == null || !nodeSim.IsSimulationActive() || customCall) { /// NON-STOCK CODE END /// int num = (int)pedestrianLightState << 2 | (int)vehicleLightState; if (segmentData.m_startNode == nodeID) { if ((frame >> 8 & 1u) == 0u) { segmentData.m_trafficLightState0 = (byte)((int)(segmentData.m_trafficLightState0 & 240) | num); } else { segmentData.m_trafficLightState1 = (byte)((int)(segmentData.m_trafficLightState1 & 240) | num); } if (vehicles) { segmentData.m_flags |= NetSegment.Flags.TrafficStart; } else { segmentData.m_flags &= ~NetSegment.Flags.TrafficStart; } if (pedestrians) { segmentData.m_flags |= NetSegment.Flags.CrossingStart; } else { segmentData.m_flags &= ~NetSegment.Flags.CrossingStart; } } else { if ((frame >> 8 & 1u) == 0u) { segmentData.m_trafficLightState0 = (byte)((int)(segmentData.m_trafficLightState0 & 15) | num << 4); } else { segmentData.m_trafficLightState1 = (byte)((int)(segmentData.m_trafficLightState1 & 15) | num << 4); } if (vehicles) { segmentData.m_flags |= NetSegment.Flags.TrafficEnd; } else { segmentData.m_flags &= ~NetSegment.Flags.TrafficEnd; } if (pedestrians) { segmentData.m_flags |= NetSegment.Flags.CrossingEnd; } else { segmentData.m_flags &= ~NetSegment.Flags.CrossingEnd; } } } // NON-STOCK CODE }