mirror of
https://github.com/vegapnk/RJW-Genes.git
synced 2024-08-15 00:23:31 +00:00
Draft for Mating Call
This commit is contained in:
parent
983bbfd727
commit
79895f352e
9 changed files with 157 additions and 4 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue