public static void Prefix(ref PurchaseUI.Purchasable[] purchasables, PurchaseUI.OnClose onClose) { StackTrace trace = new StackTrace(1); Type type = null; foreach (var v in trace.GetFrames()) { var candidateType = v.GetMethod().DeclaringType; if (typeof(BaseUI).IsAssignableFrom(candidateType)) { type = candidateType; break; } } if (type == null) { return; } BaseUI ui = onClose.Target as BaseUI; purchasables = PurchasableUIRegistry.customPurchasables.Where(x => x.Key(type, ui)).Select(x => x.Value(ui)).ToArray().AddRangeToArray(purchasables); foreach (var v in PurchasableUIRegistry.customManipulators.Where(x => x.Key(type, ui))) { v.Value(ui, ref purchasables); } }
// TODO: Remove this, fix UITemplatesPatch private static GameObject CreatePurchaseUI(Sprite titleIcon, string titleKey, PurchaseUI.Purchasable[] purchasables, bool hideNubuckCost, PurchaseUI.OnClose onClose, bool unavailInMainList = false) { GameObject gameObject = Instantiate(GameContext.Instance.UITemplates.purchaseUIPrefab); PurchaseUI component = gameObject.GetComponent <PurchaseUI>(); component.Init(titleIcon, titleKey, onClose); foreach (PurchaseUI.Purchasable purchasable in purchasables) { component.AddButton(purchasable, unavailInMainList); } if (hideNubuckCost) { component.HideNubuckCost(); } component.SelectFirst(); return(gameObject); }
public static void Prefix(UITemplates __instance, ref PurchaseUI.Purchasable[] purchasables, PurchaseUI.OnClose onClose) { if (purchaseUIs.ContainsKey(onClose.Target.GetType())) { purchasables = purchaseUIs[onClose.Method.ReflectedType].Invoke(purchasables); } }