fix issue #2 "Exception on animal mating"
+ function SexInteractionUtility::getBestialityRoles extracted from functions SexActIsBestialityWithOrdinaryAnimal, SexActIsBestialityWithSpecialAnimal
This commit is contained in:
parent
211442e7eb
commit
68c7246ef7
|
@ -146,24 +146,46 @@ namespace Privacy_Please
|
|||
return BasicSettings.worryAboutBeastiality && jobDriver.Partner != null && jobDriver.Partner.RaceProps.Animal;
|
||||
}
|
||||
|
||||
/** <returns>whether the act is bestiality to begin with, and if so, first the humanoid and then the animal</returns> */
|
||||
static (bool IsBestiality, Pawn Humanoid, Pawn Animal) getBestialityRoles(JobDriver_Sex jobDriver)
|
||||
{
|
||||
(bool, Pawn, Pawn) nope = (false, null, null);
|
||||
if (!BasicSettings.worryAboutBeastiality) return nope;
|
||||
|
||||
/* can be animal, if...
|
||||
* - RJW option "animal on animal" is enabled
|
||||
* - RJW option "bestiality" is enabled and an animal has the "breeder" designator
|
||||
*/
|
||||
var actor = jobDriver.GetActor();
|
||||
/* can be animal, if...
|
||||
* - RJW option "animal on animal" is enabled
|
||||
* - RJW option "bestiality" is enabled
|
||||
*/
|
||||
var target = jobDriver.Partner;
|
||||
|
||||
if (actor.IsAnimal() && target.RaceProps.Humanlike) return (true, target, actor);
|
||||
else if (actor.RaceProps.Humanlike && target.IsAnimal()) return (true, actor, target);
|
||||
return nope;
|
||||
}
|
||||
|
||||
public static bool SexActIsBestialityWithOrdinaryAnimal(JobDriver_Sex jobDriver, Pawn witness = null)
|
||||
{
|
||||
if (BasicSettings.worryAboutBeastiality == false) return false;
|
||||
var (IsBestiality, Humanoid, Animal) = getBestialityRoles(jobDriver);
|
||||
if (!IsBestiality) return false;
|
||||
|
||||
if (jobDriver.Partner == null || jobDriver.Partner.RaceProps.Animal == false) return false;
|
||||
if (jobDriver.pawn.Ideo.PreceptsListForReading.Any(x => x.def.defName == "Bestiality_BondOnly") && jobDriver.Partner.relations.GetFirstDirectRelationPawn(PawnRelationDefOf.Bond) != jobDriver.pawn) return true;
|
||||
if (jobDriver.pawn.Ideo.PreceptsListForReading.Any(x => x.def.defName == "Bestiality_OnlyVenerated") && jobDriver.pawn.Ideo.IsVeneratedAnimal(jobDriver.Partner) == false) return true;
|
||||
if (Humanoid.Ideo.PreceptsListForReading.Any(x => x.def.defName == "Bestiality_BondOnly") && Animal.relations.GetFirstDirectRelationPawn(PawnRelationDefOf.Bond) != Humanoid) return true;
|
||||
if (Humanoid.Ideo.PreceptsListForReading.Any(x => x.def.defName == "Bestiality_OnlyVenerated") && !Humanoid.Ideo.IsVeneratedAnimal(Animal)) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool SexActIsBestialityWithSpecialAnimal(JobDriver_Sex jobDriver, Pawn witness = null)
|
||||
{
|
||||
if (BasicSettings.worryAboutBeastiality == false) return false;
|
||||
var (IsBestiality, Humanoid, Animal) = getBestialityRoles(jobDriver);
|
||||
if (!IsBestiality) return false;
|
||||
|
||||
if (jobDriver.Partner == null || jobDriver.Partner.RaceProps.Animal == false) return false;
|
||||
if (jobDriver.pawn.Ideo.PreceptsListForReading.Any(x => x.def.defName == "Bestiality_BondOnly") && jobDriver.Partner.relations.GetFirstDirectRelationPawn(PawnRelationDefOf.Bond) == jobDriver.pawn) return true;
|
||||
if (jobDriver.pawn.Ideo.PreceptsListForReading.Any(x => x.def.defName == "Bestiality_OnlyVenerated") && jobDriver.pawn.Ideo.IsVeneratedAnimal(jobDriver.Partner) == true) return true;
|
||||
if (Humanoid.Ideo.PreceptsListForReading.Any(x => x.def.defName == "Bestiality_BondOnly") && Animal.relations.GetFirstDirectRelationPawn(PawnRelationDefOf.Bond) == Humanoid) return true;
|
||||
if (Humanoid.Ideo.PreceptsListForReading.Any(x => x.def.defName == "Bestiality_OnlyVenerated") && Humanoid.Ideo.IsVeneratedAnimal(Animal)) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue