mirror of
				https://github.com/vegapnk/RJW-Genes.git
				synced 2024-08-15 00:23:31 +00:00 
			
		
		
		
	Rescued Cocoonweaver, FerventOvipositor and InsectIncubator into Breeding Genes
This commit is contained in:
		
							parent
							
								
									9c273d5567
								
							
						
					
					
						commit
						51b988f18c
					
				
					 10 changed files with 348 additions and 20 deletions
				
			
		| 
						 | 
				
			
			@ -29,6 +29,7 @@
 | 
			
		|||
- Slider for Evergrowth Tick-Speed, thanks to @jaaldabaoth
 | 
			
		||||
- Resizing Age for resizing Genes can be set in Settings @jaaldabaoth
 | 
			
		||||
- **Licentia related genes are only placeholders**, as Licentia is not 1.5 yet
 | 
			
		||||
- InsectIncubator only does self-fertilization now, but does not increase storage capacities for eggs anymore
 | 
			
		||||
 | 
			
		||||
**Fixes:** 
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										34
									
								
								Common/Defs/AbilityDefs/Ability_CocoonWeaver.xml
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								Common/Defs/AbilityDefs/Ability_CocoonWeaver.xml
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,34 @@
 | 
			
		|||
<?xml version="1.0" encoding="utf-8" ?>
 | 
			
		||||
<Defs>
 | 
			
		||||
  <AbilityDef ParentName="AbilityTouchBase">
 | 
			
		||||
    <defName>rjw_genes_ability_cocoonweaver</defName>
 | 
			
		||||
    <label>Cocoon</label>
 | 
			
		||||
    <description>Weaves the victim into a (self-sustaining) cocoon. The victim cannot move, but can be bred.</description>
 | 
			
		||||
    <iconPath>Genes/Icons/Cocoon</iconPath>
 | 
			
		||||
    <stunTargetWhileCasting>true</stunTargetWhileCasting>
 | 
			
		||||
    <displayGizmoWhileUndrafted>true</displayGizmoWhileUndrafted>
 | 
			
		||||
    <disableGizmoWhileUndrafted>false</disableGizmoWhileUndrafted>
 | 
			
		||||
    <warmupMote>Mote_CocoonStencil</warmupMote>
 | 
			
		||||
    <warmupEffecter>CocoonWeave</warmupEffecter>
 | 
			
		||||
    <jobDef>CastAbilityOnThingMelee</jobDef>
 | 
			
		||||
    <displayOrder>404</displayOrder>
 | 
			
		||||
    <!-- 30k Ticks = 12h -->
 | 
			
		||||
    <cooldownTicksRange>30000</cooldownTicksRange>
 | 
			
		||||
    <verbProperties>
 | 
			
		||||
      <verbClass>Verb_CastAbilityTouch</verbClass>
 | 
			
		||||
      <drawAimPie>false</drawAimPie>
 | 
			
		||||
      <range>-1</range>
 | 
			
		||||
      <warmupTime>15</warmupTime>
 | 
			
		||||
      <targetParams>
 | 
			
		||||
        <canTargetAnimals>true</canTargetAnimals>
 | 
			
		||||
        <canTargetSelf>false</canTargetSelf>
 | 
			
		||||
        <canTargetBuildings>false</canTargetBuildings>
 | 
			
		||||
        <canTargetMechs>false</canTargetMechs>
 | 
			
		||||
        <canTargetBloodfeeders>true</canTargetBloodfeeders>
 | 
			
		||||
      </targetParams>
 | 
			
		||||
    </verbProperties>
 | 
			
		||||
    <comps>
 | 
			
		||||
      <li Class="RJW_Genes.CompProperties_AbilityCocoonWeaver"/>
 | 
			
		||||
    </comps>
 | 
			
		||||
  </AbilityDef>
 | 
			
		||||
</Defs>
 | 
			
		||||
							
								
								
									
										37
									
								
								Common/Defs/Effects/cocoonweave.xml
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								Common/Defs/Effects/cocoonweave.xml
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,37 @@
 | 
			
		|||
<?xml version="1.0" encoding="utf-8" ?>
 | 
			
		||||
