static bool Prefix(CareerManagerLicensesScreen __instance, ref int __result) { int nSlots = (int)CM_Constants.nSlotsField.GetValue(__instance); __result = Mathf.Max(CM_Constants.N_BUILTIN_LICENSES + CM_Constants.N_PASS_LICENSES - nSlots, 0); return(false); }
// oh god why static void Postfix(int startingIndex, CareerManagerLicensesScreen __instance) { int nSlots = (int)CM_Constants.nSlotsField.GetValue(__instance); // offset from first slot in screen int passLicenseSlot = CM_Constants.N_BUILTIN_LICENSES - startingIndex; if (passLicenseSlot < nSlots) { Type entryListType = typeof(List <>).MakeGenericType(CM_Constants.licenseEntryType); PropertyInfo indexProp = entryListType.GetProperty("Item", BindingFlags.Public | BindingFlags.Instance); object licenseEntryList = CM_Constants.licenseEntryField.GetValue(__instance); object licenseEntry = indexProp.GetValue(licenseEntryList, new object[] { passLicenseSlot }); CM_Constants.updateLicenseMethod.Invoke(licenseEntry, new object[] { PassLicenses.Passengers1 }); } }