コード例 #1
0
        public static void QueryMechAssemblyPopup(SimGameState s, MechDef d, MechBayPanel refresh = null, SimpleMechAssembly_InterruptManager_AssembleMechEntry close = null)
        {
            if (GetNumPartsForAssembly(s, d) < s.Constants.Story.DefaultMechPartMax)
            {
                if (close != null)
                {
                    close.NewClose();
                }
                return;
            }
            IEnumerable <MechDef> ownedMechVariantParts = GetAllAssemblyVariants(s, d)
                                                          .Where(m => s.GetItemCount(
                                                                     m.Description.Id, "MECHPART", SimGameState.ItemCountType.UNDAMAGED_ONLY) > 0 || CheckOmniKnown(s, d, m));

            int    selectedMechParts    = s.GetItemCount(d.Description.Id, "MECHPART", SimGameState.ItemCountType.UNDAMAGED_ONLY);
            int    numberOfChassisOwned = GetNumberOfMechsOwnedOfType(s, d);
            string desc = $"Yang: {d.Chassis.YangsThoughts}\n\n";

            IEnumerable <string> additionalVariants = ownedMechVariantParts
                                                      .Where(m => m.Description.Id != d.Description.Id)
                                                      .Select(m =>
            {
                int count = s.GetItemCount(m.Description.Id, "MECHPART", SimGameState.ItemCountType.UNDAMAGED_ONLY);
                int com   = GetNumberOfMechsOwnedOfType(s, m);
                return($"[[DM.MechDefs[{m.Description.Id}], {m.Chassis.VariantName}]] ({count} Parts/{com} Complete)");
            });

            string selectedMechDisplayTitle = $"[[DM.MechDefs[{d.Description.Id}],{d.Chassis.VariantName}]] ({selectedMechParts} Parts/{numberOfChassisOwned} Complete)";

            if (additionalVariants.Count() > 1)
            {
                desc += $"We can build the {selectedMechDisplayTitle}, " +
                        $"or one of these other variants of the {d.Chassis.Description.UIName}:\n\n";
                desc += string.Join("\n", additionalVariants);
                VariantPopup(desc, s, ownedMechVariantParts, refresh, close);
            }
            else if (additionalVariants.Count() == 1)
            {
                desc += $"We can build the {selectedMechDisplayTitle}, or the\n" +
                        $"{string.Join("", additionalVariants)} variant of the {d.Chassis.Description.UIName}.";
                VariantPopup(desc, s, ownedMechVariantParts, refresh, close);
            }
            else
            {
                desc += $"Should I build the {selectedMechDisplayTitle}?";
                VariantPopup(desc, s, new[] { d }, refresh, close);
            }
        }
コード例 #2
0
        public static void PerformMechAssemblyStorePopup(SimGameState s, MechDef d, MechBayPanel refresh, SimpleMechAssembly_InterruptManager_AssembleMechEntry close)
        {
            MechDef toAdd   = PerformMechAssembly(s, d);
            int     mechbay = s.GetFirstFreeMechBay();

            if (mechbay < 0) // no space - direct storage
            {
                StoreMech(s, toAdd);
                Log.Log("no space, direct storage");
                if (refresh != null)
                {
                    refresh.RefreshData(false);
                }
                GenericPopupBuilder pop = GenericPopupBuilder.Create("Mech Assembled",
                                                                     string.Format("Yang: [[DM.MechDefs[{3}],{1} {2}]] finished!\n{0}\n\nWe have no space for a new mech, so it goes into storage.",
                                                                                   d.Chassis.YangsThoughts, d.Chassis.Description.UIName, d.Chassis.VariantName, d.Description.Id));
                pop.AddButton("ok", delegate
                {
                    if (close != null)
                    {
                        close.NewClose();
                    }
                }, true, null);
                pop.AddFader(new UIColorRef?(LazySingletonBehavior <UIManager> .Instance.UILookAndColorConstants.PopupBackfill), 0f, true);
                pop.Render();
            }
            else
            {
                GenericPopupBuilder pop = GenericPopupBuilder.Create("Mech Assembled",
                                                                     string.Format("Yang: [[DM.MechDefs[{3}],{1} {2}]] finished!\n{0}\n\nShould I put it into storage, or ready it for combat?",
                                                                                   d.Chassis.YangsThoughts, d.Chassis.Description.UIName, d.Chassis.VariantName, d.Description.Id));
                pop.AddButton("storage", delegate
                {
                    StoreMech(s, toAdd);
                    Log.Log("direct storage");
                    if (refresh != null)
                    {
                        refresh.RefreshData(false);
                    }
                    if (close != null)
                    {
                        close.NewClose();
                    }
                }, true, null);
                pop.AddButton("ready it", delegate
                {
                    if (Settings.AssembledMechsNeedReadying)
                    {
                        ReadyMech(s, toAdd, mechbay);
                    }
                    else
                    {
                        s.AddMech(mechbay, toAdd, true, false, false);
                    }
                    Log.Log("added to bay " + mechbay);
                    if (refresh != null)
                    {
                        refresh.RefreshData(false);
                    }
                    if (close != null)
                    {
                        close.NewClose();
                    }
                }, true, null);
                pop.AddFader(new UIColorRef?(LazySingletonBehavior <UIManager> .Instance.UILookAndColorConstants.PopupBackfill), 0f, true);
                pop.Render();
            }
        }
コード例 #3
0
        public static void VariantPopup(string desc, SimGameState s, IEnumerable <MechDef> variantsToList, MechBayPanel refresh = null, SimpleMechAssembly_InterruptManager_AssembleMechEntry close = null)
        {
            GenericPopupBuilder pop    = GenericPopupBuilder.Create("Assemble Mech?", desc);
            bool   hasMultipleVariants = variantsToList.Count() > 1;
            string closeButtonText     = hasMultipleVariants ? "-" : "Not now";

            pop.AddButton(closeButtonText, delegate
            {
                if (close != null)
                {
                    close.NewClose();
                }
            }, true, null);


            foreach (MechDef m in variantsToList)
            {
                string buttonText = hasMultipleVariants ? string.Format("{0}", m.Chassis.VariantName) : "Yes";
                pop.AddButton(buttonText, delegate
                {
                    PerformMechAssemblyStorePopup(s, m, refresh, close);
                }, true, null);
            }

            pop.CancelOnEscape();
            pop.AddFader(new UIColorRef?(LazySingletonBehavior <UIManager> .Instance.UILookAndColorConstants.PopupBackfill), 0f, true);
            pop.Render();
        }