patched relation utility

This commit is contained in:
Jaaldabaoth 2024-05-26 10:11:24 +02:00
parent e372c8fe71
commit 246f227792
4 changed files with 130 additions and 46 deletions

Binary file not shown.

View file

@ -0,0 +1,129 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using HarmonyLib;
using RimWorld;
using Verse;
using rjw;
namespace RJW_BGS
{
[HarmonyPatch(typeof(ParentRelationUtility))]
public class patchGetParents
{
// Token: 0x0600000F RID: 15
[HarmonyPostfix]
[HarmonyPatch("GetFather")]
private static void FatherPostfix(ref Pawn __result, Pawn pawn)
{
if (__result == null && pawn.RaceProps.IsFlesh && pawn.relations != null)
{
List<DirectPawnRelation> directRelations = pawn.relations.DirectRelations;
bool flag = false;
for (int i = 0; i < directRelations.Count; i++)
{
DirectPawnRelation directPawnRelation = directRelations[i];
if (directPawnRelation.def == PawnRelationDefOf.Parent)
{
if (flag)
{
__result = directPawnRelation.otherPawn;
return;
}
flag = true;
}
}
}
}
// Token: 0x06000010 RID: 16
[HarmonyPostfix]
[HarmonyPatch("GetMother")]
private static void MotherPostfix(ref Pawn __result, Pawn pawn)
{
if (__result == null && pawn.RaceProps.IsFlesh && pawn.relations != null)
{
List<DirectPawnRelation> directRelations = pawn.relations.DirectRelations;
for (int i = 0; i < directRelations.Count; i++)
{
DirectPawnRelation directPawnRelation = directRelations[i];
if (directPawnRelation.def == PawnRelationDefOf.Parent)
{
__result = directPawnRelation.otherPawn;
return;
}
}
}
}
// Token: 0x0600001F RID: 31
[HarmonyPostfix]
[HarmonyPatch("HasSameFather")]
private static void HasSameFatherPostfix(ref bool __result, Pawn pawn, Pawn other)
{
if (!__result && pawn.RaceProps.IsFlesh && pawn.relations != null)
{
Pawn parent = pawn.GetFather();
Pawn parent2 = other.GetMother();
Pawn parent3 = other.GetFather();
Pawn parent4 = pawn.GetMother();
if (parent != null && parent2 != null && parent == parent2)
{
__result = true;
return;
}
if (parent3 != null && parent4 != null && parent3 == parent4)
{
__result = true;
return;
}
if (parent != null && parent3 != null && parent == parent3)
{
__result = true;
return;
}
if (parent2 != null && parent4 != null && parent2 == parent4)
{
__result = true;
return;
}
}
}
// Token: 0x06000020 RID: 32
[HarmonyPostfix]
[HarmonyPatch("HasSameMother")]
private static void HasSameMotherPostfix(ref bool __result, Pawn pawn, Pawn other)
{
if (!__result && pawn.RaceProps.IsFlesh && pawn.relations != null)
{
Pawn parent = pawn.GetFather();
Pawn parent2 = other.GetMother();
Pawn parent3 = other.GetFather();
Pawn parent4 = pawn.GetMother();
if (parent != null && parent2 != null && parent == parent2)
{
__result = true;
return;
}
if (parent3 != null && parent4 != null && parent3 == parent4)
{
__result = true;
return;
}
if (parent != null && parent3 != null && parent == parent3)
{
__result = true;
return;
}
if (parent2 != null && parent4 != null && parent2 == parent4)
{
__result = true;
return;
}
}
}
}
}

View file

@ -44,6 +44,7 @@
<Compile Include="Common\Either.cs" />
<Compile Include="Common\ModLog.cs" />
<Compile Include="Common\Defs\TickIntervalExtension.cs" />
<Compile Include="Common\patches\Patch_RJW_BestialityPregnancyUtility.cs" />
<Compile Include="GeneDefOf.cs" />
<Compile Include="Genes\Breeding\Gene_MechBreeder.cs" />
<Compile Include="Genes\Breeding\PatchMechBirth.cs" />

View file

