Пример #1
0
        static void Postfix(SG_HiringHall_Screen __instance,
                            Pilot ___selectedPilot, LocalizableText ___MWInitialCostText, UIColorRefTracker ___MWCostColor,
                            HBSDOTweenButton ___HireButton)
        {
            Mod.Log.Debug?.Write("Updating UpdateMoneySpot");

            if (___selectedPilot != null)
            {
                Mod.Log.Debug?.Write(" -- pilot is selected");

                // Account for the salary
                CrewDetails details       = ModState.GetCrewDetails(___selectedPilot.pilotDef);
                int         modifiedBonus = (int)Mathf.RoundToInt(details.AdjustedBonus);
                string      bonus         = new Text(Mod.LocalizedText.Labels[ModText.LT_Crew_Bonus_Label],
                                                     new string[] { SimGameState.GetCBillString(Mathf.RoundToInt(modifiedBonus)) })
                                            .ToString();
                Mod.Log.Debug?.Write($"  -- bonus will be: {bonus}");

                ___MWInitialCostText.SetText(bonus);

                if (modifiedBonus > ModState.SimGameState.Funds)
                {
                    Mod.Log.Debug?.Write(" -- Disabling hire.");
                    ___MWCostColor.SetUIColor(UIColor.Red);
                    ___HireButton.SetState(ButtonState.Disabled);
                }
                else
                {
                    Mod.Log.Debug?.Write(" -- Enabling hire.");
                    ___MWCostColor.SetUIColor(UIColor.White);
                    ___HireButton.SetState(ButtonState.Enabled);
                }
            }
        }
Пример #2
0
        static void Postfix(SimGameOptionsMenu __instance,
                            HBSDOTweenButton ___saveGame, HBSTooltipHBSButton ___saveTooltip,
                            HBSDOTweenButton ___restartMission, HBSTooltipHBSButton ___restartTooltip)
        {
            CombatGameState combatGameState = SharedState.Combat;

            if (combatGameState != null && !combatGameState.TurnDirector.IsMissionOver && combatGameState.TurnDirector.GameHasBegun)
            {
                Mod.Log.Trace?.Write("SGOM:CS - in combat.");

                if (Mod.Config.Fixes.DisableCombatRestarts)
                {
                    Mod.Log.Debug?.Write("Disabling combat restarts.");
                    ___restartMission.SetState(ButtonState.Disabled);

                    string             title   = new Text(Mod.LocalizedText.Tooltips[ModText.TT_CombatRestartMission_Title]).ToString();
                    string             details = new Text(Mod.LocalizedText.Tooltips[ModText.TT_CombatRestartMission_Details]).ToString();
                    BaseDescriptionDef def     = new BaseDescriptionDef("SGMTipData", title, details, null);
                    ___restartTooltip.SetStateDataForButtonState(ButtonState.Disabled, TooltipUtilities.GetStateDataFromObject(def));
                }

                if (Mod.Config.Fixes.DisableCombatSaves && ___saveGame.State != ButtonState.Disabled)
                {
                    Mod.Log.Debug?.Write("Disabling combat saves.");
                    ___saveGame.SetState(ButtonState.Disabled);

                    string             title   = new Text(Mod.LocalizedText.Tooltips[ModText.TT_CombatSave_Title]).ToString();
                    string             details = new Text(Mod.LocalizedText.Tooltips[ModText.TT_CombatSave_Details]).ToString();
                    BaseDescriptionDef def     = new BaseDescriptionDef("SGMTipData", title, details, null);
                    ___saveTooltip.SetStateDataForButtonState(ButtonState.Disabled, TooltipUtilities.GetStateDataFromObject(def));
                }
            }
        }
Пример #3
0
        static void Postfix(SGBarracksMWDetailPanel __instance, Pilot p,
                            SGBarracksAdvancementPanel ___advancement, GameObject ___advancementSectionGO,
                            SGBarracksDossierPanel ___dossier,
                            SGBarracksServicePanel ___servicePanel, GameObject ___serviceSectionGO,
                            HBSDOTweenButton ___customizeButton)
        {
            if (p == null)
            {
                return;
            }
            CrewDetails details = ModState.GetCrewDetails(p.pilotDef);

            GameObject skillsButton = __instance.gameObject.FindFirstChildNamed(ModConsts.GO_HBS_Barracks_Skill_Button);

            if (skillsButton == null)
            {
                Mod.Log.Debug?.Write("SkillsButton is null!");
            }

            if (details.IsMechTechCrew || details.IsMedTechCrew || details.IsAerospaceCrew)
            {
                __instance.OnServiceSectionClicked();
                skillsButton.SetActive(false);
            }
            else
            {
                skillsButton.SetActive(true);
            }
        }
