示例#1
0
        public static void Postfix(CombatHUDRetreatEscMenu __instance, CombatGameState ___Combat, CombatHUD ___HUD)
        {
            Mod.Log.Trace?.Write($"CHUDREM:INIT - entered");

            ModState.HUD    = ___HUD;
            ModState.Combat = ___Combat;

            ModState.RetreatButton = __instance.RetreatButton;
            if (__instance.RetreatButton.gameObject.activeSelf)
            {
                Mod.Log.Info?.Write(" We are in not a priority contract or skirmish, enabling withdrawal.");
                ModState.WithdrawIsAvailable = true;

                Transform textT = __instance.RetreatButton.gameObject.transform.Find("Text");
                if (textT != null)
                {
                    GameObject textGO = textT.gameObject;
                    ModState.RetreatButtonText = textGO.GetComponent <TextMeshProUGUI>();
                }
                else
                {
                    Mod.Log.Error?.Write("Failed to find text component, cannot proceed! Disabling withdrawal logic.");
                    ModState.WithdrawIsAvailable = false;
                }
            }
            else
            {
                Mod.Log.Info?.Write(" We are in a priority contract or skirmish, preventing withdrawal.");
                ModState.WithdrawIsAvailable = true;
            }
        }
 static bool Prefix(CombatHUDRetreatEscMenu __instance) {
   if (MissionControl.Instance.AllowMissionControl() && MissionControl.Instance.IsDynamicWithdrawAllowed()) {
     Main.LogDebug("[CombatHUDRetreatEscMenuOnRetreatConfirmedPatch] Sending Dynamic Withdraw Trigger Message");
     ChunkMessage triggerDynamicWithdrawMessage = new ChunkMessage(ChunkLogic.DYNAMIC_WITHDRAW_CHUNK_GUID);
     UnityGameInstance.Instance.Game.Combat.MessageCenter.PublishMessage(triggerDynamicWithdrawMessage);
     AccessTools.Method(typeof(CombatHUDRetreatEscMenu), "OnRetreatCancelled").Invoke(__instance, null);
     if (!Main.Settings.DynamicWithdraw.DisorderlyWithdrawalCompatibility) return false;
   }
   return true;
 }
示例#3
0
            public static bool Prefix(CombatHUDRetreatEscMenu __instance, CombatGameState ___Combat, CombatHUD ___HUD)
            {
                Mod.Log.Trace?.Write("CHUDREM:ORC entered");

                if (___Combat == null || ___Combat.ActiveContract.ContractTypeValue.IsSkirmish)
                {
                    return(true);
                }
                else
                {
                    int roundsToWait = Helper.RoundsToWaitByAerospace();
                    Mod.Log.Info?.Write($"Player must wait:{roundsToWait} rounds for pickup.");

                    if (roundsToWait > 0)
                    {
                        ModState.WithdrawStarted    = true;
                        ModState.CanWithdrawOnRound = ___Combat.TurnDirector.CurrentRound + roundsToWait;
                        ModState.CanApproachOnRound = ModState.CanWithdrawOnRound + Helper.RoundsToWaitByAerospace();;
                        Mod.Log.Info?.Write($" Withdraw triggered on round {___Combat.TurnDirector.CurrentRound}. canWithdrawOn:{ModState.CanWithdrawOnRound}  canApproachOn: {ModState.CanApproachOnRound}");

                        ModState.RetreatButton = __instance.RetreatButton;
                        ModState.HUD           = ___HUD;

                        Transform textT = __instance.RetreatButton.gameObject.transform.Find("Text");
                        if (textT != null)
                        {
                            GameObject textGO = textT.gameObject;
                            ModState.RetreatButtonText = textGO.GetComponent <TextMeshProUGUI>();
                        }

                        ModState.RetreatButtonText.SetText($"In { roundsToWait } Rounds");

                        GenericPopupBuilder genericPopupBuilder =
                            GenericPopupBuilder.Create(GenericPopupType.Info,
                                                       $"Sumire is inbound and will be overhead in {roundsToWait} rounds. Survive until then!")
                            .AddButton("Continue", new Action(OnContinue), true, null);
                        genericPopupBuilder.IsNestedPopupWithBuiltInFade = true;
                        ___HUD.SelectionHandler.GenericPopup             = genericPopupBuilder.Render();

                        return(false);
                    }
                    else
                    {
                        return(true);
                    }
                }
            }