<Defs>
 | 
			
		||||
 | 
			
		||||
  <EffecterDef>
 | 
			
		||||
    <defName>CocoonWeave</defName>
 | 
			
		||||
    <children>
 | 
			
		||||
      <li>
 | 
			
		||||
        <subEffecterClass>SubEffecter_SprayerChance</subEffecterClass>
 | 
			
		||||
        <fleckDef>BloodSplash</fleckDef>
 | 
			
		||||
        <chancePerTick>0.15</chancePerTick>
 | 
			
		||||
        <burstCount>2~3</burstCount>
 | 
			
		||||
        <scale>0.75~1.5</scale>
 | 
			
		||||
        <color>(244, 244, 244)</color>
 | 
			
		||||
        <spawnLocType>RandomDrawPosOnTarget</spawnLocType>
 | 
			
		||||
        <attachToSpawnThing>true</attachToSpawnThing>
 | 
			
		||||
      </li>
 | 
			
		||||
    </children>
 | 
			
		||||
  </EffecterDef>
 | 
			
		||||
 | 
			
		||||
  <ThingDef ParentName="MoteBase">
 | 
			
		||||
    <defName>Mote_CocoonStencil</defName>
 | 
			
		||||
    <thingClass>MoteAttached</thingClass>
 | 
			
		||||
    <altitudeLayer>Terrain</altitudeLayer>
 | 
			
		||||
    <mote>
 | 
			
		||||
      <fadeInTime>0.1</fadeInTime>
 | 
			
		||||
      <fadeOutTime>0.4</fadeOutTime>
 | 
			
		||||
      <solidTime>999999</solidTime>
 | 
			
		||||
      <needsMaintenance>True</needsMaintenance>
 | 
			
		||||
    </mote>
 | 
			
		||||
    <graphicData>
 | 
			
		||||
      <graphicClass>Graphic_PawnBodySilhouette</graphicClass>
 | 
			
		||||
      <shaderType>PawnSilhouetteStencil</shaderType>
 | 
			
		||||
      <texPath>Things/Mote/Transparent</texPath>
 | 
			
		||||
    </graphicData>
 | 
			
		||||
  </ThingDef>
 | 
			
		||||
 | 
			
		||||
</Defs>
 | 
			
		||||
| 
						 | 
				
			
			@ -2,28 +2,31 @@
 | 
			
		|||
<Defs>
 | 
			
		||||
  <!-- rjw_genes_mechbreeder,rjw_genes_insectincubator and rjw_genes_insectbreeder were kindly supplied by `Shabalox` https://github.com/Shabalox/RJW_Genes_Addons/ -->
 | 
			
		||||
 | 
			
		||||
  <GeneDef>
 | 
			
		||||
  <GeneDef Name="BreedingBase" Abstract="True">
 | 
			
		||||
		<displayCategory>rjw_genes_breeding</displayCategory>
 | 
			
		||||
 | 
			
		||||
		<modExtensions>
 | 
			
		||||
				<li MayRequire="OskarPotocki.VanillaFactionsExpanded.Core" Class="VanillaGenesExpanded.GeneExtension">
 | 
			
		||||
					<backgroundPathEndogenes>Genes/Icons/RJW_Genes_Endogene_Background</backgroundPathEndogenes>
 | 
			
		||||
					<backgroundPathXenogenes>Genes/Icons/RJW_Genes_Xenogene_Background</backgroundPathXenogenes>
 | 
			
		||||
				</li>
 | 
			
		||||
			</modExtensions>
 | 
			
		||||
	</GeneDef>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  <GeneDef ParentName="BreedingBase">
 | 
			
		||||
    <defName>rjw_genes_mechbreeder</defName>
 | 
			
		||||
    <label>Mechbreeder</label>
 | 
			
		||||
    <description>Pawns with this gene are able to birth mechanoids unharmed.</description>
 | 
			
		||||
    <iconPath>World/WorldObjects/Expanding/Mechanoids</iconPath>
 | 
			
		||||
    <displayOrderInCategory>51</displayOrderInCategory>
 | 
			
		||||
	  <displayCategory>rjw_genes_breeding</displayCategory>
 | 
			
		||||
    <biostatCpx>1</biostatCpx>
 | 
			
		||||
    <biostatMet>-1</biostatMet>
 | 
			
		||||
 | 
			
		||||
    <modExtensions>
 | 
			
		||||
			<li MayRequire="OskarPotocki.VanillaFactionsExpanded.Core" Class="VanillaGenesExpanded.GeneExtension">
 | 
			
		||||
				<backgroundPathEndogenes>Genes/Icons/RJW_Genes_Endogene_Background</backgroundPathEndogenes>
 | 
			
		||||
				<backgroundPathXenogenes>Genes/Icons/RJW_Genes_Xenogene_Background</backgroundPathXenogenes>
 | 
			
		||||
			</li>
 | 
			
		||||
		</modExtensions>
 | 
			
		||||
  </GeneDef>
 | 
			
		||||
  
 | 
			
		||||
  <GeneDef>
 | 
			
		||||
  <GeneDef ParentName="BreedingBase">
 | 
			
		||||
      <defName>rjw_genes_zoophile</defName>
 | 
			
		||||
      <label>Zoophile</label>
 | 
			
		||||
      <displayCategory>rjw_genes_breeding</displayCategory>
 | 
			
		||||
      <description>Xenotypes with this Gene are Zoophile.</description>
 | 
			
		||||
      <iconPath>Genes/Icons/Zoophile</iconPath>
 | 
			
		||||
      <displayOrderInCategory>54</displayOrderInCategory>    
 | 
			
		||||
