private static string GetJunctionEventDescription(JunctionEvent e) { var description = TrackFollower.DescribeJunctionBranches(e.junction); var car = GetCarOnJunction(e.junction); var carText = (car is Car && car != PlayerManager.Car.logicCar) ? $" <color=orange>({car.ID})</color>" : ""; return(description + carText); }
public static void DrawUpcomingEvents() { if (!PlayerManager.Car) { return; } var trackInfoSettings = Main.settings.trackInfoSettings; var bogie = PlayerManager.Car.Bogies[1]; var track = bogie.track; if (track == null) { return; } var startSpan = bogie.traveller.Span; var locoDirection = PlayerManager.LastLoco == null || PlayerManager.LastLoco.GetComponent <LocoControllerBase>()?.reverser >= 0f; var direction = !locoDirection ^ (bogie.trackDirection > 0); var currentGrade = TrackIndexer.Grade(bogie.point1) * (direction ? 1 : -1); var events = TrackFollower.FollowTrack( track, startSpan, direction ? trackInfoSettings.maxEventSpan : -trackInfoSettings.maxEventSpan); var eventDescriptions = events .ExceptUnnamedTracks() .ResolveJunctionSpeedLimits() .FilterRedundantSpeedLimits() .FilterGradeEvents(currentGrade) .Take(trackInfoSettings.maxEventCount) .TakeWhile(ev => ev.span < trackInfoSettings.maxEventSpan) .Select(ev => ev switch { TrackChangeEvent e => (e.span, e.ID.ToString()), JunctionEvent e => (e.span, GetJunctionEventDescription(e)), DualSpeedLimitEvent e => (e.span, $"{e.limit} / {e.rightLimit} km/h"), SpeedLimitEvent e => (e.span, GetSpeedLimitEventDescription(e)), GradeEvent e => (e.span, $"{e.grade:F1} %"), _ => (0.0, $"Unknown event: {ev}"), })