Esempio n. 1
0
        private static string GetSpeedLimitEventDescription(SpeedLimitEvent e)
        {
            var currentSpeed = Mathf.Abs(PlayerManager.Car.GetForwardSpeed() * 3.6f);
            var color        = "white";

            if (currentSpeed > e.limit + 5f)
            {
                color = e.span < 500f ? "red" : e.span < 1000f ? "orange" : "yellow";
            }
            else if (currentSpeed < e.limit - 10f)
            {
                color = "lime";
            }
            return($"<color={color}>{e.limit} km/h</color>");
        }
Esempio n. 2
0
        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}"),
            })