WhatTheHack
WhatTheHack copied to clipboard
NRE in RimWorld.Planet.TrySatisfyPawnNeeds
NRE here because hacked mechaniods have no Psychic tracker
private void TrySatisfyPawnNeeds(Pawn pawn)
{
...
Pawn_PsychicEntropyTracker psychicEntropy = pawn.psychicEntropy;
if (psychicEntropy.Psylink != null)
{
TryGainPsyfocus(psychicEntropy);
}
}
I added this:
if (pawn.psychicEntropy == null)
pawn.psychicEntropy = new Pawn_PsychicEntropyTracker(pawn);
after this:
public static class PawnComponentsUtility_AddAndRemoveDynamicComponents
{
static void Postfix(Pawn pawn)
{
if (flagIsCreatureMine && flagIsCreatureDraftable)
{
//If everything goes well, add drafter to the pawn
pawn.drafter = new Pawn_DraftController(pawn);
...
In PR #49 i added
pawn.psychicEntropy = new Pawn_PsychicEntropyTracker(pawn);
in Recipe_HackMechanoid.PostSuccessfulApply
. This will create pawn.psychicEntropy
when a mechanoid is hacked.
But now that i think about, it won't add it to already hacked mechanoids.
So if you have already hacked mechanoids before this fix - they will still throw errors in caravans. You need to delete/rehack/... them.
So maybe add addition check in PawnComponentsUtility_AddAndRemoveDynamicComponents
as i did in the first place when open this issue ?