示例#1
0
        protected override void OnLapCompleted(LapInfo lap)
        {
            DriverInfo driver = PluginManager.GetDriverByConnectionId(lap.ConnectionId);

            driver.LapCount = lap.LapNo;
            if (lap.Cuts == 0 && (lap.Laptime < driver.BestLap || driver.BestLap == 0))
            {
                driver.BestLap = lap.Laptime;
            }

            if (this.BroadcastFastestLap > 0)
            {
                // check if this is a new fastest lap for this session
                if (lap.Cuts == 0 && this.PluginManager.CurrentSession.Laps.FirstOrDefault(l => l.Cuts == 0 && l.Laptime < lap.Laptime) == null)
                {
                    this.PluginManager.BroadcastChatMessage(
                        string.Format("{0} has set a new fastest lap: {1}", driver.DriverName, AcServerPluginManager.FormatTimespan((int)lap.Laptime)));
                }
                else if (this.BroadcastFastestLap > 1)
                {
                    if (lap.Cuts == 0)
                    {
                        this.PluginManager.BroadcastChatMessage(
                            string.Format("{0} completed a lap: {1}", driver.DriverName, AcServerPluginManager.FormatTimespan((int)lap.Laptime)));
                    }
                    else
                    {
                        this.PluginManager.BroadcastChatMessage(
                            string.Format("{0} did a lap with {1} cut(s): {2}", driver.DriverName, lap.Cuts, AcServerPluginManager.FormatTimespan((int)lap.Laptime)));
                    }
                }
            }
        }