Esempio n. 1
0
        private static void MainLogic()
        {
            GameFiber.StartNew(delegate
            {
                try
                {
                    while (true)
                    {
                        GameFiber.Yield();
                        if (EnhancedPursuitAI.InPursuit && Game.LocalPlayer.Character.IsInAnyVehicle(false))
                        {
                            if (ExtensionMethods.IsKeyCombinationDownComputerCheck(EnhancedPursuitAI.OpenPursuitTacticsMenuKey, EnhancedPursuitAI.OpenPursuitTacticsMenuModifierKey))
                            {
                                PursuitTacticsMenu.Visible = !PursuitTacticsMenu.Visible;
                            }
                        }
                        else
                        {
                            PursuitTacticsMenu.Visible = false;
                        }

                        if (Functions.IsPlayerPerformingPullover())
                        {
                            if (Functions.GetPulloverSuspect(Functions.GetCurrentPullover()) != CurrentEnhancedTrafficStop.Suspect)
                            {
                                CurrentEnhancedTrafficStop = new EnhancedTrafficStop();

                                StatisticsCounter.AddCountToStatistic("Traffic Stops", "LSPDFR+");
                                Game.LogTrivial("Adding traffic stop count - LSPDFR+");
                                API.Functions.OnTrafficStopInitiated(Functions.GetPulloverSuspect(Functions.GetCurrentPullover()));
                            }
                        }
                        //Shift Q ticket menu handler.
                        else if (!_MenuPool.IsAnyMenuOpen() && !Game.LocalPlayer.Character.IsInAnyVehicle(false) && ExtensionMethods.IsKeyCombinationDownComputerCheck(Offence.OpenTicketMenuKey, Offence.OpenTicketMenuModifierKey) &&
                                 Game.LocalPlayer.Character.GetNearbyPeds(1)[0].Exists() && Game.LocalPlayer.Character.DistanceTo(Game.LocalPlayer.Character.GetNearbyPeds(1)[0]) < 5f)
                        {
                            Game.LocalPlayer.Character.Tasks.ClearImmediately();
                            _MenuPool.ResetMenus(true, true);
                            CurrentEnhancedTrafficStop.SelectedOffences.Clear();
                            SeizeVehicleTicketCheckboxItem.Enabled = false;
                            TicketMenu.ParentMenu = null;
                            foreach (UIMenu m in OffenceCategoryMenus)
                            {
                                m.Visible = false;
                            }
                            TicketMenu.Visible = true;
                        }

                        if (!LSPDFRPlusHandler.BritishPolicingScriptRunning && ExtensionMethods.IsKeyDownComputerCheck(CourtSystem.OpenCourtMenuKey) && (ExtensionMethods.IsKeyDownRightNowComputerCheck(CourtSystem.OpenCourtMenuModifierKey) || CourtSystem.OpenCourtMenuModifierKey == Keys.None))
                        {
                            if (!CourtsMenu.Visible)
                            {
                                CourtsMenu.Visible = true;
                            }
                        }

                        if (_MenuPool.IsAnyMenuOpen())
                        {
                            NativeFunction.Natives.SET_PED_STEALTH_MOVEMENT(Game.LocalPlayer.Character, 0, 0);
                        }

                        //Prevent the traffic stop menu from being used when it shouldn't be.
                        if (TrafficStopMenu.Visible)
                        {
                            if (!Functions.IsPlayerPerformingPullover())
                            {
                                if (TrafficStopMenuEnabled)
                                {
                                    ToggleUIMenuEnabled(TrafficStopMenu, false);
                                    TrafficStopMenuEnabled = false;
                                }
                            }
                            else if (Vector3.Distance2D(Game.LocalPlayer.Character.Position, Functions.GetPulloverSuspect(Functions.GetCurrentPullover()).Position) > TrafficStopMenuDistance)
                            {
                                if (TrafficStopMenuEnabled)
                                {
                                    ToggleUIMenuEnabled(TrafficStopMenu, false);
                                    TrafficStopMenuEnabled = false;
                                }
                            }
                            else if (!TrafficStopMenuEnabled)
                            {
                                ToggleUIMenuEnabled(TrafficStopMenu, true);
                                TrafficStopMenuEnabled = true;
                            }
                        }

                        if (CourtsMenu.Visible)
                        {
                            if (!CourtsMenuPaused)
                            {
                                CourtsMenuPaused = true;
                                Game.IsPaused    = true;
                            }
                            if (ExtensionMethods.IsKeyDownComputerCheck(Keys.Delete))
                            {
                                if (PendingResultsList.Active)
                                {
                                    if (CourtCase.PendingResultsMenuCleared)
                                    {
                                        CourtSystem.DeleteCourtCase(CourtSystem.PendingCourtCases[PendingResultsList.Index]);
                                        PendingResultsList.Index = 0;
                                    }
                                }
                                else if (PublishedResultsList.Active)
                                {
                                    if (CourtCase.ResultsMenuCleared)
                                    {
                                        CourtSystem.DeleteCourtCase(CourtSystem.PublishedCourtCases[PublishedResultsList.Index]);

                                        PublishedResultsList.Index = 0;
                                    }
                                }
                            }

                            if (ExtensionMethods.IsKeyDownComputerCheck(Keys.Insert))
                            {
                                if (PendingResultsList.Active)
                                {
                                    if (CourtCase.PendingResultsMenuCleared)
                                    {
                                        CourtSystem.PendingCourtCases[PendingResultsList.Index].ResultsPublishTime = DateTime.Now;
                                        PendingResultsList.Index = 0;
                                    }
                                }
                            }
                        }
                        else if (CourtsMenuPaused)
                        {
                            CourtsMenuPaused = false;
                            Game.IsPaused    = false;
                        }
                    }
                }
                catch (System.Threading.ThreadAbortException e) { }
                catch (Exception e) { Game.LogTrivial(e.ToString()); }
            });
        }