Ejemplo n.º 1
0
        static bool Prefix(MechLabPanel __instance, bool ___batchActionInProgress, MechLabItemSlotElement ___dragItem)
        {
            var hk = Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl);

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

            if (!__instance.Initialized)
            {
                return(false);
            }
            if (___dragItem != null)
            {
                return(false);
            }
            ___batchActionInProgress = true;
            __instance.headWidget.AdvancedStripping(__instance);
            __instance.centerTorsoWidget.AdvancedStripping(__instance);
            __instance.leftTorsoWidget.AdvancedStripping(__instance);
            __instance.rightTorsoWidget.AdvancedStripping(__instance);
            __instance.leftArmWidget.AdvancedStripping(__instance);
            __instance.rightArmWidget.AdvancedStripping(__instance);
            __instance.leftLegWidget.AdvancedStripping(__instance);
            __instance.rightLegWidget.AdvancedStripping(__instance);
            __instance.FlagAsModified();
            __instance.ValidateLoadout(false);
            ___batchActionInProgress = false;
            return(false);
        }
Ejemplo n.º 2
0
    internal static void OnStripArmor(MechLabPanel mechLabPanel)
    {
        if (!MechArmorState.Strip(mechLabPanel.activeMechDef, InputUtils.ControlModifierPressed, out var updates))
        {
            return;
        }

        foreach (var update in updates)
        {
            var widget = mechLabPanel.GetLocationWidget(update.Location);
            widget.SetArmor(update.Location.IsRear(), update.Assigned);
            Control.Logger.Trace?.Log($"OnStripArmor.SetArmor update={update}");
        }

        mechLabPanel.FlagAsModified();
        mechLabPanel.ValidateLoadout(false);
    }
Ejemplo n.º 3
0
    internal static void OnMaxArmor(MechLabPanel mechLabPanel, MechLabMechInfoWidget infoWidget)
    {
        if (!MechArmorState.Maximize(mechLabPanel.activeMechDef, InputUtils.ControlModifierPressed, ArmorStructureRatioFeature.ArmorPerStep, out var updates))
        {
            return;
        }

        foreach (var update in updates)
        {
            var widget = mechLabPanel.GetLocationWidget(update.Location);
            widget.SetArmor(update.Location.IsRear(), update.Assigned);
            Control.Logger.Trace?.Log($"OnMaxArmor.SetArmor update={update}");
        }

        infoWidget.RefreshInfo();
        mechLabPanel.FlagAsModified();
        mechLabPanel.ValidateLoadout(false);
    }
Ejemplo n.º 4
0
        static bool Prefix(MechLabPanel __instance, MechLabMechInfoWidget ___mechInfoWidget, MechLabItemSlotElement ___dragItem)
        {
            var hk = Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl);

            if (hk)
            {
                return(true);
            }

            if (!__instance.Initialized)
            {
                return(false);
            }
            if (___dragItem != null)
            {
                return(false);
            }
            if (__instance.headWidget.IsDestroyed || __instance.centerTorsoWidget.IsDestroyed || __instance.leftTorsoWidget.IsDestroyed || __instance.rightTorsoWidget.IsDestroyed || __instance.leftArmWidget.IsDestroyed || __instance.rightArmWidget.IsDestroyed || __instance.leftLegWidget.IsDestroyed || __instance.rightLegWidget.IsDestroyed)
            {
                __instance.modifiedDialogShowing = true;
                GenericPopupBuilder.Create("'Mech Location Destroyed", "You cannot auto-assign armor while a 'Mech location is Destroyed.").AddButton("Okay", null, true, null).CancelOnEscape().AddFader(new UIColorRef?(LazySingletonBehavior <UIManager> .Instance.UILookAndColorConstants.PopupBackfill), 0f, true).SetAlwaysOnTop().SetOnClose(delegate
                {
                    __instance.modifiedDialogShowing = false;
                }).Render();
                return(false);
            }

            __instance.headWidget.ModifyArmor(false, __instance.headWidget.maxArmor, true);
            __instance.centerTorsoWidget.ModifyArmor(false, __instance.centerTorsoWidget.maxArmor, true);
            __instance.centerTorsoWidget.ModifyArmor(true, __instance.centerTorsoWidget.maxRearArmor, true);
            __instance.leftTorsoWidget.ModifyArmor(false, __instance.leftTorsoWidget.maxArmor, true);
            __instance.leftTorsoWidget.ModifyArmor(true, __instance.leftTorsoWidget.maxRearArmor, true);
            __instance.rightTorsoWidget.ModifyArmor(false, __instance.rightTorsoWidget.maxArmor, true);
            __instance.rightTorsoWidget.ModifyArmor(true, __instance.rightTorsoWidget.maxRearArmor, true);
            __instance.leftArmWidget.ModifyArmor(false, __instance.leftArmWidget.maxArmor, true);
            __instance.rightArmWidget.ModifyArmor(false, __instance.rightArmWidget.maxArmor, true);
            __instance.leftLegWidget.ModifyArmor(false, __instance.leftLegWidget.maxArmor, true);
            __instance.rightLegWidget.ModifyArmor(false, __instance.rightLegWidget.maxArmor, true);
            ___mechInfoWidget.RefreshInfo(false);

            __instance.FlagAsModified();
            __instance.ValidateLoadout(false);
            return(false);
        }