| 
						 | 
				
			
			@ -32,22 +35,46 @@
 | 
			
		|||
              <def>Zoophile</def>
 | 
			
		||||
          </li>
 | 
			
		||||
      </forcedTraits>
 | 
			
		||||
 | 
			
		||||
    <modExtensions>
 | 
			
		||||
			<li MayRequire="OskarPotocki.VanillaFactionsExpanded.Core" Class="VanillaGenesExpanded.GeneExtension">
 | 
			
		||||
				<backgroundPathEndogenes>Genes/Icons/RJW_Genes_Endogene_Background</backgroundPathEndogenes>
 | 
			
		||||
				<backgroundPathXenogenes>Genes/Icons/RJW_Genes_Xenogene_Background</backgroundPathXenogenes>
 | 
			
		||||
			</li>
 | 
			
		||||
		</modExtensions>
 | 
			
		||||
  </GeneDef>
 | 
			
		||||
  
 | 
			
		||||
  <GeneDef>
 | 
			
		||||
  <GeneDef ParentName="BreedingBase">
 | 
			
		||||
      <defName>rjw_genes_fertile_anus</defName>
 | 
			
		||||
      <label>Fertile Anus</label>
 | 
			
		||||
      <displayCategory>rjw_genes_breeding</displayCategory>
 | 
			
		||||
      <description>Xenotypes with this gene have a functional uterus connected to the anal cavity even for males</description>
 | 
			
		||||
      <iconPath>Genes/Icons/Fertile_anus</iconPath>
 | 
			
		||||
      <displayOrderInCategory>54</displayOrderInCategory>    
 | 
			
		||||
  </GeneDef>
 | 
			
		||||
 | 
			
		||||
  <GeneDef ParentName="BreedingBase">
 | 
			
		||||
    <defName>rjw_genes_insectincubator</defName>
 | 
			
		||||
    <label>Insect Incubator</label>	
 | 
			
		||||
	  <geneClass>RJW_Genes.Gene_InsectIncubator</geneClass>
 | 
			
		||||
    <description>Pawns with this gene fertilize insect eggs that are placed inside them.</description>
 | 
			
		||||
    <iconPath>Genes/Icons/Egg</iconPath>
 | 
			
		||||
    <displayOrderInCategory>52</displayOrderInCategory>
 | 
			
		||||
    <biostatCpx>1</biostatCpx>
 | 
			
		||||
    <biostatMet>-1</biostatMet>
 | 
			
		||||
  </GeneDef>
 | 
			
		||||
 | 
			
		||||
  <GeneDef ParentName="BreedingBase">
 | 
			
		||||
    <defName>rjw_genes_insectbreeder</defName>
 | 
			
		||||
    <label>Insect Breeder</label>	
 | 
			
		||||
    <description>Pawns with this gene are able to fertilize eggs with any fertile penis.</description>
 | 
			
		||||
    <iconPath>Genes/Icons/Insect_Breeder</iconPath>
 | 
			
		||||
    <displayOrderInCategory>53</displayOrderInCategory>
 | 
			
		||||
    <biostatCpx>1</biostatCpx>
 | 
			
		||||
    <biostatMet>-1</biostatMet>
 | 
			
		||||
  </GeneDef>
 | 
			
		||||
 | 
			
		||||
  <GeneDef ParentName="BreedingBase">
 | 
			
		||||
    <defName>rjw_genes_fervent_ovipositor</defName>
 | 
			
		||||
    <label>Fervent Ovipositor</label>	
 | 
			
		||||
	  <geneClass>RJW_Genes.Gene_FerventOvipositor</geneClass>
 | 
			
		||||
    <description>Pawns that have a female (egg producing) ovipositor produce eggs at drastically increased speed.</description>
 | 
			
		||||
    <iconPath>Genes/Icons/Fervent_Ovipositor</iconPath>
 | 
			
		||||
    <displayOrderInCategory>55</displayOrderInCategory>
 | 
			
		||||
    <biostatCpx>1</biostatCpx>
 | 
			
		||||
    <biostatMet>-1</biostatMet>
 | 
			
		||||
  </GeneDef>
 | 
			
		||||
 | 
			
		||||
</Defs>
 | 
			
		||||
| 
						 | 
				
			
			@ -109,4 +109,21 @@
 | 
			
		|||
        </modExtensions>
 | 
			
		||||
    </GeneDef>
 | 
			
		||||
 | 
			
		||||
    <GeneDef ParentName="SpecialBase">
 | 
			
		||||
		<defName>rjw_genes_cocoonweaver</defName>
 | 
			
		||||
		<label>Cocoon Weaver</label>
 | 
			
		||||
		<labelShortAdj>cocooner</labelShortAdj>
 | 
			
		||||
		<description>Carriers of this gene can produce a cocoon to prepare helpless (or willing) victims for breeding.</description>
 | 
			
		||||
		<iconPath>Genes/Icons/Cocoon</iconPath>
 | 
			
		||||
		<displayOrderInCategory>11</displayOrderInCategory>
 | 
			
		||||
		<abilities>
 | 
			
		||||
			<li>rjw_genes_ability_cocoonweaver</li>
 | 
			
		||||
		</abilities>
 | 
			
		||||
		<descriptionHyperlinks>
 | 
			
		||||
			<AbilityDef>rjw_genes_ability_cocoonweaver</AbilityDef>
 | 
			
		||||
		</descriptionHyperlinks>
 | 
			
		||||
		<biostatCpx>1</biostatCpx>
 | 
			
		||||
		<biostatMet>-1</biostatMet>
 | 
			
		||||
	</GeneDef>
 | 
			
		||||
 | 
			
		||||
</Defs>
 | 
			
		||||
							
								
								
									
										42
									
								
								Source/Genes/Breeding/Gene_FerventOvipositor.cs
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										42
									
								
								Source/Genes/Breeding/Gene_FerventOvipositor.cs
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,42 @@
 | 
			
		|||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
 | 
			
		||||
using Verse;
 | 
			
		||||
using rjw;
 | 
			
		||||
 | 
			
		||||
