Implemented Animal-Reduce for CockEater, documentation improvement.

This commit is contained in:
Vegapnk 2023-01-22 10:46:56 +01:00
parent d6aeca7249
commit 94a51be2f7

View file

@ -1,16 +1,17 @@
using System; using Verse;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Verse;
using UnityEngine;
using RimWorld; using RimWorld;
using rjw; using rjw;
using rjw.Modules.Interactions.Helpers;
namespace RJW_Genes namespace RJW_Genes
{ {
/// <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>
public class CompAbilityEffect_CockEater : CompAbilityEffect public class CompAbilityEffect_CockEater : CompAbilityEffect
{ {
private new CompProperties_AbilityCockEater Props private new CompProperties_AbilityCockEater Props
@ -20,16 +21,20 @@ namespace RJW_Genes
return (CompProperties_AbilityCockEater)this.props; return (CompProperties_AbilityCockEater)this.props;
} }
} }
public const float MINIMUM_LIFEFORCE_GAIN = 0.25f;
public override void Apply(LocalTargetInfo target, LocalTargetInfo dest) public override void Apply(LocalTargetInfo target, LocalTargetInfo dest)
{ {
base.Apply(target, dest); base.Apply(target, dest);
Pawn pawn = target.Pawn; Pawn CockBiter = this.parent.pawn;
if (pawn == null) Pawn CockBittenPawn = target.Pawn;
if (CockBittenPawn == null)
{ {
return; return;
} }
var partBPR = Genital_Helper.get_genitalsBPR(pawn); var partBPR = Genital_Helper.get_genitalsBPR(CockBittenPawn);
var parts = Genital_Helper.get_PartsHediffList(pawn, partBPR); var parts = Genital_Helper.get_PartsHediffList(CockBittenPawn, partBPR);
if (!parts.NullOrEmpty()) if (!parts.NullOrEmpty())
{ {
foreach (Hediff part in parts) foreach (Hediff part in parts)
@ -39,50 +44,67 @@ namespace RJW_Genes
if (Genital_Helper.is_penis(part)) if (Genital_Helper.is_penis(part))
{ {
GeneUtility.OffsetLifeForce(GeneUtility.GetLifeForceGene(this.parent.pawn), part.Severity); ; float gained_lifeforce = MINIMUM_LIFEFORCE_GAIN * (1 + part.Severity);
pawn.health.RemoveHediff(part); if (CockBittenPawn.IsAnimal())
pawn.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOf.rjw_genes_cock_eaten, pawn, null); {
break; //Only one penis at the time 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
CockBittenPawn.health.RemoveHediff(part);
CockBittenPawn.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOf.rjw_genes_cock_eaten, CockBittenPawn, null);
//Only one penis at the time
break;
} }
} }
} }
} }
/// <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>
public override bool Valid(LocalTargetInfo target, bool throwMessages = false) public override bool Valid(LocalTargetInfo target, bool throwMessages = false)
{ {
Pawn pawn = target.Pawn; Pawn CockBiteTarget = target.Pawn;
if (pawn != null) if (CockBiteTarget != null)
{ {
bool flag = pawn.Faction == this.parent.pawn.Faction || pawn.IsPrisonerOfColony; bool CockBiteTargetIsColonistOrPrisoner = CockBiteTarget.Faction == this.parent.pawn.Faction || CockBiteTarget.IsPrisonerOfColony;
bool flag2 = pawn.HostileTo(this.parent.pawn); bool CockBiteTargetIsHostile = CockBiteTarget.HostileTo(this.parent.pawn);
bool flag3 = pawn.Downed; bool CockBiteTargetIsDowned = CockBiteTarget.Downed;
if (!flag && !(flag2 && flag3))
if (!CockBiteTargetIsColonistOrPrisoner && !(CockBiteTargetIsHostile && CockBiteTargetIsDowned))
{ {
if (throwMessages) if (throwMessages)
{ {
if(flag2 && !flag3) if(CockBiteTargetIsHostile && !CockBiteTargetIsDowned)
{ {
Messages.Message(pawn.Name + " is hostile, but not downed.", pawn, MessageTypeDefOf.RejectInput, false); Messages.Message(CockBiteTarget.Name + " is hostile, but not downed.", CockBiteTarget, MessageTypeDefOf.RejectInput, false);
} }
else if (!flag) else if (!CockBiteTargetIsColonistOrPrisoner)
{ {
Messages.Message(pawn.Name + " is not a part of the colony or hostile.", pawn, MessageTypeDefOf.RejectInput, false); Messages.Message(CockBiteTarget.Name + " is not a part of the colony or hostile.", CockBiteTarget, MessageTypeDefOf.RejectInput, false);
} }
} }
return false; return false;
} }
if (!Genital_Helper.has_penis_fertile(pawn)) if (!Genital_Helper.has_penis_fertile(CockBiteTarget))
{ {
if (throwMessages) if (throwMessages)
{ {
Messages.Message(pawn.Name + " has no penis", pawn, MessageTypeDefOf.RejectInput, false); Messages.Message(CockBiteTarget.Name + " has no penis", CockBiteTarget, MessageTypeDefOf.RejectInput, false);
} }
return false; return false;
} }
} }
return base.Valid(target, throwMessages); return base.Valid(target, throwMessages);
} }
public override bool GizmoDisabled(out string reason) public override bool GizmoDisabled(out string reason)
{ {
Pawn_GeneTracker genes = this.parent.pawn.genes; Pawn_GeneTracker genes = this.parent.pawn.genes;