示例#1
0
        static void Postfix(MechBayMechStorageWidget __instance, List <IMechLabDraggableItem> ___inventory, IMechLabDropTarget ___parentDropTarget)
        {
            // Not MechBay, skip
            if (___parentDropTarget == null || !(___parentDropTarget is MechBayPanel mechBayPanel))
            {
                return;
            }

            // Components tab isn't selected, skip
            if (!__instance.gameObject.activeInHierarchy)
            {
                return;
            }


            if (___inventory != null && ___inventory.Count > 0 &&
                Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt))
            {
                string titleLT = new Text(Mod.LocalizedText.Dialog[ModText.DT_Title_ScrapMediums]).ToString();

                List <ChassisCount> chassisCounts = ___inventory
                                                    .OfType <MechBayChassisUnitElement>()
                                                    .Where(x => x.ChassisDef.weightClass == WeightClass.MEDIUM)
                                                    .Select(x => ScrapHelper.MapChassisUnitElement(x, __instance.Sim))
                                                    .ToList();

                ScrapHelper.BuildScrapAllDialog(chassisCounts, __instance.Sim.Constants.Finances.MechScrapModifier, titleLT,
                                                delegate { ScrapHelper.ScrapChassis(chassisCounts); });
            }
        }
示例#2
0
        public static void BuildScrapAllDialog(List <ChassisCount> filteredChassis,
                                               float scrapPartModifier, string title, Action confirmAction)
        {
            int    cbills   = ScrapHelper.CalculateTotalScrap(filteredChassis, scrapPartModifier);
            string cbillStr = SimGameState.GetCBillString(cbills);

            string descLT   = new Text(Mod.LocalizedText.Dialog[ModText.DT_Desc_ScrapAll], new object[] { cbillStr }).ToString();
            string cancelLT = new Text(Mod.LocalizedText.Dialog[ModText.DT_Button_Cancel]).ToString();
            string scrapLT  = new Text(Mod.LocalizedText.Dialog[ModText.DT_Button_Scrap]).ToString();

            GenericPopupBuilder.Create(title, descLT)
            .AddButton(cancelLT)
            .AddButton(scrapLT, confirmAction)
            .CancelOnEscape()
            .AddFader(LazySingletonBehavior <UIManager> .Instance.UILookAndColorConstants.PopupBackfill)
            .Render();
        }