(Re-)work around a bug in RJW (and potentially any number of other mods) that causes CompPostPostRemoved to be called on the wrong pawn.

This commit is contained in:
lutepickle 2022-07-20 09:56:04 -07:00
parent 1125930869
commit 54e41b7aa4
3 changed files with 10 additions and 0 deletions

Binary file not shown.

View file

@ -184,6 +184,11 @@ namespace RJW_Menstruation
public override void CompPostPostRemoved()
{
if (parent.pawn.GetBreastComp() == this)
{
Log.Warning($"Attempted to remove breast comp from wrong pawn ({parent.pawn}).");
return;
}
HugsLibController.Instance.TickDelayScheduler.TryUnscheduleCallback(action);
Log.Message(parent.pawn.Label + " breast tick scheduler removed");
base.CompPostPostRemoved();

View file

@ -527,6 +527,11 @@ namespace RJW_Menstruation
public override void CompPostPostRemoved()
{
if (parent.pawn.GetMenstruationComps().Contains(this))
{
Log.Warning($"Attempted to remove menstruation comp from wrong pawn ({parent.pawn}).");
return;
}
HugsLibController.Instance.TickDelayScheduler.TryUnscheduleCallback(actionref);
Log.Message(parent.pawn.Label + " tick scheduler removed");
pregnancy?.Miscarry();