示例#4
0
            public static void Postfix(CombatHUDRetreatEscMenu __instance, CombatGameState ___Combat, CombatHUD ___HUD)
            {
                Mod.Log.Trace?.Write("CHUDREM:U entered");

                try {
                    Mod.Log.Debug?.Write($" On ESCmenu update -> currentRound:{___Combat.TurnDirector.CurrentRound} canWithdrawOn:{ModState.CanWithdrawOnRound} canApproachOn:{ModState.CanApproachOnRound}");
                    if (___Combat.TurnDirector.CurrentRound < ModState.CanWithdrawOnRound)
                    {
                        int withdrawIn = ModState.CanWithdrawOnRound - ___Combat.TurnDirector.CurrentRound;
                        Mod.Log.Debug?.Write($" Turns to withdraw: {withdrawIn}  currentRound:{___Combat.TurnDirector.CurrentRound} canWithdrawOn:{ModState.CanWithdrawOnRound} canApproachOn:{ModState.CanApproachOnRound}");

                        __instance.RetreatButton.SetState(ButtonState.Disabled, false);
                        ModState.RetreatButtonText.fontSize = 24;
                        ModState.RetreatButtonText.color    = Color.white;
                        ModState.RetreatButtonText.SetText($"In { withdrawIn } Rounds");
                    }
                    else if (___Combat.TurnDirector.CurrentRound == ModState.CanWithdrawOnRound)
                    {
                        Mod.Log.Debug?.Write($" Can withdraw on this turn. currentRound:{___Combat.TurnDirector.CurrentRound} canWithdrawOn:{ModState.CanWithdrawOnRound} canApproachOn:{ModState.CanApproachOnRound}");

                        if (__instance.RetreatButton.BaseState != ButtonState.Enabled)
                        {
                            __instance.RetreatButton.SetState(ButtonState.Enabled, false);
                        }
                        ModState.RetreatButtonText.fontSize = 24;
                        ModState.RetreatButtonText.color    = Color.white;
                        ModState.RetreatButtonText.SetText($"Withdraw");
                    }
                    else if (ModState.CanApproachOnRound > ___Combat.TurnDirector.CurrentRound)
                    {
                        int readyIn = ModState.CanApproachOnRound - ___Combat.TurnDirector.CurrentRound;
                        Mod.Log.Debug?.Write($" Turns to ready: {readyIn}  currentRound:{___Combat.TurnDirector.CurrentRound} canWithdrawOn:{ModState.CanWithdrawOnRound} canApproachOn:{ModState.CanApproachOnRound}");

                        __instance.RetreatButton.SetState(ButtonState.Disabled, false);
                        ModState.RetreatButtonText.fontSize = 24;
                        ModState.RetreatButtonText.color    = Color.white;
                        ModState.RetreatButtonText.SetText($"In { readyIn } Rounds");
                    }
                } catch (Exception e) {
                    Mod.Log.Error?.Write("Failed to perform update logic!");
                    Mod.Log.Error?.Write(e);
                }
            }
示例#5
0
        public static void Postfix(CombatHUDRetreatEscMenu __instance, CombatGameState ___Combat, CombatHUD ___HUD, bool ___isArena)
        {
            Mod.Log.Trace("CHUDREM:U entered");

            if (!___isArena)
            {
                Mod.Log.Debug($" On ESCmenu update -> currentRound:{___Combat.TurnDirector.CurrentRound} canWithdrawOn:{State.CanWithdrawOnRound} canApproachOn:{State.CanApproachOnRound}");
                if (___Combat.TurnDirector.CurrentRound < State.CanWithdrawOnRound)
                {
                    int withdrawIn = State.CanWithdrawOnRound - ___Combat.TurnDirector.CurrentRound;
                    Mod.Log.Debug($" Turns to withdraw: {withdrawIn}  currentRound:{___Combat.TurnDirector.CurrentRound} canWithdrawOn:{State.CanWithdrawOnRound} canApproachOn:{State.CanApproachOnRound}");

                    __instance.RetreatButton.SetState(ButtonState.Disabled, false);
                    State.RetreatButtonText.fontSize = 24;
                    State.RetreatButtonText.color    = Color.white;
                    State.RetreatButtonText.SetText($"In { withdrawIn } Rounds", new object[] { });
                }
                else if (___Combat.TurnDirector.CurrentRound == State.CanWithdrawOnRound)
                {
                    Mod.Log.Debug($" Can withdraw on this turn. currentRound:{___Combat.TurnDirector.CurrentRound} canWithdrawOn:{State.CanWithdrawOnRound} canApproachOn:{State.CanApproachOnRound}");

                    if (__instance.RetreatButton.BaseState != ButtonState.Enabled)
                    {
                        __instance.RetreatButton.SetState(ButtonState.Enabled, false);
                    }
                    State.RetreatButtonText.fontSize = 24;
                    State.RetreatButtonText.color    = Color.white;
                    State.RetreatButtonText.SetText($"Withdraw", new object[] { });
                }
                else if (State.CanApproachOnRound > ___Combat.TurnDirector.CurrentRound)
                {
                    int readyIn = State.CanApproachOnRound - ___Combat.TurnDirector.CurrentRound;
                    Mod.Log.Debug($" Turns to ready: {readyIn}  currentRound:{___Combat.TurnDirector.CurrentRound} canWithdrawOn:{State.CanWithdrawOnRound} canApproachOn:{State.CanApproachOnRound}");

                    __instance.RetreatButton.SetState(ButtonState.Disabled, false);
                    State.RetreatButtonText.fontSize = 24;
                    State.RetreatButtonText.color    = Color.white;
                    State.RetreatButtonText.SetText($"In { readyIn } Rounds", new object[] { });
                }
            }
        }
示例#6
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);
                }
            }