2023-01-22 09:46:56 +00:00
using Verse ;
2022-12-29 17:03:02 +00:00
using RimWorld ;
using rjw ;
namespace RJW_Genes
{
2023-01-22 09:46:56 +00:00
/// <summary>
/// The CockEater Ability bites off the first found non-artifical cock of an target pawn.
/// It will restore {MINIMUM_LIFEFORCE_GAIN} multiplied by up to 2-times the Cock-Size.
/// Consuming a "towering" cock will give 2*{MINIMUM_LIFEFORCE_GAIN}, resulting in default 0.5f LifeForce.
/// This number is reduced for consuming animals by Settings.
///
/// Balancing note: With the Cock-Eaters a drain of 0.08 is normal per day. This means 1 average cock should hold for 3-4 days of fertilin-fuel and half a day for an animal.
/// </summary>
2022-12-29 17:03:02 +00:00
public class CompAbilityEffect_CockEater : CompAbilityEffect
{
private new CompProperties_AbilityCockEater Props
{
get
{
return ( CompProperties_AbilityCockEater ) this . props ;
}
}
2023-01-22 09:46:56 +00:00
public const float MINIMUM_LIFEFORCE_GAIN = 0.25f ;
2022-12-29 17:03:02 +00:00
public override void Apply ( LocalTargetInfo target , LocalTargetInfo dest )
{
base . Apply ( target , dest ) ;
2023-01-22 09:46:56 +00:00
Pawn CockBiter = this . parent . pawn ;
Pawn CockBittenPawn = target . Pawn ;
if ( CockBittenPawn = = null )
2022-12-29 17:03:02 +00:00
{
return ;
}
2023-01-22 09:46:56 +00:00
var partBPR = Genital_Helper . get_genitalsBPR ( CockBittenPawn ) ;
var parts = Genital_Helper . get_PartsHediffList ( CockBittenPawn , partBPR ) ;
2022-12-29 17:03:02 +00:00
if ( ! parts . NullOrEmpty ( ) )
{
foreach ( Hediff part in parts )
{
if ( GenitaliaChanger . IsArtificial ( part ) )
continue ;
2023-01-09 13:14:51 +00:00
if ( Genital_Helper . is_penis ( part ) )
2022-12-29 17:03:02 +00:00
{
2023-01-22 09:46:56 +00:00
float gained_lifeforce = MINIMUM_LIFEFORCE_GAIN * ( 1 + part . Severity ) ;
if ( CockBittenPawn . IsAnimal ( ) )
{
gained_lifeforce * = RJW_Genes_Settings . rjw_genes_fertilin_from_animals_factor ;
}
// Increase LifeForce for Biter
GeneUtility . OffsetLifeForce ( GeneUtility . GetLifeForceGene ( CockBiter ) , gained_lifeforce ) ;
// Handle Damage for Bitten
2023-04-10 10:33:05 +00:00
CockBittenPawn . TakeDamage ( new DamageInfo ( DamageDefOf . Bite , 99999f , 999f , hitPart : Genital_Helper . get_genitalsBPR ( CockBittenPawn ) ) ) ;
//CockBittenPawn.health.RemoveHediff(part);
2023-01-22 09:46:56 +00:00
CockBittenPawn . needs . mood . thoughts . memories . TryGainMemory ( ThoughtDefOf . rjw_genes_cock_eaten , CockBittenPawn , null ) ;
//Only one penis at the time
break ;
2022-12-29 17:03:02 +00:00
}
}
}
}
2023-01-22 09:46:56 +00:00
/// <summary>
/// For validity, there are a few checks:
/// 1. Target has Penis
/// 2. Target is either Colonist / Prisoner
/// 3. If the Target is an enemy, it must be downed.
/// </summary>
2022-12-29 17:03:02 +00:00
public override bool Valid ( LocalTargetInfo target , bool throwMessages = false )
{
2023-01-22 09:46:56 +00:00
Pawn CockBiteTarget = target . Pawn ;
if ( CockBiteTarget ! = null )
2022-12-29 17:03:02 +00:00
{
2023-01-22 09:46:56 +00:00
bool CockBiteTargetIsColonistOrPrisoner = CockBiteTarget . Faction = = this . parent . pawn . Faction | | CockBiteTarget . IsPrisonerOfColony ;
bool CockBiteTargetIsHostile = CockBiteTarget . HostileTo ( this . parent . pawn ) ;
bool CockBiteTargetIsDowned = CockBiteTarget . Downed ;
if ( ! CockBiteTargetIsColonistOrPrisoner & & ! ( CockBiteTargetIsHostile & & CockBiteTargetIsDowned ) )
2022-12-29 17:03:02 +00:00
{
if ( throwMessages )
{
2023-01-22 09:46:56 +00:00
if ( CockBiteTargetIsHostile & & ! CockBiteTargetIsDowned )
2022-12-29 17:03:02 +00:00
{
2023-01-22 09:46:56 +00:00
Messages . Message ( CockBiteTarget . Name + " is hostile, but not downed." , CockBiteTarget , MessageTypeDefOf . RejectInput , false ) ;
2022-12-29 17:03:02 +00:00
}
2023-01-22 09:46:56 +00:00
else if ( ! CockBiteTargetIsColonistOrPrisoner )
2022-12-29 17:03:02 +00:00
{
2023-01-22 09:46:56 +00:00
Messages . Message ( CockBiteTarget . Name + " is not a part of the colony or hostile." , CockBiteTarget , MessageTypeDefOf . RejectInput , false ) ;
2022-12-29 17:03:02 +00:00
}
}
return false ;
}
2023-01-22 09:46:56 +00:00
if ( ! Genital_Helper . has_penis_fertile ( CockBiteTarget ) )
2022-12-29 17:03:02 +00:00
{
if ( throwMessages )
{
2023-01-22 09:46:56 +00:00
Messages . Message ( CockBiteTarget . Name + " has no penis" , CockBiteTarget , MessageTypeDefOf . RejectInput , false ) ;
2022-12-29 17:03:02 +00:00
}
return false ;
}
}
return base . Valid ( target , throwMessages ) ;
}
2023-01-22 09:46:56 +00:00
2023-01-09 13:14:51 +00:00
public override bool GizmoDisabled ( out string reason )
{
Pawn_GeneTracker genes = this . parent . pawn . genes ;
Gene_LifeForce gene_LifeForce = ( genes ! = null ) ? genes . GetFirstGeneOfType < Gene_LifeForce > ( ) : null ;
if ( gene_LifeForce = = null )
{
reason = "AbilityDisabledNoFertilinGene" . Translate ( this . parent . pawn ) ;
return true ;
}
reason = null ;
return false ;
}
2022-12-29 17:03:02 +00:00
}
}