Prefix(SGBarracksMWDetailPanel __instance, Pilot ___curPilot)
 {
     if (
         Local.state.getItem("cheat_pilotskill_reset") == "" ||
         !(
             Input.GetKey(KeyCode.LeftShift) ||
             Input.GetKey(KeyCode.RightShift)
             )
         )
     {
         return(true);
     }
     GenericPopupBuilder
     .Create(
         "Pilot Reskill",
         "This will set skills to 1 and refund all XP."
         )
     .AddButton("Cancel")
     .AddButton("Pilot Reskill", () =>
     {
         PilotReskill(__instance, ___curPilot);
     })
     .CancelOnEscape()
     .AddFader(
         HBS.LazySingletonBehavior <UIManager>
         .Instance
         .UILookAndColorConstants
         .PopupBackfill
         )
     .Render();
     return(false);
 }
Beispiel #2
0
        public static void Postfix(SGBarracksWidget __instance, string button,
                                   SGBarracksMWDetailPanel ___mechWarriorDetails)
        {
            if (button != "Close")
            {
                return;
            }
            var sim = UnityGameInstance.BattleTechGame.Simulation;

            if (sim == null)
            {
                return;
            }

            var curPilot = Traverse.Create(___mechWarriorDetails).Field("curPilot").GetValue <Pilot>();

            if (String.IsNullOrEmpty(curPilot.GUID))
            {
                return;
            }
            if (!ModState.PilotCurrentFreeXP.ContainsKey(curPilot.GUID))
            {
                ModState.PilotCurrentFreeXP.Add(curPilot.GUID, curPilot.UnspentXP);
                Mod.Log.Info?.Write(
                    $"CHEATDETECTION: {curPilot.Description.Id}: Added key  {curPilot.GUID} to PilotCurrentXP with UnspentXP {curPilot.UnspentXP} but should have been done already. At SGBarracksWidget.ReceiveButtonPress, Post.");
            }

            ModState.PilotCurrentFreeXP[curPilot.GUID] = curPilot.UnspentXP;
            Mod.Log.Info?.Write(
                $"CHEATDETECTION: {curPilot.Description.Id}:  {curPilot.GUID} Free XP state was {ModState.PilotCurrentFreeXP[curPilot.GUID]} after changing to basePilot {curPilot.UnspentXP} At SGBarracksWidget.ReceiveButtonPress, Post.");
        }
Beispiel #3
0
 private static void RespecAndRefresh(SGBarracksMWDetailPanel __instance, Pilot pilot)
 {
     WipePilotStats(pilot);
     UnityGameInstance.BattleTechGame.Simulation.AddFunds(-modSettings.cost);
     pilot.pilotDef.PilotTags.Add("HasRetrained");
     __instance.DisplayPilot(pilot);
 }
Beispiel #4
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);
            }
        }
Beispiel #5
0
            public static bool Prefix(SGBarracksMWDetailPanel __instance, Pilot ___curPilot)
            {
                var hotkeyPerformed = Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift);

                if (!hotkeyPerformed)
                {
                    return(true);
                }

                var simState = UnityGameInstance.BattleTechGame.Simulation;

                if (modSettings.onceOnly && ___curPilot.pilotDef.PilotTags.Contains("HasRetrained"))
                {
                    GenericPopupBuilder
                    .Create("Unable To Retrain", "Each pilot can only retrain once.")
                    .AddButton("Acknowledged")
                    .CancelOnEscape()
                    .AddFader(LazySingletonBehavior <UIManager> .Instance.UILookAndColorConstants.PopupBackfill)
                    .Render();
                    return(true);
                }

                if (modSettings.trainingModuleRequired && !simState.ShipUpgrades.Any(u => u.Tags.Any(t => t.Contains("argo_trainingModule2"))))
                {
                    GenericPopupBuilder
                    .Create("Unable To Retrain", "You must have built the Training Module 2 upgrade aboard the Argo.")
                    .AddButton("Acknowledged")
                    .CancelOnEscape()
                    .AddFader(LazySingletonBehavior <UIManager> .Instance.UILookAndColorConstants.PopupBackfill)
                    .Render();
                    return(true);
                }

                if (simState.Funds < modSettings.cost)
                {
                    GenericPopupBuilder
                    .Create("Unable To Retrain", $"You need ¢{modSettings.cost:N0}.")
                    .AddButton("Acknowledged")
                    .CancelOnEscape()
                    .AddFader(LazySingletonBehavior <UIManager> .Instance.UILookAndColorConstants.PopupBackfill)
                    .Render();
                    return(true);
                }

                var message = modSettings.onceOnly
                    ? $"This will set skills to 1 and refund all XP.\nIt will cost ¢{modSettings.cost:N0} and each pilot can only retrain once."
                    : $"This will set skills to 1 and refund all XP.\nIt will cost ¢{modSettings.cost:N0}";

                GenericPopupBuilder
                .Create("Retrain", message)
                .AddButton("Cancel")
                .AddButton("Retrain Pilot", () => RespecAndRefresh(__instance, ___curPilot))
                .CancelOnEscape()
                .AddFader(LazySingletonBehavior <UIManager> .Instance.UILookAndColorConstants.PopupBackfill)
                .Render();
                return(false);
            }
Beispiel #6
0
            public static void Postfix(SGBarracksMWDetailPanel __instance,
                                       Pilot p,
                                       SGBarracksAdvancementPanel ___advancement
                                       )
            {
                var sim = UnityGameInstance.BattleTechGame.Simulation;


                var gunPips   = Traverse.Create(___advancement).Field("gunPips").GetValue <List <SGBarracksSkillPip> >();
                var pilotPips = Traverse.Create(___advancement).Field("pilotPips").GetValue <List <SGBarracksSkillPip> >();
                var gutPips   = Traverse.Create(___advancement).Field("gutPips").GetValue <List <SGBarracksSkillPip> >();
                var tacPips   = Traverse.Create(___advancement).Field("tacPips").GetValue <List <SGBarracksSkillPip> >();


                var abilityDefs = p.pilotDef.AbilityDefs.Where(x => x.IsPrimaryAbility == true);

                //loop through abilities the pilot has, and place those ability icons/tooltips in the appropriate pip slot.
                foreach (AbilityDef ability in abilityDefs)
                {
                    if (ability.ReqSkill == SkillType.Gunnery)
                    {
                        Traverse.Create(gunPips[ability.ReqSkillLevel - 1]).Field("abilityIcon").GetValue <SVGImage>().vectorGraphics = ability.AbilityIcon;
                        Traverse.Create(gunPips[ability.ReqSkillLevel - 1]).Field("AbilityTooltip").GetValue <HBSTooltip>()
                        .SetDefaultStateData(TooltipUtilities.GetStateDataFromObject(ability.Description));
                    }
                }

                foreach (AbilityDef ability in abilityDefs)
                {
                    if (ability.ReqSkill == SkillType.Piloting)
                    {
                        Traverse.Create(pilotPips[ability.ReqSkillLevel - 1]).Field("abilityIcon").GetValue <SVGImage>().vectorGraphics = ability.AbilityIcon;
                        Traverse.Create(pilotPips[ability.ReqSkillLevel - 1]).Field("AbilityTooltip").GetValue <HBSTooltip>()
                        .SetDefaultStateData(TooltipUtilities.GetStateDataFromObject(ability.Description));
                    }
                }

                foreach (AbilityDef ability in abilityDefs)
                {
                    if (ability.ReqSkill == SkillType.Guts)
                    {
                        Traverse.Create(gutPips[ability.ReqSkillLevel - 1]).Field("abilityIcon").GetValue <SVGImage>().vectorGraphics = ability.AbilityIcon;
                        Traverse.Create(gutPips[ability.ReqSkillLevel - 1]).Field("AbilityTooltip").GetValue <HBSTooltip>()
                        .SetDefaultStateData(TooltipUtilities.GetStateDataFromObject(ability.Description));
                    }
                }

                foreach (AbilityDef ability in abilityDefs)
                {
                    if (ability.ReqSkill == SkillType.Tactics)
                    {
                        Traverse.Create(tacPips[ability.ReqSkillLevel - 1]).Field("abilityIcon").GetValue <SVGImage>().vectorGraphics = ability.AbilityIcon;
                        Traverse.Create(tacPips[ability.ReqSkillLevel - 1]).Field("AbilityTooltip").GetValue <HBSTooltip>()
                        .SetDefaultStateData(TooltipUtilities.GetStateDataFromObject(ability.Description));
                    }
                }
            }
        PilotReskill(SGBarracksMWDetailPanel __instance, Pilot ___curPilot)
        {
            var sim      = UnityGameInstance.BattleTechGame.Simulation;
            var pilotDef = ___curPilot.pilotDef.CopyToSim();

            foreach (var val in sim.Constants.Story.CampaignCommanderUpdateTags)
            {
                if (!sim.CompanyTags.Contains(val))
                {
                    sim.CompanyTags.Add(val);
                }
            }
            // save xpUsed
            var xpUsed = (
                sim.GetLevelRangeCost(1, pilotDef.SkillPiloting - 1)
                + sim.GetLevelRangeCost(1, pilotDef.SkillGunnery - 1)
                + sim.GetLevelRangeCost(1, pilotDef.SkillGuts - 1)
                + sim.GetLevelRangeCost(1, pilotDef.SkillTactics - 1)
                );

            // handle xpUsed overflow
            if (xpUsed < 0)
            {
                xpUsed = 0x40000000;
            }
            // reset ___curPilot
            Traverse.Create(pilotDef).Property("BasePiloting").SetValue(1);
            Traverse.Create(pilotDef).Property("BaseGunnery").SetValue(1);
            Traverse.Create(pilotDef).Property("BaseGuts").SetValue(1);
            Traverse.Create(pilotDef).Property("BaseTactics").SetValue(1);
            Traverse.Create(pilotDef).Property("BonusPiloting").SetValue(1);
            Traverse.Create(pilotDef).Property("BonusGunnery").SetValue(1);
            Traverse.Create(pilotDef).Property("BonusGuts").SetValue(1);
            Traverse.Create(pilotDef).Property("BonusTactics").SetValue(1);
            pilotDef.abilityDefNames.Clear();
            pilotDef.SetSpentExperience(0);
            pilotDef.ForceRefreshAbilityDefs();
            pilotDef.ResetBonusStats();
            ___curPilot.FromPilotDef(pilotDef);
            // reset xpUsed
            ___curPilot.AddExperience(0, "reset", xpUsed);
            // ___curPilot.AddExperience(0, "reset", 1234567);
            __instance.DisplayPilot(___curPilot);
        }
