Added more checks to pheromone, fixes #25

This commit is contained in:
Vegapnk 2023-03-19 17:17:33 +01:00
parent 90204f9134
commit bb6fbb67d9
1 changed files with 19 additions and 3 deletions

View File

@ -39,9 +39,25 @@ namespace RJW_Genes
{
foreach (Pawn pawn in map.mapPawns.AllPawns)
{
if (pawn != null && this.pawn != null && pawn != this.pawn
&& pos.DistanceTo(pawn.Position) < APHRODISIAC_DISTANCE && GenSight.LineOfSight(pos, pawn.Position, pawn.Map)
&& !GeneUtility.HasGeneNullCheck(pawn, GeneDefOf.rjw_genes_aphrodisiac_pheromones))
// Return for trivial errors
if (pawn == null || this.pawn == null || pawn == this.pawn)
continue;
// Check for position-existance
if (pawn.Position == null || pos == null || pawn.Map == null)
continue;
// Do nothing if pawn is carried
if (pawn.CarriedBy != null)
continue;
// Do nothing if Pawn is Baby or Child (#25)
if (!pawn.ageTracker.Adult)
continue;
// Do nothing for pawns that also have pheromones
if (GeneUtility.HasGeneNullCheck(pawn, GeneDefOf.rjw_genes_aphrodisiac_pheromones))
continue;
// Actual Logic:
// Pawn qualifies in right distance and needs line of sight.
if (pos.DistanceTo(pawn.Position) < APHRODISIAC_DISTANCE && GenSight.LineOfSight(pos, pawn.Position, pawn.Map))
{
yield return pawn;
}