Add an explanation to the CompPostPostRemoved check, as well as refactor the checks a bit

This commit is contained in:
lutepickle 2022-07-20 10:25:57 -07:00
parent 947c61c8a2
commit d0210c23bf
3 changed files with 4 additions and 2 deletions

Binary file not shown.

View File

@ -184,7 +184,7 @@ namespace RJW_Menstruation
public override void CompPostPostRemoved()
{
if (parent.pawn.GetBreastComp() == this)
if (parent.pawn.health.hediffSet.hediffs.Contains(parent))
{
Log.Warning($"Attempted to remove breast comp from wrong pawn ({parent.pawn}).");
return;

View File

@ -527,7 +527,9 @@ namespace RJW_Menstruation
public override void CompPostPostRemoved()
{
if (parent.pawn.GetMenstruationComps().Contains(this))
// If a hediff is removed from a pawn that does not have it, CompPostPostRemoved is still called on the pawn that does.
// If it was a legitimate removal, then it won't be in this pawn's hediff list anymore, as that removal occurs first
if (parent.pawn.health.hediffSet.hediffs.Contains(parent))
{
Log.Warning($"Attempted to remove menstruation comp from wrong pawn ({parent.pawn}).");
return;