Пример #1
0
        private bool LaunchRandomEvent(CEEvent OverrideEvent = null)
        {
            if (CESettings.Instance.EventCaptorNotifications)
            {
                if (notificationEventExists || progressEventExists)
                {
                    return(false);
                }
            }

            CEEvent returnedEvent;

            if (OverrideEvent == null)
            {
                returnedEvent = CEEventManager.ReturnWeightedChoiceOfEventsRandom();
            }
            else
            {
                returnedEvent = OverrideEvent;
            }

            if (returnedEvent == null)
            {
                return(false);
            }
            notificationEventExists = true;

            if (CESettings.Instance.EventCaptorNotifications)
            {
                try
                {
                    if (!string.IsNullOrWhiteSpace(returnedEvent.NotificationName))
                    {
                        new CESubModule().LoadCampaignNotificationTexture(returnedEvent.NotificationName, 1);
                    }
                    else if (returnedEvent.SexualContent)
                    {
                        new CESubModule().LoadCampaignNotificationTexture("CE_random_sexual_notification", 1);
                    }
                    else
                    {
                        new CESubModule().LoadCampaignNotificationTexture("CE_random_notification", 1);
                    }
                }
                catch (Exception e)
                {
                    InformationManager.DisplayMessage(new InformationMessage("LoadCampaignNotificationTextureFailure", Colors.Red));

                    CECustomHandler.ForceLogToFile("LoadCampaignNotificationTexture");
                    CECustomHandler.ForceLogToFile(e.Message + " : " + e);
                }

                Campaign.Current.CampaignInformationManager.NewMapNoticeAdded(new CEEventMapNotification(returnedEvent, new TextObject("{=CEEVENTS1059}Random event is ready")));
            }
            else
            {
                if (Game.Current.GameStateManager.ActiveState is MapState mapState)
                {
                    Campaign.Current.LastTimeControlMode = Campaign.Current.TimeControlMode;

                    if (!mapState.AtMenu)
                    {
                        _extraVariables.menuToSwitchBackTo = null;
                        _extraVariables.currentBackgroundMeshNameToSwitchBackTo = null;
                        GameMenu.ActivateGameMenu("prisoner_wait");
                    }
                    else
                    {
                        _extraVariables.menuToSwitchBackTo = mapState.GameMenuId;
                        _extraVariables.currentBackgroundMeshNameToSwitchBackTo = mapState.MenuContext.CurrentBackgroundMeshName;
                    }

                    GameMenu.SwitchToMenu(returnedEvent.Name);
                }
            }

            return(true);
        }