static void Postfix(CombatHUDFireButton __instance, CombatHUDFireButton.FireMode value)
 {
     if (__instance.gameObject != null)
     {
         if (__instance.gameObject.name == ModConsts.ChargeFB_GO_ID)
         {
             string localText = new Localize.Text(Mod.LocalizedText.Labels[ModText.LT_Label_Melee_Type_Charge]).ToString();
             __instance.FireText.SetText(localText, new object[] { });
         }
         else if (__instance.gameObject.name == ModConsts.KickFB_GO_ID)
         {
             string localText = new Localize.Text(Mod.LocalizedText.Labels[ModText.LT_Label_Melee_Type_Kick]).ToString();
             __instance.FireText.SetText(localText, new object[] { });
         }
         else if (__instance.gameObject.name == ModConsts.PhysicalWeaponFB_GO_ID)
         {
             string localText = new Localize.Text(Mod.LocalizedText.Labels[ModText.LT_Label_Melee_Type_Physical_Weapon]).ToString();
             __instance.FireText.SetText(localText, new object[] { });
         }
         else if (__instance.gameObject.name == ModConsts.PunchFB_GO_ID)
         {
             string localText = new Localize.Text(Mod.LocalizedText.Labels[ModText.LT_Label_Melee_Type_Punch]).ToString();
             __instance.FireText.SetText(localText, new object[] { });
         }
     }
 }
 public static void Postfix(CombatHUDFireButton __instance, CombatHUDFireButton.FireMode value)
 {
     try
     {
         if (value == CombatHUDFireButton.FireMode.Engage && Fields.JuggernautCharges)
         {
             Logger.Info($"[CombatHUDFireButton_CurrentFireMode_POSTFIX] Overriding FireText...");
             __instance.FireText.SetText("CHARGE!");
         }
     }
     catch (Exception e)
     {
         Logger.Error(e);
     }
 }
        static CombatHUDFireButton CloneCHUDFireButton(GameObject parent, CombatHUDFireButton cloneSource, string goName, CombatGameState Combat, CombatHUD HUD)
        {
            CombatHUDFireButton newButton = GameObject.Instantiate <CombatHUDFireButton>(cloneSource);

            newButton.Init(Combat, HUD);
            newButton.gameObject.transform.parent = parent.transform;
            Mod.UILog.Trace?.Write($"Created {goName} and attached to parent.");

            newButton.gameObject.name = goName;
            newButton.gameObject.transform.SetAsFirstSibling();
            newButton.gameObject.transform.localScale = Vector3.one;

            RectTransform rectTransform = newButton.gameObject.GetComponent <RectTransform>();

            rectTransform.sizeDelta = new Vector2(240f, 70f); // Default is 160, 80

            Image image = newButton.gameObject.GetComponent <Image>();

            image.color = new Color(255f, 255f, 255f, 204f);

            LayoutElement layoutElement = newButton.gameObject.GetComponent <LayoutElement>();

            layoutElement.minWidth        = 240f;
            layoutElement.preferredWidth  = 240f;
            layoutElement.minHeight       = 70f;
            layoutElement.preferredHeight = 70f;
            layoutElement.ignoreLayout    = false;

            GameObject punchOverheatWarn = newButton.gameObject.transform.Find("overheatWarn").gameObject;

            punchOverheatWarn.SetActive(false);
            GameObject punchShutdownWarn = newButton.gameObject.transform.Find("shutdownWarn").gameObject;

            punchShutdownWarn.SetActive(false);
            GameObject sideWedges = newButton.gameObject.transform.Find("confirmFrame_sideWedges (1)").gameObject;

            sideWedges.SetActive(false);

            Mod.UILog.Trace?.Write($"Redid layout for {goName}.");
            return(newButton);
        }
        static bool Prefix(CombatHUDFireButton __instance)
        {
            if (__instance == null || __instance.gameObject == null)
            {
                return(true);
            }

            Mod.UILog.Info?.Write($"CHUDFB - OnClick FIRED for FireMode: {__instance.CurrentFireMode}");

            bool shouldReturn = true;
            CombatHUDAttackModeSelector selector = SharedState.CombatHUD.AttackModeSelector;

            if (__instance.gameObject.name == ModConsts.ChargeFB_GO_ID)
            {
                MeleeState meleeState = ModState.GetMeleeState(
                    SharedState.CombatHUD.SelectionHandler.ActiveState.SelectedActor,
                    SharedState.CombatHUD.SelectionHandler.ActiveState.PreviewPos);
                ModState.AddOrUpdateSelectedAttack(
                    SharedState.CombatHUD.SelectionHandler.ActiveState.SelectedActor,
                    meleeState.Charge
                    );
                Mod.UILog.Info?.Write("User selected Charge button");
                shouldReturn = false;
            }
            else if (__instance.gameObject.name == ModConsts.KickFB_GO_ID)
            {
                MeleeState meleeState = ModState.GetMeleeState(
                    SharedState.CombatHUD.SelectionHandler.ActiveState.SelectedActor,
                    SharedState.CombatHUD.SelectionHandler.ActiveState.PreviewPos);
                ModState.AddOrUpdateSelectedAttack(
                    SharedState.CombatHUD.SelectionHandler.ActiveState.SelectedActor,
                    meleeState.Kick
                    );
                Mod.UILog.Info?.Write("User selected Kick button");
                shouldReturn = false;
            }
            else if (__instance.gameObject.name == ModConsts.PhysicalWeaponFB_GO_ID)
            {
                MeleeState meleeState = ModState.GetMeleeState(
                    SharedState.CombatHUD.SelectionHandler.ActiveState.SelectedActor,
                    SharedState.CombatHUD.SelectionHandler.ActiveState.PreviewPos);
                ModState.AddOrUpdateSelectedAttack(
                    SharedState.CombatHUD.SelectionHandler.ActiveState.SelectedActor,
                    meleeState.PhysicalWeapon
                    );
                Mod.UILog.Info?.Write("User selected PhysWeap button");
                shouldReturn = false;
            }
            else if (__instance.gameObject.name == ModConsts.PunchFB_GO_ID)
            {
                MeleeState meleeState = ModState.GetMeleeState(
                    SharedState.CombatHUD.SelectionHandler.ActiveState.SelectedActor,
                    SharedState.CombatHUD.SelectionHandler.ActiveState.PreviewPos);
                ModState.AddOrUpdateSelectedAttack(
                    SharedState.CombatHUD.SelectionHandler.ActiveState.SelectedActor,
                    meleeState.Punch
                    );
                Mod.UILog.Info?.Write("User selected Punch button");
                shouldReturn = false;
            }
            else
            {
                MeleeAttack selectedAttack2 = ModState.GetSelectedAttack(SharedState.CombatHUD?.SelectionHandler?.ActiveState?.SelectedActor);
                if (selectedAttack2 != null)
                {
                    Mod.UILog.Info?.Write("OnClick from generic CHUDFB with selected type, short-cutting to action.");

                    // Disable the buttons to prevent accidental clicks?
                    if (selectedAttack2 is ChargeAttack)
                    {
                        ModState.ChargeFB.CurrentFireMode = CombatHUDFireButton.FireMode.None;
                    }
                    if (selectedAttack2 is KickAttack)
                    {
                        ModState.KickFB.CurrentFireMode = CombatHUDFireButton.FireMode.None;
                    }
                    if (selectedAttack2 is WeaponAttack)
                    {
                        ModState.PhysicalWeaponFB.CurrentFireMode = CombatHUDFireButton.FireMode.None;
                    }
                    if (selectedAttack2 is PunchAttack)
                    {
                        ModState.PunchFB.CurrentFireMode = CombatHUDFireButton.FireMode.None;
                    }

                    return(true);
                }
            }

            MeleeAttack selectedAttack = ModState.GetSelectedAttack(SharedState.CombatHUD?.SelectionHandler?.ActiveState?.SelectedActor);

            if (selectedAttack != null)
            {
                Mod.UILog.Debug?.Write("Enabling description container for melee attack");
                selector.DescriptionContainer.SetActive(true);
                selector.DescriptionContainer.gameObject.SetActive(true);

                HashSet <string> descriptonNotes = selectedAttack.DescriptionNotes;
                string           description     = String.Join(", ", descriptonNotes);
                Mod.UILog.Debug?.Write($"Aggregate description is: {description}");

                selector.DescriptionText.SetText(description);
                selector.DescriptionText.ForceMeshUpdate(true);

                // TODO: Update weapon damage instead?

                // Update the weapon strings
                SharedState.CombatHUD.WeaponPanel.RefreshDisplayedWeapons();
            }

            return(shouldReturn);
        }