private static void ProcessBuy(InventoryDataObject_SHOP selected) { var item_type = selected.GetItemType(); if (Control.State.Sim.InMechLabStore() && ( item_type == MechLabDraggableItemType.StorePart || item_type == MechLabDraggableItemType.SalvagePart )) { Control.LogDebug(DInfo.ShopActions, "- cannot buy mech and parts in mechlab, return"); return; } //if (ActiveShop is IDefaultShop def_shop) ////{ // Control.LogDebug(DInfo.ShopActions, "- IDefaultShop"); // var shop = def_shop.ShopToUse; // if (shop == null) // { // Control.LogDebug(DInfo.ShopActions, "-- no shop, return"); // return; // } int price = GetPrice_Transpliters.GetPrice(null, selected.shopDefItem, Shop.PurchaseType.Normal, Shop.ShopType.System); var money = Control.State.Sim.Funds; var max_to_buy = money / price; if (!selected.shopDefItem.IsInfinite && max_to_buy > selected.quantity) { max_to_buy = selected.quantity; } Control.LogDebug(DInfo.ShopActions, $"-- money:{money} price:{price} num:{selected.quantity} max:{max_to_buy}"); if (max_to_buy == 1 || !Control.Settings.AllowMultiBuy) { if (Control.Settings.ShowConfirm && price >= Control.Settings.ConfirmLowLimit) { GenericPopupBuilder.Create("Confirm?", $"Purchase {selected.GetName()} for {price}?") .AddButton("Cancel", null, true, null) .AddButton("Accept", () => OnBuyItem(1), true, null) .CancelOnEscape() .AddFader(new UIColorRef?(LazySingletonBehavior <UIManager> .Instance.UILookAndColorConstants.PopupBackfill), 0f, true) .Render(); } else { OnBuyItem(1); } } else { SG_Stores_MultiPurchasePopup_Handler.StartDialog("Buy", selected.shopDefItem, selected.GetName(), max_to_buy, price, OnBuyItem, null); } //} //else if (ActiveShop is IListShop shop) //{ //} //else //{ // Control.LogError("- unknown type of shop, return"); //} }
public static IEnumerable <CodeInstruction> RepalceGetPrice(IEnumerable <CodeInstruction> instructions) { return(GetPrice_Transpliters.RepalceGetPrice(instructions)); }