erdelf / AlienRaces

Rimworld mod alien race framework
MIT License
103 stars 69 forks source link

BodyReferenceTranspiler not applying #59

Closed brustmopf closed 1 year ago

brustmopf commented 3 years ago

The bodyReferenceTranspiler is not modifying the references to body done by the means of a call to the property RaceProperties.body (e.g. pawn.Raceproperties.body) This means that races with bodies assigned to custom LifeStageAgeAlien only have the default body.. I would suggest adding the following block to the transpiler method body :

                if (i < instructionList.Count - 1 && instructionList[i + 1].OperandIs(bodyInfo) && instruction.OperandIs(raceprops))
                {
                    instruction = new CodeInstruction(OpCodes.Call, AccessTools.Method(patchType, nameof(ReplacedBody)));
                    i++;
                }

at this location: https://github.com/erdelf/AlienRaces/blob/bcaabbcdd1d5098bb69ca53684371a02d83ca08a/Source/AlienRace/AlienRace/HarmonyPatches.cs#L1011

Testing would suggest this fixes the issue.

brustmopf commented 3 years ago

In addition, even with the fix above, there are a couple of references to body field that are not patched. I list the methods here:

-Verse.PawnKindDef.ConfigErrors() -Verse.ThingDef.ConfigErrors() -Verse.VerbProperties.ConfigErrors() -Verse.DamageWorker_Blunt.StunChances() -Verse.HediffSet+.GetNotMissingParts()