public static void GetPregnancyForHero(Hero father, Hero mother) { MakePregnantAction.Apply(mother); PregnancyCampaignBehavior pregnancyCampaignBehavior = Campaign.Current.GetCampaignBehavior <PregnancyCampaignBehavior>(); CampaignTime campaignTime = CampaignTime.DaysFromNow(Campaign.Current.Models.PregnancyModel.PregnancyDurationInDays); if (MoreSpouseSetting.Instance.SettingData.ExspouseGetPregnancyEnable) { campaignTime = CampaignTime.DaysFromNow(MoreSpouseSetting.Instance.SettingData.ExspouseGetPregnancyDurationInDays); } Type type = pregnancyCampaignBehavior.GetType(); FieldInfo _heroPregnancies = type.GetField("_heroPregnancies", BindingFlags.NonPublic | BindingFlags.Instance); IList list = (IList)_heroPregnancies.GetValue(pregnancyCampaignBehavior); object[] parameters = new object[3] { mother, father, campaignTime }; try { Type innerType = type.GetNestedType("Pregnancy", BindingFlags.NonPublic | BindingFlags.Instance); object obj = Activator.CreateInstance(innerType, BindingFlags.Public | BindingFlags.Instance, null, parameters, null); list.Add(obj); } catch (IOException e) { InformationManager.DisplayMessage(new InformationMessage("MoreSpouses.ChildConceived error:" + e.Message)); } }
static bool Prefix(PregnancyCampaignBehavior __instance, Hero mother) { if (mother.IsFemale && mother.Age > 18 && (Hero.MainHero.ExSpouses.Contains(mother) || mother == Hero.MainHero.Spouse)) { CampaignTime campaignTime = CampaignTime.DaysFromNow(Campaign.Current.Models.PregnancyModel.PregnancyDurationInDays); if (MoreSpouseSetting.Instance.SettingData.ExspouseGetPregnancyEnable) { campaignTime = CampaignTime.DaysFromNow(MoreSpouseSetting.Instance.SettingData.ExspouseGetPregnancyDurationInDays); } Type type = __instance.GetType(); FieldInfo _heroPregnancies = type.GetField("_heroPregnancies", BindingFlags.NonPublic | BindingFlags.Instance); IList list = (IList)_heroPregnancies.GetValue(__instance); object[] parameters = new object[3] { mother, Hero.MainHero, campaignTime }; try { Type innerType = type.GetNestedType("Pregnancy", BindingFlags.NonPublic | BindingFlags.Instance); object obj = Activator.CreateInstance(innerType, BindingFlags.Public | BindingFlags.Instance, null, parameters, null); list.Add(obj); } catch (IOException e) { InformationManager.DisplayMessage(new InformationMessage("MoreSpouses.ChildConceived error:" + e.Message)); } return(false); } return(true); }
static void Postfix(PregnancyCampaignBehavior __instance, Hero hero) { Type type = __instance.GetType(); BindingFlags flags = BindingFlags.NonPublic | BindingFlags.Instance; if (null == type) { return; } if (hero.IsFemale && hero.Age > 18 && Hero.MainHero.ExSpouses.Contains(hero) && !hero.IsPregnant && hero != Hero.MainHero.Spouse) { try { MethodInfo methodinfo = type.GetMethod("RefreshSpouseVisit", flags); object[] parameters = new object[1] { hero }; if (null != methodinfo) { object i = methodinfo.Invoke(__instance, parameters); } } catch (TargetInvocationException e) { InformationManager.DisplayMessage(new InformationMessage($"MoreSpouses.DailyTickHero error:" + e.Message)); } } else if (!hero.IsFemale && hero.IsPregnant && Hero.MainHero.ExSpouses.Contains(hero)) //男性怀孕逻辑处理 { try { MethodInfo[] info = type.GetMethods(flags); object[] parameters = new object[1] { hero }; foreach (MethodInfo func in info) { if (func.Name.Equals("CheckOffspringsToDeliver", StringComparison.Ordinal)) { ParameterInfo[] parmInfo = func.GetParameters(); if (parmInfo.Length == 1) { Type type1 = parmInfo[0].ParameterType; Type type2 = hero.GetType(); if (type1.Equals(type2)) { func.Invoke(__instance, parameters); } } } } } catch (TargetInvocationException e) { InformationManager.DisplayMessage(new InformationMessage($"MoreSpouses.DailyTickHero error:" + e.Message)); } } }
public static object GetHeroPregnanciesObject() { if (PregCampHelper.m_heroPregnanciesField == (FieldInfo)null) { return((object)null); } PregnancyCampaignBehavior behaviorInstance = Utillty.GetPregnancyCampaignBehaviorInstance(); return(behaviorInstance == null ? (object)null : PregCampHelper.m_heroPregnanciesField.GetValue((object)behaviorInstance)); }
private static void Postfix(PregnancyCampaignBehavior __instance) { CampaignEvents.DailyTickEvent.AddNonSerializedListener(__instance, () => { var pregnancies = AccessTools.Field(typeof(PregnancyCampaignBehavior), "_heroPregnancies") .GetValue(__instance) as IReadOnlyList <object>; float timeShiftDays = 1 * LifeIsShortConfig.Instance.AgeMultiplier - 1; if (timeShiftDays > 0) { foreach (var pregnancy in pregnancies) { var dateField = pregnancy.GetType().GetField("DueDate"); var date = (CampaignTime)dateField.GetValue(pregnancy); var newDate = CampaignTime.Days((float)date.ToDays - timeShiftDays); dateField.SetValue(pregnancy, newDate); } } }); }
public static void DoChildConceivedMethod(Hero hero) { if (hero == null) { return; } PregnancyCampaignBehavior behaviorInstance = Utillty.GetPregnancyCampaignBehaviorInstance(); if (behaviorInstance == null) { return; } MethodInfo method = typeof(PregnancyCampaignBehavior).GetMethod("ChildConceived", BindingFlags.Instance | BindingFlags.NonPublic); if (method == (MethodInfo)null) { return; } method.Invoke((object)behaviorInstance, new object[1] { (object)hero }); }
public static bool Prefix(PregnancyCampaignBehavior __instance, ref Hero hero) { return(hero != Hero.MainHero && hero != Hero.MainHero.Spouse || !Config.Instance.DisablePlayerUncontrollablePregnancy); }
public static bool Prefix(PregnancyCampaignBehavior __instance, ref Hero hero) { PregnancyCheckOffspringsToDeliverPatch._removeAbortionMotherInHeroPregnancies(hero); return(true); }
public static bool Prefix(PregnancyCampaignBehavior __instance, ref Hero mother) { PregnancyChildConceivedPatch._getRealParentsInCurPregnancy(mother); return(true); }