@ -17,58 +17,12 @@ namespace RJW_Genes
listing_Standard.ColumnWidth = rect.width / 2.05f;
listing_Standard.Begin(rect);
listing_Standard.Gap(24f);
listing_Standard.Label("Fertilin-Gain from Animals" + ": " +
Math.Round((double)(RJW_Genes_Settings.rjw_genes_fertilin_from_animals_factor * 100f), 0).ToString() + "%", -1f, "of fertilin gained (compared to human-baseline).");
RJW_Genes_Settings.rjw_genes_fertilin_from_animals_factor = listing_Standard.Slider(RJW_Genes_Settings.rjw_genes_fertilin_from_animals_factor, 0f, 3f);
listing_Standard.Gap(5f);
listing_Standard.CheckboxLabeled("Sexdemon Visits", ref rjw_genes_sexdemon_visit, "If enabled, incubi and succubi can spawn in through an event.", 0f, 1f);
if (rjw_genes_sexdemon_visit)
{
listing_Standard.Gap(3f);
listing_Standard.CheckboxLabeled(" Size matters", ref rjw_genes_sexdemon_join_size_matters, "Incubi and succubi will consider size/tightness of partners genital for deciding if they want to join", 0f, 1f);
listing_Standard.Gap(3f);
listing_Standard.CheckboxLabeled(" Sexdemon groups", ref rjw_genes_sexdemon_visit_groups, "Multiple sexdemons can spawn during a event", 0f, 1f);
listing_Standard.Gap(3f);
listing_Standard.CheckboxLabeled(" Succubi", ref rjw_genes_sexdemon_visit_succubi, "Allow incubi to spawn through this even", 0f, 1f);
listing_Standard.Gap(3f);
listing_Standard.CheckboxLabeled(" Incubi", ref rjw_genes_sexdemon_visit_incubi, "Allow incubi to spawn through this even", 0f, 1f);
}
listing_Standard.Gap(5f);
listing_Standard.CheckboxLabeled("generous-donor cheatmode", ref rjw_genes_generous_donor_cheatmode, "When enabled, pawns with the 'generous donor' are not drained and not fertilin exhausted. Hence they can fuel succubi and incubi non-stop. This makes them drastically easier to keep, and you should not do it.", 0f, 1f);
listing_Standard.Gap(5f);
listing_Standard.CheckboxLabeled("detailed-debug", ref rjw_genes_detailed_debug, "Adds detailed information to the log about interactions and genes.", 0f, 1f);
listing_Standard.End();
}
public override void ExposeData()
{
base.ExposeData();
Scribe_Values.Look<float>(ref RJW_Genes_Settings.rjw_genes_fertilin_from_animals_factor, "rjw_genes_fertilin_from_animals_factor", RJW_Genes_Settings.rjw_genes_fertilin_from_animals_factor, true);
Scribe_Values.Look<bool>(ref RJW_Genes_Settings.rjw_genes_detailed_debug, "rjw_genes_detailed_debug", RJW_Genes_Settings.rjw_genes_detailed_debug, true);
Scribe_Values.Look<bool>(ref RJW_Genes_Settings.rjw_genes_sexdemon_visit, "rjw_genes_sexdemon_visit", RJW_Genes_Settings.rjw_genes_sexdemon_visit, true);
Scribe_Values.Look<bool>(ref RJW_Genes_Settings.rjw_genes_sexdemon_join_size_matters, "rjw_genes_sexdemon_join_size_matters", RJW_Genes_Settings.rjw_genes_sexdemon_join_size_matters, true);
Scribe_Values.Look<bool>(ref RJW_Genes_Settings.rjw_genes_sexdemon_visit_groups, "rjw_genes_sexdemon_groups", RJW_Genes_Settings.rjw_genes_sexdemon_visit_groups, true);
Scribe_Values.Look<bool>(ref RJW_Genes_Settings.rjw_genes_sexdemon_visit_succubi, "rjw_genes_sexdemon_succubi", RJW_Genes_Settings.rjw_genes_sexdemon_visit_succubi, true);
Scribe_Values.Look<bool>(ref RJW_Genes_Settings.rjw_genes_sexdemon_visit_incubi, "rjw_genes_sexdemon_incubi", RJW_Genes_Settings.rjw_genes_sexdemon_visit_incubi, true);
Scribe_Values.Look<bool>(ref RJW_Genes_Settings.rjw_genes_generous_donor_cheatmode, "rjw_genes_generous_donor_cheatmode", RJW_Genes_Settings.rjw_genes_generous_donor_cheatmode, true);
}
public static bool rjw_genes_detailed_debug = false;
public static float rjw_genes_fertilin_from_animals_factor = 0.1f;
public static bool rjw_genes_sexdemon_visit = true;
public static bool rjw_genes_sexdemon_join_size_matters = true;
public static bool rjw_genes_sexdemon_visit_groups = true;
public static bool rjw_genes_sexdemon_visit_succubi = true;
public static bool rjw_genes_sexdemon_visit_incubi = true;
public static bool rjw_genes_generous_donor_cheatmode = false;
}
}