Exemple #1
0
 static bool Prefix(SGNavigationScreen __instance)
 {
     try {
         if (Fields.Deployment)
         {
             UIManager    uiManager = (UIManager)AccessTools.Field(typeof(SGNavigationScreen), "uiManager").GetValue(__instance);
             SimGameState simState  = (SimGameState)AccessTools.Field(typeof(SGNavigationScreen), "simState").GetValue(__instance);
             Action       cleanup   = delegate() {
                 uiManager.ResetFader(UIManagerRootType.PopupRoot);
                 simState.Starmap.Screen.AllowInput(true);
             };
             string primaryButtonText = "Break Contract";
             string message           = "WARNING: This action will break your current deployment contract. Your reputation with the employer and the MRB will be negatively affected.";
             PauseNotification.Show("Navigation Change", message, simState.GetCrewPortrait(SimGameCrew.Crew_Sumire), string.Empty, true, delegate {
                 cleanup();
                 Fields.Deployment = false;
                 if (simState.DoesFactionGainReputation(Fields.DeploymentEmployer))
                 {
                     Settings settings = Helper.LoadSettings();
                     ReflectionHelper.InvokePrivateMethode(simState, "SetReputation", new object[] { Fields.DeploymentEmployer, settings.DeploymentBreakRepCost, StatCollection.StatOperation.Int_Add, null });
                     ReflectionHelper.InvokePrivateMethode(simState, "SetReputation", new object[] { Faction.MercenaryReviewBoard, settings.DeploymentBreakMRBRepCost, StatCollection.StatOperation.Int_Add, null });
                     AccessTools.Field(typeof(SimGameState), "activeBreadcrumb").SetValue(simState, null);
                 }
                 simState.Starmap.SetActivePath();
                 simState.SetSimRoomState(DropshipLocation.SHIP);
             }, primaryButtonText, cleanup, "Cancel");
             simState.Starmap.Screen.AllowInput(false);
             uiManager.SetFaderColor(uiManager.UILookAndColorConstants.PopupBackfill, UIManagerFader.FadePosition.FadeInBack, UIManagerRootType.PopupRoot, true);
             return(false);
         }
         else
         {
             return(true);
         }
     }
     catch (Exception e) {
         Logger.LogError(e);
         return(true);
     }
 }