Exemplo n.º 1
0
        static void Postfix(TaskManagementElement element)
        {
            try {
                Flareup flareup = Utilities.currentFlareup();
                if (element.Entry.ID != "nextflareupContract" || flareup == null)
                {
                    return;
                }

                WIIC.sim.SetTimeMoving(false);
                PauseNotification.Show("Flareup Details", flareup.getDescription(), WIIC.sim.GetCrewPortrait(SimGameCrew.Crew_Sumire), "", true, null);
            } catch (Exception e) {
                WIIC.modLog.Error?.Write(e);
            }
        }
Exemplo n.º 2
0
 static bool Prefix(SimGameState __instance, Action continueAction, Action cancelAction)
 {
     try {
         if (__instance.ActiveTravelContract == null)
         {
             return(false);
         }
         string primaryButtonText = Strings.T("Confirm");
         string message           = Strings.T("Commander, we're locked into our existing contract already. We can't take another one without seeing this one through first. We've got enough problems with people shooting us already, let's not add lawyers to the mix.");
         PauseNotification.Show("CONTRACT VIOLATION", message, __instance.GetCrewPortrait(SimGameCrew.Crew_Darius), string.Empty, true, cancelAction, primaryButtonText, null, null);
         return(false);
     }
     catch (Exception e) {
         PersistentMapClient.Logger.LogError(e);
         return(false);
     }
 }
Exemplo n.º 3
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);
     }
 }
Exemplo n.º 4
0
 static bool Prefix(SGContractsWidget __instance)
 {
     try {
         SimGameState Sim = (SimGameState)AccessTools.Property(typeof(SGContractsWidget), "Sim").GetValue(__instance, null);
         if (__instance.SelectedContract.Override.travelOnly && !__instance.SelectedContract.IsPriorityContract && Sim.ActiveMechs.Count < 8)
         {
             string message = "Commander, a deployment is a longer term arrangement with an employer, that may require missions to be done without time between them for repairs. I strongly encourage you to only deploy on this arrangement if we are capable of fielding multiple lances with little or no time for repairs, just in case.";
             PauseNotification.Show("Deployment", message,
                                    Sim.GetCrewPortrait(SimGameCrew.Crew_Darius), string.Empty, true, delegate {
                 __instance.NegotiateContract(__instance.SelectedContract, null);
             }, "Do it anyways", null, "Cancel");
             return(false);
         }
         else
         {
             return(true);
         }
     }
     catch (Exception e) {
         Logger.LogError(e);
         return(true);
     }
 }
Exemplo n.º 5
0
        private static bool Prefix(SGNavigationScreen __instance)
        {
            try {
                Flareup flareup = Utilities.currentFlareup();
                WIIC.modLog.Warn?.Write($"OnTravelCourseAccepted. Flareup: {flareup}, ActiveTravelContract: {WIIC.sim.ActiveTravelContract}");
                if (flareup == null)
                {
                    return(true);
                }

                if (!WIIC.flareups.ContainsKey(WIIC.sim.CurSystem.ID))
                {
                    WIIC.modLog.Warn?.Write($"Found company tag indicating flareup participation, but no matching flareup for {WIIC.sim.CurSystem.ID}");
                    WIIC.sim.CompanyTags.Remove("WIIC_helping_attacker");
                    WIIC.sim.CompanyTags.Remove("WIIC_helping_defender");
                    return(true);
                }

                UIManager uiManager = (UIManager)AccessTools.Field(typeof(SGNavigationScreen), "uiManager").GetValue(__instance);

                void cleanup()
                {
                    uiManager.ResetFader(UIManagerRootType.PopupRoot);
                    WIIC.sim.Starmap.Screen.AllowInput(true);
                }

                string title             = Strings.T("Navigation Change");
                string primaryButtonText = Strings.T("Break Deployment");
                string cancel            = Strings.T("Cancel");
                string message           = Strings.T("Leaving {0} will break our current deployment. Our reputation with {1} and the MRB will suffer, Commander.", flareup.location.Name, flareup.employer.FactionDef.ShortName);
                WIIC.modLog.Info?.Write(message);
                PauseNotification.Show(title, message, WIIC.sim.GetCrewPortrait(SimGameCrew.Crew_Sumire), string.Empty, true, delegate {
                    try {
                        WIIC.modLog.Info?.Write("Breaking deployment contract");

                        Flareup flareup2 = Utilities.currentFlareup();
                        WIIC.modLog.Info?.Write("Flareup: {flareup2}");

                        if (flareup2 != null && flareup2.employer.DoesGainReputation)
                        {
                            WIIC.modLog.Info?.Write("Employer: {flareup2.employer}");

                            float employerRepBadFaithMod = WIIC.sim.Constants.Story.EmployerRepBadFaithMod;
                            WIIC.modLog.Info?.Write("employerRepBadFaithMod: {employerRepBadFaithMod}");
                            WIIC.modLog.Info?.Write("CAREER: {SimGameState.SimGameType.CAREER}");
                            WIIC.modLog.Info?.Write("difficulty: {flareup2.location.Def.GetDifficulty(SimGameState.SimGameType.CAREER)}");
                            int num = (int)Math.Round(flareup2.location.Def.GetDifficulty(SimGameState.SimGameType.CAREER) * employerRepBadFaithMod);

                            WIIC.sim.SetReputation(flareup2.employer, num);
                            WIIC.sim.SetReputation(FactionEnumeration.GetMercenaryReviewBoardFactionValue(), num);
                        }

                        WIIC.sim.CompanyTags.Remove("WIIC_helping_attacker");
                        WIIC.sim.CompanyTags.Remove("WIIC_helping_defender");

                        WIIC.sim.RoomManager.RefreshTimeline(false);
                        WIIC.sim.Starmap.SetActivePath();
                        WIIC.sim.SetSimRoomState(DropshipLocation.SHIP);

                        cleanup();
                    } catch (Exception e) {
                        WIIC.modLog.Error?.Write(e);
                    }
                }, primaryButtonText, cleanup, cancel);

                WIIC.sim.Starmap.Screen.AllowInput(false);
                uiManager.SetFaderColor(uiManager.UILookAndColorConstants.PopupBackfill, UIManagerFader.FadePosition.FadeInBack, UIManagerRootType.PopupRoot);
                return(false);
            } catch (Exception e) {
                WIIC.modLog.Error?.Write(e);
                return(true);
            }
        }