Added PheromoneSpit Gene

This commit is contained in:
Vegapnk 2024-06-01 10:12:00 +02:00
parent 48e06ff97f
commit a68c263aa1
7 changed files with 171 additions and 31 deletions

View file

@ -28,37 +28,9 @@ namespace RJW_Genes
public override void Apply(LocalTargetInfo target, LocalTargetInfo dest)
{
base.Apply(target, dest);
DoAnimalBreedingPulse();
ModLog.Message($"{this.parent.pawn} is casting MatingCall");
AnimalBreedingHelper.DoAnimalBreedingPulse(this.parent.pawn, Props.calldistance);
}
private void DoAnimalBreedingPulse()
{
if (fired) { return; }
IEnumerable<Pawn> animals = this.parent.pawn.Map.mapPawns.AllPawnsSpawned.Where<Pawn>((Func<Pawn, bool>)(p => p.IsNonMutantAnimal && p.Position.InHorDistOf(this.parent.pawn.Position, Props.calldistance)));
int breeder_counter = 0;
foreach (Pawn animal in animals)
{
if (animal.MentalState != null && (animal.MentalState.def == MentalStateDefOf.Manhunter || animal.MentalState.def == MentalStateDefOf.ManhunterPermanent))
{
Log.Warning("Found an angry Animal to Fuck");
animal?.MentalState?.RecoverFromState();
}
if(xxx.is_healthy_enough(animal))
{
// Stopping all Jobs in this way is a bit heavy - but as it's only about Animals this should be fine.
animal.jobs.CaptureAndClearJobQueue();
animal.jobs.StopAll();
Job job = JobMaker.MakeJob(xxx.animalBreed, this.parent.pawn);
animal.jobs.TryTakeOrderedJob(job);
breeder_counter++;
}
}
ModLog.Message($"{breeder_counter} of {animals.Count()} Animals in range are trying to breed {this.parent.pawn}");
fired = true;
}
}
}