Beispiel #8
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);
            }
        }
Beispiel #9
0
        public static void Postfix(SGBarracksMWDetailPanel __instance, Pilot ___tempPilot, Pilot ___curPilot)
        {
            var sim = UnityGameInstance.BattleTechGame.Simulation;

            if (sim == null)
            {
                return;
            }
            if (String.IsNullOrEmpty(___curPilot.GUID))
            {
                return;
            }
            if (!ModState.PilotCurrentFreeXP.ContainsKey(___curPilot.GUID))
            {
                ModState.PilotCurrentFreeXP.Add(___curPilot.GUID, ___curPilot.UnspentXP);
                Mod.Log.Info?.Write(
                    $"CHEATDETECTION: {___curPilot.Description.Id}: Added key  {___curPilot.GUID}  to PilotCurrentXP with UnspentXP {___curPilot.UnspentXP} but should have been done already. At OnPilotReset, Post.");
            }

            ModState.PilotCurrentFreeXP[___curPilot.GUID] = ___curPilot.UnspentXP;
            Mod.Log.Info?.Write(
                $"CHEATDETECTION: {___curPilot.Description.Id}:  {___curPilot.GUID} Free XP state was {ModState.PilotCurrentFreeXP[___curPilot.GUID]} after changing to basePilot {___curPilot.UnspentXP} at OnPilotReset, Post.");
        }
Beispiel #10
0
        private static void RespecAndRefresh(SGBarracksMWDetailPanel __instance, Pilot pilot)
        {
            Logger.Log($"===============================================================");
            Logger.Log($"Before:\t{pilot.pilotDef.ExperienceSpent}, {pilot.pilotDef.ExperienceUnspent}");
            Logger.Log($"Skill:\t{pilot.pilotDef.SkillGunnery}, {pilot.pilotDef.SkillPiloting}, {pilot.pilotDef.SkillGuts}, {pilot.pilotDef.SkillTactics}");
            Logger.Log($"Base:\t{pilot.pilotDef.BaseGunnery}, {pilot.pilotDef.BasePiloting}, {pilot.pilotDef.BaseGuts}, {pilot.pilotDef.BaseTactics}");
            Logger.Log($"Bonus:\t{pilot.pilotDef.BonusGunnery}, {pilot.pilotDef.BonusPiloting}, {pilot.pilotDef.BonusGuts}, {pilot.pilotDef.BonusTactics}");

            SimGameState sim  = UnityGameInstance.BattleTechGame.Simulation;
            int          cost = GetRespecCost(sim, pilot);
            int          days = GetRespecInjuryDays(sim, pilot) + sim.GetPilotTimeoutTimeRemaining(pilot);

            RespecPilot(pilot);
            sim.AddFunds(-cost);

            // currently bugged: AddInjuryDays(sim, pilot, days);
            pilot.pilotDef.SetTimeoutTime(days);
            pilot.pilotDef.PilotTags.Add("pilot_lightinjury");
            sim.RefreshInjuries();

            pilot.pilotDef.PilotTags.Add("HasRetrained");
            __instance.DisplayPilot(pilot);
            __instance.ForceRefreshImmediate();
            sim.RoomManager.RefreshDisplay();
            Logger.Log($"===============================================================");
            Logger.Log($"cost: {cost}, days: {days}");
            Logger.Log($"===============================================================");
            Logger.Log($"After:\t{pilot.pilotDef.ExperienceSpent}, {pilot.pilotDef.ExperienceUnspent}");
            Logger.Log($"Skill:\t{pilot.pilotDef.SkillGunnery}, {pilot.pilotDef.SkillPiloting}, {pilot.pilotDef.SkillGuts}, {pilot.pilotDef.SkillTactics}");
            Logger.Log($"Base:\t{pilot.pilotDef.BaseGunnery}, {pilot.pilotDef.BasePiloting}, {pilot.pilotDef.BaseGuts}, {pilot.pilotDef.BaseTactics}");
            Logger.Log($"Bonus:\t{pilot.pilotDef.BonusGunnery}, {pilot.pilotDef.BonusPiloting}, {pilot.pilotDef.BonusGuts}, {pilot.pilotDef.BonusTactics}");

            //invoking private method:  sim.RespecPilot(pilot); // bugged method!!!
            //typeof(ToHit).GetMethod("RespecPilot", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).Invoke(sim, new object[] { pilot });
            //pilot.AddExperience(0, "respec", experienceSpent);
        }
