Draft for Mating Call

This commit is contained in:
Vegapnk 2024-05-31 16:41:42 +02:00
parent 983bbfd727
commit 79895f352e
9 changed files with 157 additions and 4 deletions

View file

@ -0,0 +1,64 @@
using RimWorld;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Verse.Sound;
using Verse;
using RimWorld.Planet;
using rjw;
using HarmonyLib;
using Verse.AI;
namespace RJW_Genes
{
public class CompAbilityEffect_MatingCall : CompAbilityEffect
{
bool fired = false;
private new CompProperties_AbilityMatingCall Props
{
get
{
return (CompProperties_AbilityMatingCall)this.props;
}
}
public override void Apply(LocalTargetInfo target, LocalTargetInfo dest)
{
base.Apply(target, dest);
DoAnimalBreedingPulse();
}
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,20 @@
using RimWorld;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RJW_Genes
{
public class CompProperties_AbilityMatingCall : CompProperties_AbilityEffect
{
public int calldistance;
public CompProperties_AbilityMatingCall()
{
this.compClass = typeof(CompAbilityEffect_MatingCall);
}
}
}

View file

@ -64,8 +64,10 @@
<Compile Include="Common\ModLog.cs" />
<Compile Include="Common\Defs\TickIntervalExtension.cs" />
<Compile Include="Common\Patches\PatchImplants.cs" />
<Compile Include="Genes\Breeding\Gene_FerventOvipositor.cs" />
<Compile Include="Genes\Breeding\Gene_InsectIncubator.cs" />
<Compile Include="Genes\Breeding\Abilities\CompAbilityEffect_MatingCall.cs" />
<Compile Include="Genes\Breeding\Abilities\CompProperties_AbilityMatingCall.cs" />
<Compile Include="Genes\Breeding\Genes\Gene_FerventOvipositor.cs" />
<Compile Include="Genes\Breeding\Genes\Gene_InsectIncubator.cs" />
<Compile Include="Genes\Damage\Gene_Elasticity.cs" />
<Compile Include="Genes\Life_Force\Events\SuccubusVisit\IncidentWorker_SuccubusVisit.cs" />
<Compile Include="Genes\Life_Force\Events\SuccubusVisit\LordJob_SuccubusVisit.cs" />
@ -76,8 +78,8 @@
<Compile Include="Common\Patches\PatchGetParents.cs" />
<Compile Include="Common\Patches\PatchPregnancyHelper.cs" />
<Compile Include="GeneDefOf.cs" />
<Compile Include="Genes\Breeding\Gene_MechBreeder.cs" />
<Compile Include="Genes\Breeding\PatchMechBirth.cs" />
<Compile Include="Genes\Breeding\Genes\Gene_MechBreeder.cs" />
<Compile Include="Genes\Breeding\Patches\PatchMechBirth.cs" />
<Compile Include="Genes\ExtraGenitalia\Gene_Femboy.cs" />
<Compile Include="Genes\ExtraGenitalia\Gene_UdderBreasts.cs" />
<Compile Include="Genes\Gender\Defs\GenderFluidExtension.cs" />