mirror of
https://github.com/vegapnk/RJW-Genes.git
synced 2024-08-15 00:23:31 +00:00
Rework of InsectIncubator
This commit is contained in:
parent
765ef964c4
commit
c8dfa8fc89
4 changed files with 59 additions and 3 deletions
|
@ -3,8 +3,9 @@
|
|||
**Changes:**
|
||||
|
||||
- Cocoon Weaver Gene
|
||||
- Spawn Spelopede Gene (Can re changed to spawn Megascarabs or other insects)
|
||||
- Spawn Spelopede Gene (Can be changed to spawn Megascarabs or other insects via xml)
|
||||
- Queens & Caste Logic (see below)
|
||||
- Addition to InsectIncubator: Now fertilizes eggs once placed inside a host, and breeds out eggs twice as fast.
|
||||
|
||||
**Internal:**
|
||||
|
||||
|
|
|
@ -169,7 +169,8 @@
|
|||
|
||||
<GeneDef>
|
||||
<defName>rjw_genes_insectincubator</defName>
|
||||
<label>InsectIncubator</label>
|
||||
<label>InsectIncubator</label>
|
||||
<geneClass>RJW_Genes.Gene_InsectIncubator</geneClass>
|
||||
<description>Pawns with this gene are able to host more insect eggs, hatch them faster and fertilize any inserted egg.</description>
|
||||
<iconPath>Genes/Icons/More_Egg_Space</iconPath>
|
||||
<displayOrderInCategory>52</displayOrderInCategory>
|
||||
|
|
53
Source/Genes/Hive/Genes/Gene_InsectIncubator.cs
Normal file
53
Source/Genes/Hive/Genes/Gene_InsectIncubator.cs
Normal file
|
@ -0,0 +1,53 @@
|
|||
using RimWorld;
|
||||
using rjw;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Verse;
|
||||
|
||||
namespace RJW_Genes
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// This Gene checks for all parasitic Insect-Eggs in a Pawn:
|
||||
/// 1. Is it fertilized ? => tick it down "extra".
|
||||
/// 2. Is it not fertilized? => fertilize it with the Incubator as parent
|
||||
///
|
||||
/// Important: The other half of the behavior for the gene (more egg-capacity) is in `Patch_InsectINcubator_PregnancyHelper`.
|
||||
/// </summary>
|
||||
public class Gene_InsectIncubator : Gene
|
||||
{
|
||||
|
||||
const int TICK_INTERVAL = 60000 / 48; // 60k = 1 day, we want 0.5h which is 1/48th of 1 day.
|
||||
|
||||
public override void Tick()
|
||||
{
|
||||
base.Tick();
|
||||
|
||||
// Don't check too often, only in the HashTickInterval to safe some computing power
|
||||
if (this.pawn.IsHashIntervalTick(TICK_INTERVAL) && this.pawn.Map != null)
|
||||
{
|
||||
List<Hediff_InsectEgg> eggs = new List<Hediff_InsectEgg>();
|
||||
pawn.health.hediffSet.GetHediffs<Hediff_InsectEgg>(ref eggs);
|
||||
|
||||
foreach (Hediff_InsectEgg egg in eggs)
|
||||
{
|
||||
// The implanter check checks if the egg is still in an ovipositor.
|
||||
if (egg.implanter == null || egg.implanter == pawn)
|
||||
continue;
|
||||
|
||||
if (!egg.fertilized && egg.implanter != null) {
|
||||
egg.Fertilize(pawn);
|
||||
if (RJW_Genes_Settings.rjw_genes_detailed_debug) ModLog.Message($"Gene_InsectIncubator: fertilized egg {egg} in {pawn}");
|
||||
}
|
||||
else if (egg.fertilized)
|
||||
{
|
||||
egg.lastTick += TICK_INTERVAL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -43,8 +43,9 @@
|
|||
<Compile Include="GeneDefOf.cs" />
|
||||
<Compile Include="Genes\Breeding\Gene_MechBreeder.cs" />
|
||||
<Compile Include="Genes\Breeding\PatchMechBirth.cs" />
|
||||
<Compile Include="Genes\Hive\Genes\Gene_InsectIncubator.cs" />
|
||||
<Compile Include="Genes\Hive\Patches\Patch_InsectBreeder_EggFertilization.cs" />
|
||||
<Compile Include="Genes\Breeding\PatchPregnancyHelper.cs" />
|
||||
<Compile Include="Genes\Hive\Patches\Patch_InsectIncubator_PregnancyHelper.cs" />
|
||||
<Compile Include="Genes\Cum\CumUtility.cs" />
|
||||
<Compile Include="Genes\Cum\Gene_VeryMuchCum.cs" />
|
||||
<Compile Include="Genes\Cum\Gene_MuchCum.cs" />
|
||||
|
|
Loading…
Reference in a new issue