Beispiel #11
0
            public static void Prefix(SGBarracksMWDetailPanel __instance, Pilot p)
            {
                UseSavedPilot = true;
                SavedPilot    = p;
                isBookish     = false;
                if (p.pilotDef.PilotTags.Contains("pilot_bookish"))
                {
                    isBookish = true;
                }

                isKlutz = false;
                if (p.pilotDef.PilotTags.Contains("pilot_klutz"))
                {
                    isKlutz = true;
                }

                isAssassin = false;
                if (p.pilotDef.PilotTags.Contains("pilot_assassin"))
                {
                    isAssassin = true;
                }

                __instance.Initialize(saveSimState);
            }
            public static bool Prefix(SGBarracksMWDetailPanel __instance, Pilot ___curPilot, SGBarracksDossierPanel ___dossier)
            {
                var background = UIManager.Instance.UILookAndColorConstants.PopupBackfill;

                var hk = Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl);

                if (!hk)
                {
                    return(true);
                }
                var resetSpecs = true;

                if (___curPilot.IsPlayerCharacter && SpecManager.ManagerInstance.StratComs.Count > 1)
                {
                    GenericPopupBuilder
                    .Create("Change Stratcoms or Reset Specs?",
                            "Do you wish to change StratComs or reset specializations?.")
                    .AddButton("Change StratComs", () =>
                    {
                        var stratDesc = "";
                        var stratcoms = SpecManager.ManagerInstance.StratComs;
                        foreach (var stratCom in stratcoms)
                        {
                            var description =
                                $"<b>{stratCom.StratComName}:</b> {stratCom.description}\n\n";
                            stratDesc += description;
                        }

                        var popup = GenericPopupBuilder.Create("Select Active StratCom", stratDesc).CancelOnEscape()
                                    .AddFader(background);
                        foreach (var stratCom in stratcoms)
                        {
                            popup.AddButton(stratCom.StratComName, () =>
                            {
                                SpecManager.ManagerInstance.SetStratCom(stratCom.StratComID, ___curPilot, ___dossier, __instance);
                                resetSpecs = false;
                            });
                        }
                        popup.Render();
                    })
                    .AddButton("Reset Specs", () =>
                    {
                        if (!String.IsNullOrEmpty(ModInit.modSettings.argoUpgradeToReset) && resetSpecs &&
                            !sim.CompanyTags.Contains(ModInit.modSettings.argoUpgradeToReset))
                        {
                            GenericPopupBuilder
                            .Create("Unable To Reset Specializations", $"Required Argo Upgrade Not Found: {ModInit.modSettings.argoUpgradeToReset}.")
                            .AddButton("Understood")
                            .CancelOnEscape()
                            .AddFader(background)
                            .Render();
                        }

                        else if ((!String.IsNullOrEmpty(ModInit.modSettings.argoUpgradeToReset) && resetSpecs &&
                                  sim.CompanyTags.Contains(ModInit.modSettings.argoUpgradeToReset)) ||
                                 String.IsNullOrEmpty(ModInit.modSettings.argoUpgradeToReset))
                        {
                            GenericPopupBuilder
                            .Create("Reset Specializations",
                                    "Are you sure you want to reset all specializations and progress for this pilot?")
                            .AddButton("Cancel")
                            .AddButton("Reset Mission Specs",
                                       () => SpecManager.ManagerInstance.ResetMissionSpecs(___curPilot, ___dossier,
                                                                                           __instance))
                            .AddButton("Reset Opfor Specs",
                                       () => SpecManager.ManagerInstance.ResetOpForSpecs(___curPilot, ___dossier,
                                                                                         __instance))
                            .CancelOnEscape()
                            .AddFader(background)
                            .Render();
                        }
                    }).CancelOnEscape()
                    .AddFader(background)
                    .Render();
                    return(false);
                }

                if (!String.IsNullOrEmpty(ModInit.modSettings.argoUpgradeToReset) && resetSpecs &&
                    !sim.CompanyTags.Contains(ModInit.modSettings.argoUpgradeToReset))
                {
                    GenericPopupBuilder
                    .Create("Unable To Reset Specializations", $"Required Argo Upgrade Not Found: {ModInit.modSettings.argoUpgradeToReset}.")
                    .AddButton("Understood")
                    .CancelOnEscape()
                    .AddFader(background)
                    .Render();
                    return(false);
                }

                else if ((!String.IsNullOrEmpty(ModInit.modSettings.argoUpgradeToReset) && resetSpecs &&
                          sim.CompanyTags.Contains(ModInit.modSettings.argoUpgradeToReset)) || String.IsNullOrEmpty(ModInit.modSettings.argoUpgradeToReset))
                {
                    GenericPopupBuilder
                    .Create("Reset Specializations", "Are you sure you want to reset all specializations and progress for this pilot?")
                    .AddButton("Cancel")
                    .AddButton("Reset Mission Specs", () => SpecManager.ManagerInstance.ResetMissionSpecs(___curPilot, ___dossier, __instance))
                    .AddButton("Reset Opfor Specs", () => SpecManager.ManagerInstance.ResetOpForSpecs(___curPilot, ___dossier, __instance))
                    .CancelOnEscape()
                    .AddFader(background)
                    .Render();
                    return(false);
                }
                else
                {
                    return(false);
                }
            }