Пример #4
0
 public static void Reset()
 {
     // Reinitialize state
     WithdrawalTriggered   = false;
     RoundsUntilWithdrawal = 0;
     RetreatButton         = null;
     BehaviorVarValuesCache.Clear();
     //RangeToTargetsAlliesCache.Clear();
 }
Пример #5
0
        public static void CombatChatModule_CombatInit_Postfix(CombatChatModule __instance, MessageCenter ____messageCenter,
                                                               HBSDOTweenButton ____chatBtn, HBSDOTweenButton ____muteBtn, HBS_InputField ____inputField,
                                                               GameObject ____activeChatWindow, ActiveChatListView ____activeChatList, PassiveChatListView ____passiveChatList)
        {
            ____chatBtn.enabled = true;
            ____chatBtn.gameObject.SetActive(true);
            ____muteBtn.enabled = false;
            ____muteBtn.gameObject.SetActive(false);
            ____inputField.enabled = false;
            ____inputField.gameObject.SetActive(false);
            ____inputField.readOnly = true;

            // Hide the send button
            Transform sendButtonT = ____activeChatWindow.gameObject.transform.Find("uixPrf_genericButton");

            if (sendButtonT != null)
            {
                sendButtonT.gameObject.SetActive(false);
            }
            else
            {
                Mod.Log.Info("Could not find send button to disable!");
            }

            // Set the scroll spacing to 0
            Transform scrollListT = ____activeChatWindow.gameObject.transform.Find("panel_history/uixPrfPanl_listView/ScrollRect/Viewport/List");

            if (scrollListT != null)
            {
                VerticalLayoutGroup scrollListVLG = scrollListT.gameObject.GetComponent <VerticalLayoutGroup>();
                scrollListVLG.spacing = 0;
            }
            else
            {
                Mod.Log.Info("Could not find scrollList to change spacing!");
            }

            // Resize the image background
            Transform imageBackgroundT = ____activeChatWindow.gameObject.transform.Find("image_background");

            if (imageBackgroundT != null)
            {
                RectTransform imageBackgroundRT = imageBackgroundT.gameObject.GetComponent <RectTransform>();
                Rect          ibRect            = imageBackgroundRT.rect;
                Mod.Log.Info($"Background image size: {ibRect.height}h x {ibRect.width}");
                Vector3 newPos = imageBackgroundRT.position;
                newPos.y += 20f;
                imageBackgroundRT.position = newPos;
                imageBackgroundRT.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, ibRect.height - 20);
                imageBackgroundRT.ForceUpdateRectTransforms();
            }
            else
            {
                Mod.Log.Info("Could not find imageBackground to change size!");
            }
        }
Пример #6
0
        public static void CombatChatModule_Init_Postfix(CombatChatModule __instance, MessageCenter ____messageCenter,
                                                         HBSDOTweenButton ____chatBtn, HBSDOTweenButton ____muteBtn, ActiveChatListView ____activeChatList)
        {
            ____chatBtn.enabled = false;
            ____chatBtn.gameObject.SetActive(false);
            ____muteBtn.enabled = false;
            ____muteBtn.gameObject.SetActive(false);

            ____messageCenter.AddSubscriber(MessageCenterMessageType.FloatieMessage, OnFloatie);
            messageCenter = ____messageCenter;
        }
Пример #7
0
        public static void Reset()
        {
            // Reinitialize state
            WithdrawStarted = false;

            CanWithdrawOnRound = -1;
            CanWithdrawOnRound = -1;

            RetreatButton     = null;
            RetreatButtonText = null;
            HUD = null;

            CombatDamage = 0f;
        }
