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;
}
}
}

View file

@ -0,0 +1,31 @@
using RimWorld;
using rjw;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Verse;
using Verse.AI;
namespace RJW_Genes
{
public class CompAbilityEffect_PheromoneSpit : CompAbilityEffect
{
bool fired = false;
private new CompProperties_AbilityPheromoneSpit Props
{
get
{
return (CompProperties_AbilityPheromoneSpit)this.props;
}
}
public override void Apply(LocalTargetInfo target, LocalTargetInfo dest)
{
base.Apply(target, dest);
AnimalBreedingHelper.DoAnimalBreedingPulse(target.Pawn, Props.calldistance);
}
}
}

View file

@ -0,0 +1,18 @@
using RimWorld;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RJW_Genes {
public class CompProperties_AbilityPheromoneSpit : CompProperties_AbilityEffect
{
public int calldistance;
public CompProperties_AbilityPheromoneSpit()
{
this.compClass = typeof(CompAbilityEffect_PheromoneSpit);
}
}
}