Beispiel #13
0
            public static bool Prefix(SGBarracksMWDetailPanel __instance, Pilot ___curPilot)
            {
                var hotkeyPerformed = Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift);

                if (!hotkeyPerformed)
                {
                    return(true);
                }

                var simState = UnityGameInstance.BattleTechGame.Simulation;

                if (Main.Settings.OnceOnly && ___curPilot.pilotDef.PilotTags.Contains("HasRetrained"))
                {
                    GenericPopupBuilder
                    .Create("Unable To Retrain", "Each pilot can only retrain once.")
                    .AddButton("Acknowledged")
                    .CancelOnEscape()
                    .AddFader(backfill)
                    .Render();
                    return(true);
                }

                if (Main.Settings.TrainingModuleRequired && !simState.ShipUpgrades.Any(u => u.Tags.Any(t => t.Contains("argo_trainingModule2"))))
                {
                    GenericPopupBuilder
                    .Create("Unable To Retrain", "You must have built the Training Module 2 upgrade aboard the Argo.")
                    .AddButton("Acknowledged")
                    .CancelOnEscape()
                    .AddFader(backfill)
                    .Render();
                    return(true);
                }

                var sim  = UnityGameInstance.BattleTechGame.Simulation;
                var cost = GetRespecCost(sim, ___curPilot);
                var days = GetRespecInjuryDays(sim, ___curPilot);

                if (simState.Funds < Main.Settings.Cost)
                {
                    GenericPopupBuilder
                    .Create("Unable To Retrain", $"You need ¢{cost:N0}.")
                    .AddButton("Acknowledged")
                    .CancelOnEscape()
                    .AddFader(backfill)
                    .Render();
                    return(true);
                }
                var message = "This will set skills back to 1 and refund all XP.";

                //var message = "This will set skills back to their intial values and refund all XP.";

                message += $"\nIt will cost ¢{cost:N0}";

                message += (days > 0) ? $" and the pilot will be unavailable for {days:N0} days."
                                            : ".";

                message += Main.Settings.OnceOnly ? $"\nEach pilot can only retrain once."
                                                  : "";

                GenericPopupBuilder
                .Create("Retrain", message)
                .AddButton("Cancel")
                .AddButton("Retrain Pilot", () => RespecAndRefresh(__instance, ___curPilot))
                .CancelOnEscape()
                .AddFader(backfill)
                .Render();
                return(false);
            }