Пример #8
0
        static void Postfix(SG_HiringHall_Screen __instance, GameObject ___WarningAreaObject,
                            HBSDOTweenButton ___HireButton, LocalizableText ___WarningText,
                            HBSTooltip ___NoHireTooltip, Pilot ___selectedPilot)
        {
            Mod.Log.Debug?.Write("Updating MWSelectedPanel:WarningsCheck");

            // Use the warnings area to display the contract length terms
            if (___selectedPilot != null && ___HireButton.State == ButtonState.Enabled)
            {
                ___WarningAreaObject.SetActive(true);

                CrewDetails details = ModState.GetCrewDetails(___selectedPilot.pilotDef);

                string contractTermS = new Text(Mod.LocalizedText.Labels[ModText.LT_Crew_Contract_Term],
                                                new object[] { details.ContractTerm }
                                                ).ToString();
                ___WarningText.SetText(contractTermS);
            }
        }
Пример #9
0
        static void Postfix(SGBarracksMWDetailPanel __instance,
                            Pilot ___curPilot,
                            SGBarracksAdvancementPanel ___advancement, GameObject ___advancementSectionGO,
                            SGBarracksDossierPanel ___dossier,
                            SGBarracksServicePanel ___servicePanel, GameObject ___serviceSectionGO,
                            HBSDOTweenButton ___customizeButton)
        {
            if (___curPilot == null)
            {
                return;
            }

            CrewDetails details = ModState.GetCrewDetails(___curPilot.pilotDef);

            if (details.IsMechTechCrew || details.IsMedTechCrew || details.IsAerospaceCrew)
            {
                ___advancementSectionGO.SetActive(false);
            }
        }
Пример #10
0
            public static bool Prefix(CombatHUDRetreatEscMenu __instance, HBSDOTweenButton ___RetreatButton, CombatGameState ___Combat, CombatHUD ___HUD)
            {
                Mod.Log.Trace?.Write($"CHUDREM:ORBP entered");

                Mod.Log.Debug?.Write($"  RetreatButton pressed -> withdrawStarted:{ModState.WithdrawStarted} " +
                                     $"CurrentRound:{___Combat.TurnDirector.CurrentRound} CanWithdrawOn:{ModState.CanWithdrawOnRound} CanApproachOn:{ModState.CanApproachOnRound}");

                if (ModState.WithdrawStarted && ModState.CanWithdrawOnRound == ___Combat.TurnDirector.CurrentRound)
                {
                    Mod.Log.Debug?.Write($"Checking for combat damage and active enemies");
                    ModState.CombatDamage = Helper.CalculateCombatDamage();
                    if (ModState.CombatDamage > 0 && ___Combat.TurnDirector.DoAnyUnitsHaveContactWithEnemy)
                    {
                        int repairCost = (int)Math.Ceiling(ModState.CombatDamage) * Mod.Config.LeopardRepairCostPerDamage;
                        void withdrawAction()
                        {
                            OnImmediateWithdraw(__instance.IsGoodFaithEffort());
                        }

                        GenericPopupBuilder builder = GenericPopupBuilder.Create(GenericPopupType.Warning,
                                                                                 $"Enemies are within weapons range! If you withdraw now the Leopard will take {SimGameState.GetCBillString(repairCost)} worth of damage.")
                                                      .CancelOnEscape()
                                                      .AddButton("Cancel")
                                                      .AddButton("Withdraw", withdrawAction, true, null);
                        builder.IsNestedPopupWithBuiltInFade = true;
                        ___HUD.SelectionHandler.GenericPopup = builder.Render();
                        return(false);
                    }
                    else
                    {
                        Mod.Log.Info?.Write($" Immediate withdraw due to no enemies");
                        OnImmediateWithdraw(__instance.IsGoodFaithEffort());
                        return(false);
                    }
                }
                else
                {
                    return(true);
                }
            }
Пример #11
0
 static bool Prefix(SGLocationWidget __instance, SimGameState ___simState, HBSDOTweenButton ___storeButton, StarSystem currSystem, GameObject ___NothingToBuyStoreOverlay, GameObject ___LowRepStoreOverlay)
 {
     try {
         Faction           owner      = currSystem.Owner;
         SimGameReputation reputation = ___simState.GetReputation(owner);
         if (reputation <= SimGameReputation.LOATHED)
         {
             ___LowRepStoreOverlay.SetActive(true);
             ___NothingToBuyStoreOverlay.SetActive(false);
             ___storeButton.SetState(ButtonState.Disabled, false);
         }
         else
         {
             ___LowRepStoreOverlay.SetActive(false);
             ___NothingToBuyStoreOverlay.SetActive(false);
             ___storeButton.SetState(ButtonState.Enabled, false);
         }
         return(false);
     }
     catch (Exception e) {
         Logger.LogError(e);
         return(true);
     }
 }
Пример #12
0
        public static void SimGameOptionsMenu_SetSaveTooltip_Postfix(SimGameOptionsMenu __instance, HBSTooltipHBSButton ___saveTooltip, SaveReason ___reason, HBSDOTweenButton ___saveGame)
        {
            if (___saveTooltip == null)
            {
                return;
            }

            GameInstance    battleTechGame = UnityGameInstance.BattleTechGame;
            CombatGameState combat         = battleTechGame.Combat;

            if (combat != null && !combat.TurnDirector.IsMissionOver && combat.TurnDirector.GameHasBegun)
            {
                string             details = "Saving during combat missions disabled to prevent errors and bugs.";
                BaseDescriptionDef def     = new BaseDescriptionDef("SGMTipData", "Unable to Save", details, null);
                ___saveTooltip.SetStateDataForButtonState(ButtonState.Disabled, TooltipUtilities.GetStateDataFromObject(def));
            }
        }
Пример #13
0
        public static void MultiPurchasePopup_Refresh_Postfix(SG_Stores_MultiPurchasePopup __instance, int ___costPerUnit, int ___quantityBeingSold,
                                                              LocalizableText ___TitleText, LocalizableText ___DescriptionText, string ___itemName, HBSDOTweenButton ___ConfirmButton)
        {
            Mod.Log.Debug("SG_S_MPP:R entered.");
            int value = ___costPerUnit * ___quantityBeingSold;

            Mod.Log.Debug($"SG_S_MPP:R   value:{value} = costPerUnit:{___costPerUnit} x quantityBeingSold:{___quantityBeingSold}.");

            string actionS = "??";

            if (State.StoreIsBuying)
            {
                actionS = "BUY";
            }
            else if (State.StoreIsSelling)
            {
                actionS = "SELL";
            }

            Text titleT = new Text($"{actionS}: {___itemName}");

            ___TitleText.SetText(titleT.ToString(), new object[] { });

            Text descT = new Text($"{actionS} FOR <color=#F79B26>{SimGameState.GetCBillString(value)}</color>");

            ___DescriptionText.SetText(descT.ToString(), new object[] { });

            ___ConfirmButton.SetText(actionS);
        }
Пример #14
0
        static void Postfix(MechLabPanel __instance, MechLabDismountWidget ___dismountWidget, HBSDOTweenButton ___btn_mechViewerButton)
        {
            if (__instance.IsSimGame && !HasRun)
            {
                // dismountWidget.gameObject.SetActive(IsSimGame); => change it's rectTransform.sizeDelta.y to 180
                if (___dismountWidget != null && ___dismountWidget.gameObject != null)
                {
                    RectTransform rt        = ___dismountWidget.gameObject.GetComponent <RectTransform>();
                    Vector3       newDeltas = rt.sizeDelta;
                    newDeltas.y  = 180;
                    rt.sizeDelta = newDeltas;
                }

                // btn_mechViewerButton.gameObject.SetActive(IsSimGame); => change it's pos_x from 1274 to 690
                if (___btn_mechViewerButton != null && ___btn_mechViewerButton.gameObject != null)
                {
                    RectTransform rt     = ___btn_mechViewerButton.gameObject.GetComponent <RectTransform>();
                    Vector3       newPos = rt.position;
                    newPos.x   -= 584;
                    rt.position = newPos;
                }

                HasRun = true;
            }
        }
Пример #15
0
        public static void ReplaceTitle(LocalizableText ___TitleText, LocalizableText ___DescriptionText,
                                        string ___itemName, int ___costPerUnit, int ___quantityBeingSold, HBSDOTweenButton ___ConfirmButton)
        {
            if (!SG_Stores_MultiPurchasePopup_Handler.Replace)
            {
                return;
            }

            ___TitleText.SetText($"{SG_Stores_MultiPurchasePopup_Handler.Text} {___itemName}");
            var value = SimGameState.GetCBillString(___costPerUnit * ___quantityBeingSold);

            ___DescriptionText.SetText($"{SG_Stores_MultiPurchasePopup_Handler.Text} FOR <color=#F79B26>{value}</color>");
            ___ConfirmButton.SetText(SG_Stores_MultiPurchasePopup_Handler.Text);
        }