public static void PerformMechAssemblyStorePopup(SimGameState s, MechDef d, Action onClose) { WwiseManager.PostEvent(AudioEventList_ui.ui_sim_popup_newChassis, WwiseManager.GlobalAudioObject, null, null); MechDef toAdd = PerformMechAssembly(s, d); int mechbay; if (toAdd.IsVehicle()) { mechbay = CUIntegration.GetFirstFreeMechBay(s, d); // vehicle bay, +100 or something similar } else { mechbay = s.GetFirstFreeMechBay(); } GenericPopupBuilder pop = GenericPopupBuilder.Create($"{d.GetMechOmniVehicle()} Assembled", $"Yang: [[DM.MechDefs[{d.Description.Id}],{d.Chassis.Description.UIName} {d.Chassis.VariantName}]] finished!\n{d.Chassis.YangsThoughts}\n\n"); pop.AddButton("storage", delegate { StoreMech(s, toAdd); CallMessages(s, toAdd); Log.Log("direct storage"); onClose?.Invoke(); }, true, null); if (mechbay < 0) // no space - direct storage { pop.Body += $"We have no space for a new {d.GetMechOmniVehicle()}, so it goes into storage."; } else { pop.Body += "Should I put it into storage or ready it for combat?"; pop.AddButton("ready it", delegate { if (Settings.AssembledMechsNeedReadying) { ReadyMech(s, toAdd, mechbay); CallMessages(s, toAdd); } else { s.AddMech(mechbay, toAdd, true, false, false); CallMessages(s, toAdd); } Log.Log("added to bay " + mechbay); onClose?.Invoke(); }, true, null); } if (s.IsSellingAllowed()) { int cost = toAdd.GetMechSellCost(s); pop.Body += $"\n\nDarius: We could also sell it for {SimGameState.GetCBillString(cost)}, although Yang would certanly not like it."; pop.AddButton("sell it", delegate { s.AddFunds(cost, "Store", true, true); Log.Log("sold for " + cost); s.CompanyStats.ModifyStat("Mission", 0, "COMPANY_MechsAdded", StatCollection.StatOperation.Int_Add, 1, -1, true); CallMessages(s, toAdd); onClose?.Invoke(); }, true, null); } pop.AddFader(new UIColorRef?(LazySingletonBehavior <UIManager> .Instance.UILookAndColorConstants.PopupBackfill), 0f, true); pop.Render(); }
public static void FinishedLoading() { CCIntegration.LoadDelegates(); CUIntegration.LoadDelegates(); }
public static bool Prefix(MechBayChassisInfoWidget __instance, ChassisDef ___selectedChassis, MechBayPanel ___mechBay) { if (___selectedChassis == null) { return(true); } int bay = ___mechBay.Sim.GetFirstFreeMechBay(); MechDef d = ___selectedChassis.GetMainMechDef(___mechBay.Sim.DataManager); if (___selectedChassis.MechPartCount > 0) // this is actually a part that gets assembled { int p = SimpleMechAssembly_Main.GetNumPartsForAssembly(___mechBay.Sim, d); if (p < ___mechBay.Sim.Constants.Story.DefaultMechPartMax) { GenericPopupBuilder.Create($"{d.GetMechOmniVehicle()} Assembly", SimpleMechAssembly_Main.GetAssembleNotEnoughPartsText(___mechBay.Sim, d)).AddButton("Cancel", null, true, null) .AddFader(new UIColorRef?(LazySingletonBehavior <UIManager> .Instance.UILookAndColorConstants.PopupBackfill), 0f, true).Render(); return(false); } ___mechBay.Sim.InterruptQueue.AddInterrupt(new SimpleMechAssembly_Main.SimpleMechAssembly_InterruptManager_AssembleMechEntry(___mechBay.Sim, d, delegate { ___mechBay.RefreshData(false); }), true); return(false); } if (___selectedChassis.MechPartCount < ___selectedChassis.MechPartMax) { return(true); } if (___selectedChassis.IsVehicle()) { bay = CUIntegration.GetFirstFreeMechBay(___mechBay.Sim, d); if (bay < 0) { GenericPopupBuilder.Create("Cannot Ready Vehicle", "There are no available slots in the Vehicle Bay. You must move an active Vehicle into storage before readying this chassis.") .AddFader(new UIColorRef?(LazySingletonBehavior <UIManager> .Instance.UILookAndColorConstants.PopupBackfill), 0f, true).Render(); } else { GenericPopupBuilder.Create("Ready Vehicle?", $"It will take {Mathf.CeilToInt(___mechBay.Sim.Constants.Story.MechReadyTime / (float)___mechBay.Sim.MechTechSkill)} day(s) to ready this Vehicle for combat.") .AddButton("Cancel", null, true, null).AddButton("Ready", delegate { if (___mechBay.Sim.ScrapInactiveMech(___selectedChassis.Description.Id, false)) { SimpleMechAssembly_Main.ReadyMech(___mechBay.Sim, new MechDef(d, ___mechBay.Sim.GenerateSimGameUID(), true), bay, true); ___mechBay.RefreshData(false); ___mechBay.ViewBays(); } }).AddFader(new UIColorRef?(LazySingletonBehavior <UIManager> .Instance.UILookAndColorConstants.PopupBackfill), 0f, true).CancelOnEscape().Render(); } return(false); } if (!___selectedChassis.IsOmni()) { return(true); } if (bay < 0) { return(true); } ___mechBay.Sim.InterruptQueue.AddInterrupt(new SimpleMechAssembly_Main.SimpleMechAssembly_InterruptManager_UnStorageOmniEntry(___mechBay.Sim, d, delegate { ___mechBay.RefreshData(false); })); return(false); }