mirror of
https://gitgud.io/lutepickle/rjw_menstruation.git
synced 2024-08-14 22:46:52 +00:00
Use 'original' parameter for the birth outcome patch instead of looking up the function again
This commit is contained in:
parent
def0c04838
commit
c402f871b6
2 changed files with 2 additions and 4 deletions
Binary file not shown.
|
@ -175,13 +175,11 @@ namespace RJW_Menstruation
|
||||||
return baby;
|
return baby;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static readonly MethodInfo ApplyBirthOutcome_NewTemp = typeof(PregnancyUtility).GetMethod(nameof(PregnancyUtility.ApplyBirthOutcome_NewTemp));
|
|
||||||
private static readonly int birtherThing = ApplyBirthOutcome_NewTemp.GetParameters().FirstIndexOf(parameter => parameter.Name == "birtherThing" && parameter.ParameterType == typeof(Thing));
|
|
||||||
private static readonly MethodInfo GeneratePawn = typeof(PawnGenerator).GetMethod(nameof(PawnGenerator.GeneratePawn), new Type[] {typeof (PawnGenerationRequest)});
|
private static readonly MethodInfo GeneratePawn = typeof(PawnGenerator).GetMethod(nameof(PawnGenerator.GeneratePawn), new Type[] {typeof (PawnGenerationRequest)});
|
||||||
|
public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, MethodBase original)
|
||||||
public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
|
|
||||||
{
|
{
|
||||||
bool methodPatched = false;
|
bool methodPatched = false;
|
||||||
|
int birtherThing = original.GetParameters().FirstIndexOf(parameter => parameter.Name == "birtherThing" && parameter.ParameterType == typeof(Thing));
|
||||||
if (birtherThing < 0) throw new InvalidOperationException("Could not locate index of birtherThing");
|
if (birtherThing < 0) throw new InvalidOperationException("Could not locate index of birtherThing");
|
||||||
if (GeneratePawn?.ReturnType != typeof(Pawn)) throw new InvalidOperationException("GeneratePawn not found");
|
if (GeneratePawn?.ReturnType != typeof(Pawn)) throw new InvalidOperationException("GeneratePawn not found");
|
||||||
foreach (CodeInstruction instruction in instructions)
|
foreach (CodeInstruction instruction in instructions)
|
||||||
|
|
Loading…
Reference in a new issue