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
				
			
		| 
						 | 
				
			
			@ -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);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue