Update the hookup transpilers to apply the estrus overrides in the other direction.

This commit is contained in:
lutepickle 2022-05-28 19:05:10 -07:00
parent 72e1712394
commit 41054f979e
3 changed files with 22 additions and 16 deletions

Binary file not shown.

View File

@ -196,15 +196,16 @@ namespace RJW_Menstruation
public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
{
// We only want the first fuckability check, i.e. the estrus-haver towards a partner
bool found_fuckability = false;
bool first_fuckability = true;
foreach(CodeInstruction instruction in instructions)
{
if(!found_fuckability && instruction.LoadsField(MinimumFuckabilityToHookup))
if(instruction.LoadsField(MinimumFuckabilityToHookup))
{
found_fuckability = true;
yield return new CodeInstruction(OpCodes.Ldarg_0);
yield return new CodeInstruction(OpCodes.Ldarg_1);
yield return new CodeInstruction(first_fuckability ? OpCodes.Ldarg_0 : OpCodes.Ldarg_1);
yield return new CodeInstruction(first_fuckability ? OpCodes.Ldarg_1 : OpCodes.Ldarg_0);
yield return CodeInstruction.Call(typeof(Roll_To_Skip_Patch), nameof(FuckabilityThreshold));
first_fuckability = false;
}
else yield return instruction;
}
@ -231,8 +232,8 @@ namespace RJW_Menstruation
{
LocalBuilder pawn_index = null;
// Like in the last one, we're only interested in the first of each
bool found_first_attractiveness = false;
bool found_first_relationship = false;
bool first_attractiveness = true;
bool first_relationship = true;
foreach(CodeInstruction instruction in instructions)
{
// Get where the compiler decided to index the pawn at
@ -241,23 +242,27 @@ namespace RJW_Menstruation
pawn_index = (LocalBuilder)instruction.operand;
yield return instruction;
}
else if (!found_first_attractiveness && instruction.LoadsField(MinimumAttractivenessToHookup))
else if (instruction.LoadsField(MinimumAttractivenessToHookup))
{
if (pawn_index?.LocalType != typeof(Pawn))
throw new System.InvalidOperationException($"pawn_index is not a Pawn ({pawn_index?.LocalType})");
found_first_attractiveness = true;
yield return new CodeInstruction(OpCodes.Ldarg_0);
yield return new CodeInstruction(OpCodes.Ldloc_S, pawn_index);
yield return first_attractiveness ? new CodeInstruction(OpCodes.Ldarg_0) : new CodeInstruction(OpCodes.Ldloc_S, pawn_index);
yield return first_attractiveness ? new CodeInstruction(OpCodes.Ldloc_S, pawn_index) : new CodeInstruction(OpCodes.Ldarg_0);
yield return CodeInstruction.Call(typeof(FindBestPartner_Patch), nameof(AttractivenessThreshold));
}
else if (!found_first_relationship && instruction.LoadsField(MinimumRelationshipToHookup))
first_attractiveness = false;
}
else if (instruction.LoadsField(MinimumRelationshipToHookup))
{
if (pawn_index?.LocalType != typeof(Pawn))
throw new System.InvalidOperationException($"pawn_index is not a Pawn ({pawn_index?.LocalType})");
found_first_relationship = true;
yield return new CodeInstruction(OpCodes.Ldarg_0);
yield return new CodeInstruction(OpCodes.Ldloc_S, pawn_index);
yield return first_relationship ? new CodeInstruction(OpCodes.Ldarg_0) : new CodeInstruction(OpCodes.Ldloc_S, pawn_index);
yield return first_relationship ? new CodeInstruction(OpCodes.Ldloc_S, pawn_index) : new CodeInstruction(OpCodes.Ldarg_0);
yield return CodeInstruction.Call(typeof(FindBestPartner_Patch), nameof(RelationshipThreshold));
first_relationship = false;
}
else yield return instruction;
}

View File

@ -2,6 +2,7 @@ Version 1.0.6.3
- Fix pawn generation for races with a single lifestage.
- Show womb gizmo for males with vaginas, too.
- Show the status button in the health tab for pawns with more than one genital.
- The hookup override will now apply for pawns in estrus being considered by others.
Version 1.0.6.2
- Fix error/crash when a pawn in estrus (with hookup override enabled) looks for partners.