Esempio n. 1
0
        public static bool Prefix(SimGameState __instance, string id)
        {
            __instance.AddItemStat(id, "MECHPART", false);

            if (SimGameState_ResolveCompleteContract.IsResolving != null) // save added mechs for later completion
            {
                if (!SimGameState_ResolveCompleteContract.IsResolving.ContainsKey(id))
                {
                    SimGameState_ResolveCompleteContract.IsResolving.Add(id, 0);
                }
                SimGameState_ResolveCompleteContract.IsResolving[id]++;
            }
            else // no contract -> direct assembly
            {
                MechDef d = __instance.DataManager.MechDefs.Get(id);
                int     p = SimpleMechAssembly_Main.GetNumPartsForAssembly(__instance, d);
                if (p >= __instance.Constants.Story.DefaultMechPartMax)
                {
                    //SimpleMechAssembly_Main.QueryMechAssemblyPopup(__instance, d, null);
                    __instance.InterruptQueue.AddInterrupt(new SimpleMechAssembly_Main.SimpleMechAssembly_InterruptManager_AssembleMechEntry(__instance, d, null), true);
                }
            }

            return(false); // completely replace
        }
Esempio n. 2
0
        public static void Postfix(SimGameState __instance)
        {
            List <string> VariantsDone = new List <string>();

            foreach (KeyValuePair <string, int> kv in IsResolving)
            {
                MechDef d = __instance.DataManager.MechDefs.Get(kv.Key);
                if (VariantsDone.Contains(d.Description.Id))
                {
                    continue;
                }
                int p = SimpleMechAssembly_Main.GetNumPartsForAssembly(__instance, d);
                if (p >= __instance.Constants.Story.DefaultMechPartMax)
                {
                    //SimpleMechAssembly_Main.QueryMechAssemblyPopup(__instance, d, null);
                    __instance.InterruptQueue.AddInterrupt(new SimpleMechAssembly_Main.SimpleMechAssembly_InterruptManager_AssembleMechEntry(__instance, d, null), true);
                    foreach (MechDef m in SimpleMechAssembly_Main.GetAllAssemblyVariants(__instance, d))
                    {
                        if (!VariantsDone.Contains(m.Description.Id))
                        {
                            VariantsDone.Add(m.Description.Id);
                        }
                    }
                }
            }
            IsResolving = null;
        }
 public static void Postfix(SG_Shop_ItemSelectedPanel __instance, InventoryDataObject_BASE theController, SimGameState ___simState, LocalizableText ___MechPartCountText)
 {
     if (theController.mechDef == null)
     {
         return;
     }
     ___MechPartCountText.SetText(SimpleMechAssembly_Main.GetMechCountDescrString(___simState, theController.mechDef));
 }
Esempio n. 4
0
        public static void Postfix(ListElementController_SalvageMechPart_NotListView __instance, InventoryItemElement_NotListView theWidget, SimGameState ___simState)
        {
            int pieces    = ___simState.GetItemCount(__instance.mechDef.Description.Id, "MECHPART", SimGameState.ItemCountType.UNDAMAGED_ONLY);
            int needed    = ___simState.Constants.Story.DefaultMechPartMax;
            int varpieces = SimpleMechAssembly_Main.GetNumPartsForAssembly(___simState, __instance.mechDef);
            int owned     = SimpleMechAssembly_Main.GetNumberOfMechsOwnedOfType(___simState, __instance.mechDef);

            theWidget.mechPartsNumbersText.SetText(string.Format("{0}({1})/{3}({2})", pieces, varpieces, owned, needed));
        }
Esempio n. 5
0
        public static void Postfix(SG_Shop_ItemSelectedPanel __instance, InventoryDataObject_BASE theController, SimGameState ___simState, LocalizableText ___MechPartCountText)
        {
            if (theController.mechDef == null)
            {
                return;
            }
            int pieces    = ___simState.GetItemCount(theController.mechDef.Description.Id, "MECHPART", SimGameState.ItemCountType.UNDAMAGED_ONLY);
            int needed    = ___simState.Constants.Story.DefaultMechPartMax;
            int varpieces = SimpleMechAssembly_Main.GetNumPartsForAssembly(___simState, theController.mechDef);
            int owned     = SimpleMechAssembly_Main.GetNumberOfMechsOwnedOfType(___simState, theController.mechDef);

            ___MechPartCountText.SetText(string.Format("{0}({1})/{3}({2})", pieces, varpieces, owned, needed));
        }
Esempio n. 6
0
        public static bool Prefix(MechBayChassisInfoWidget __instance, ChassisDef ___selectedChassis, MechBayPanel ___mechBay)
        {
            if (___selectedChassis == null)
            {
                return(true);
            }
            int     bay = ___mechBay.Sim.GetFirstFreeMechBay();
            string  id  = ___selectedChassis.Description.Id.Replace("chassisdef", "mechdef");
            MechDef d   = ___mechBay.Sim.DataManager.MechDefs.Get(id);

            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("Mech Assembly", "Yang: I do not have enough parts to assemble a mech out of it.").AddButton("Cancel", null, true, null)
                    .AddFader(new UIColorRef?(LazySingletonBehavior <UIManager> .Instance.UILookAndColorConstants.PopupBackfill), 0f, true).Render();
                    return(false);
                }
                //SimpleMechAssembly_Main.QueryMechAssemblyPopup(___mechBay.Sim, d, ___mechBay);
                ___mechBay.Sim.InterruptQueue.AddInterrupt(new SimpleMechAssembly_Main.SimpleMechAssembly_InterruptManager_AssembleMechEntry(___mechBay.Sim, d, ___mechBay), true);
                return(false);
            }
            if (___selectedChassis.MechPartCount < ___selectedChassis.MechPartMax)
            {
                return(true);
            }
            if (SimpleMechAssembly_Main.Settings.OmniMechTag == null || !___selectedChassis.ChassisTags.Contains(SimpleMechAssembly_Main.Settings.OmniMechTag))
            {
                return(true);
            }
            if (bay < 0)
            {
                return(true);
            }
            SimpleMechAssembly_Main.UnStorageOmniMechPopup(___mechBay.Sim, d, ___mechBay);
            return(false);
        }
 public static void Postfix(ListElementController_SalvageMechPart_NotListView __instance, InventoryItemElement_NotListView theWidget, SimGameState ___simState)
 {
     theWidget.mechPartsNumbersText.SetText(SimpleMechAssembly_Main.GetMechCountDescrString(___simState, __instance.mechDef));
 }
        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);
        }