Tachyonite / Pawnmorpher

A mod all about mutation for Rimworld 1.3!
20 stars 20 forks source link

Alien race compatibility improvement #587

Closed SirMashedPotato closed 2 years ago

SirMashedPotato commented 2 years ago

Describe the bug Non-mechanoid pawns that don't use Normal flesh type can't be mutated, even if they aren't actually mechanoid in nature.

To Reproduce You try mutate a pawn that doesn't use the Normal flesh type, such as ESCP - Sloads. And they don't gain the mutagenic build-up hediff.

Expected behavior Mutagen.CanInfect should check HAR's compatibility fields, specifically isFlesh. If the pawn is flesh, then it doesn't return.

Additional context https://github.com/Tachyonite/Pawnmorpher/blob/0dc196ce0b7900b2b41596669413015f4ebbef7b/Source/Pawnmorphs/Esoteria/TfSys/Mutagen.cs#L102

Changing it to something along the lines of this should fix it.

if (!def.canInfectMechanoids)
{
     if(pawn.def is AlienRace.ThingDef_AlienRace a && !a.alienRace.compatibility.IsFlesh)
     {
          return false;
     }
     else
     {
          if(pawn.RaceProps.FleshType != FleshTypeDefOf.Normal)
          {
               return false;
          }
     }
}
SirMashedPotato commented 2 years ago

Realised while I was in the shower, my example above wouldn't actually work, so here's take 2.

if (!def.canInfectMechanoids)
{
     if(pawn.def is AlienRace.ThingDef_AlienRace a)
     {
          if(!a.alienRace.compatibility.IsFlesh)
          {
                    return false;
          }
     }
     else
     {
          if(pawn.RaceProps.FleshType != FleshTypeDefOf.Normal)
          {
               return false;
          }
     }
}
Zeracronius commented 2 years ago

Definitely sounds like something to look into, and by the surface as a good solution.

I did not know that HAR had race compatibility information, so that is something to look further into too.