RamRod6198 / Z-Levels

55 stars 33 forks source link

Joy in hospital beds #80

Open Archoran opened 3 years ago

Archoran commented 3 years ago

When a pawn has low joy while downed in a bed, it can stand up and immediately fall down to ground again.

Archoran commented 3 years ago

The root for this issue sits in the Joy Giver Patch of yours. It searches not only for the currently allowed joy giving tasks but for all of them - leading the pawn to try to get to the billards table or something which it cannot do, because it's legs are broken.

I would recommend to take the Game source code as sample for this:

...
this.joyGiverChances[joyGiverDef] = 0f;
if (this.JoyGiverAllowed(joyGiverDef) && !pawn.needs.joy.tolerances.BoredOf(joyGiverDef.joyKind)
    && joyGiverDef.Worker.CanBeGivenTo(pawn))
{
    if (joyGiverDef.pctPawnsEverDo < 1f)
    ...

The part this.JoyGiverAllowed(joyGiverDef) is missing in your function - JobPatches.JobGiver_GetJoyPatch.TryGiveJob. Hope that I can help a bit. (it's line 621 btw.)

Archoran commented 3 years ago

(in general I would recommend a massive revise of the JobPatches class... cause it generates performance problems.)