namespace RJW_Genes
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// Manages the rjw_genes_fervent_ovipositor to grow eggs much faster.
 | 
			
		||||
    /// 
 | 
			
		||||
    /// TODO: Move the Multiplier into XML 
 | 
			
		||||
    /// TODO: This gene only works after the first egg, the first egg for two new pawns spawns at the same time (strange). 
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public class Gene_FerventOvipositor : Gene
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
        const int MULTIPLIER = 3; // Tick 3 times as much, making a pawn with this Gene Produce Eggs 4 times as fast as the normal.
 | 
			
		||||
 | 
			
		||||
        public override void Tick()
 | 
			
		||||
        {
 | 
			
		||||
            base.Tick();
 | 
			
		||||
 | 
			
		||||
            if (pawn == null) return;
 | 
			
		||||
 | 
			
		||||
            Hediff_PartBaseNatural OvipositorF = (Hediff_PartBaseNatural)pawn.health.hediffSet.GetFirstHediffOfDef(rjw.Genital_Helper.ovipositorF);
 | 
			
		||||
 | 
			
		||||
            if (OvipositorF == null) return;
 | 
			
		||||
 | 
			
		||||
            OvipositorF.nextEggTick = Math.Max(OvipositorF.nextEggTick - MULTIPLIER, -1);
 | 
			
		||||
 | 
			
		||||
            // DevNote: I first had a for-loop calling OviPositorF.tick(), but I fear that would be a performance sink.
 | 
			
		||||
            // Also, it would double other aspects as well, such as bleeding out through your insect-PP or dropping out the eggs.
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										67
									
								
								Source/Genes/Breeding/Gene_InsectIncubator.cs
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										67
									
								
								Source/Genes/Breeding/Gene_InsectIncubator.cs
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,67 @@
 | 
			
		|||
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
 | 
			
		||||
    /// 
 | 
			
		||||
    /// To save performance, this gene fires (default) every 0.5h, which also means a slight delay until fertilization happens.
 | 
			
		||||
    /// </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);
 | 
			
		||||
                // This part works as intended and shows Non-Human Eggs too
 | 
			
		||||
                //if (RJW_Genes_Settings.rjw_genes_detailed_debug) ModLog.Message($"Gene_InsectIncubator: Found {eggs.Count} Hediff_InsectEgg in {pawn}");
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                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);
 | 
			
		||||
                        // DevNote Issue 38: Sometimes Eggs are not fertilized here, because the normal Fertilize Function is called which has an upper Limit on Gestation.
 | 
			
		||||
                        // I will not do anything about it here, maybe upstream, but I print here. 
 | 
			
		||||
                        if (RJW_Genes_Settings.rjw_genes_detailed_debug)
 | 
			
		||||
                        {
 | 
			
		||||
                            if (egg.fertilized)
 | 
			
		||||
                                ModLog.Message($"Gene_InsectIncubator: fertilized egg {egg} in {pawn}");
 | 
			
		||||
                            else if (egg.GestationProgress > 0.5)
 | 
			
		||||
                                ModLog.Message($"Gene_InsectIncubator: Failed to fertilize {egg} in {pawn} due to high gestation progress");
 | 
			
		||||
                            else
 | 
			
		||||
                                ModLog.Message($"Gene_InsectIncubator: failed to fertiliz egg {egg} in {pawn}");
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                    // DevNote: There is an issue with Eggs reaching too much gestation progress (>100%), which causes DownStream bugs. To avoid this, there are some extra checks in place.  
 | 
			
		||||
                    else if (egg.fertilized && egg.GestationProgress <= .93)
 | 
			
		||||
                    {
 | 
			
		||||
                        egg.lastTick += TICK_INTERVAL;
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,81 @@
 | 
			
		|||
using Verse;
 | 
			
		||||
using RimWorld;
 | 
			
		||||
using rjw;
 | 
			
		||||
 | 
			
		||||
namespace RJW_Genes
 | 
			
		||||
{
 | 
			
		||||
    /// <summary>
 | 
			
		||||
    /// The CocoonWeaver Ability applies the RJW-Cocoon to a pawn.
 | 
			
		||||
    /// Friendly Pawns can always be cocooned, neutral and hostile pawns must be downed. 
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public class CompAbilityEffect_CocoonWeaver : CompAbilityEffect
 | 
			
		||||
    {
 | 
			
		||||
        private new CompProperties_AbilityCocoonWeaver Props
 | 
			
		||||
        {
 | 
			
		||||
            get
 | 
			
		||||
            {
 | 
			
		||||
                return (CompProperties_AbilityCocoonWeaver)this.props;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        public override void Apply(LocalTargetInfo target, LocalTargetInfo dest)
 | 
			
		||||
        {
 | 
			
		||||
            base.Apply(target, dest);
 | 
			
		||||
 | 
			
		||||
            Pawn CocooningPawn = this.parent.pawn;
 | 
			
		||||
            Pawn PawnToCocoon = target.Pawn;
 | 
			
		||||
 | 
			
		||||
            // Error Case - Null Pawn
 | 
			
		||||
            if (PawnToCocoon == null)
 | 
			
		||||
            {
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            PawnToCocoon.health.AddHediff(HediffDef.Named("RJW_Cocoon"));
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// For validity, there are a few checks:
 | 
			
		||||
        /// 0. Target is not already cocooned 
 | 
			
		||||
        /// 1. Target is either Colonist / Prisoner 
 | 
			
		||||
        /// 2. If the Target is an enemy or neutral, it must be downed. 
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        public override bool Valid(LocalTargetInfo target, bool throwMessages = false)
 | 
			
		||||
        {
 | 
			
		||||
            Pawn cocoonTarget = target.Pawn;
 | 
			
		||||
            if (cocoonTarget != null)
 | 
			
		||||
            {
 | 
			
		||||
                bool CocoonTargetIsColonistOrPrisoner = cocoonTarget.Faction == this.parent.pawn.Faction || cocoonTarget.IsPrisonerOfColony;
 | 
			
		||||
                bool CocoonTargetIsHostile = cocoonTarget.HostileTo(this.parent.pawn);
 | 
			
		||||
                bool CocoonTargetIsDowned = cocoonTarget.Downed;
 | 
			
		||||
 | 
			
		||||
                if (cocoonTarget.health.hediffSet.hediffs.Any(t => t.def.defName == "RJW_Cocoon"))
 | 
			
		||||
                {
 | 
			
		||||
                    if (throwMessages)
 | 
			
		||||
                        Messages.Message(cocoonTarget.Name + " is already cocooned.", cocoonTarget, MessageTypeDefOf.RejectInput, false);
 | 
			
		||||
                    return false;
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                if (!CocoonTargetIsColonistOrPrisoner && !(CocoonTargetIsHostile && CocoonTargetIsDowned))
 | 
			
		||||
                {
 | 
			
		||||
                    if (throwMessages)
 | 
			
		||||
                    {
 | 
			
		||||
                        if (CocoonTargetIsHostile && !CocoonTargetIsDowned)
 | 
			
		||||
                        {
 | 
			
		||||
                            Messages.Message(cocoonTarget.Name + " is hostile, but not downed.", cocoonTarget, MessageTypeDefOf.RejectInput, false);
 | 
			
		||||
                        }
 | 
			
		||||
                        else if (!CocoonTargetIsColonistOrPrisoner)
 | 
			
		||||
                        {
 | 
			
		||||
                            Messages.Message(cocoonTarget.Name + " is not a part of the colony or hostile.", cocoonTarget, MessageTypeDefOf.RejectInput, false);
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                    return false;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            return base.Valid(target, throwMessages);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,18 @@
 | 
			
		|||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Linq;
 | 
			
		||||
using System.Text;
 | 
			
		||||
using System.Threading.Tasks;
 | 
			
		||||
using Verse;
 | 
			
		||||
using RimWorld;
 | 
			
		||||
 | 
			
		||||
namespace RJW_Genes
 | 
			
		||||
{
 | 
			
		||||
    public class CompProperties_AbilityCocoonWeaver : CompProperties_AbilityEffect
 | 
			
		||||
    {
 | 
			
		||||
        public CompProperties_AbilityCocoonWeaver()
 | 
			
		||||
        {
 | 
			
		||||
            this.compClass = typeof(CompAbilityEffect_CocoonWeaver);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -64,6 +64,8 @@
 | 
			
		|||
    <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\Damage\Gene_Elasticity.cs" />
 | 
			
		||||
    <Compile Include="Genes\Patches\PatchLitteredBirth.cs" />
 | 
			
		||||
    <Compile Include="Common\Patches\PatchGetParents.cs" />
 | 
			
		||||
| 
						 | 
				
			
			@ -154,6 +156,8 @@
 | 
			
		|||
    <Compile Include="Genes\Patches\LustFeeding.cs" />
 | 
			
		||||
    <Compile Include="Genes\Patches\MultiplePregnancies.cs" />
 | 
			
		||||
    <Compile Include="Genes\Patch_AddNotifyOnGeneration.cs" />
 | 
			
		||||
    <Compile Include="Genes\Special\Abilities\CompAbilityEffect_CocoonWeaver.cs" />
 | 
			
		||||
    <Compile Include="Genes\Special\Abilities\CompProperties_AbilityCocoonWeaver.cs" />
 | 
			
		||||
    <Compile Include="Genes\Special\Defs\AgeTransferExtension.cs" />
 | 
			
		||||
    <Compile Include="Genes\Special\Defs\HormonalSalivaExtension.cs" />
 | 
			
		||||
    <Compile Include="Genes\Special\Patches\Patch_AgeDrain.cs" />
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue