Added Faction Penalties for Age Draining, Youth Fountain and Genetic Diseases

This commit is contained in:
Vegapnk 2024-07-05 15:04:45 +02:00
parent b12e9afbc0
commit f5917052ab
7 changed files with 114 additions and 0 deletions

View file

@ -1,4 +1,5 @@
using HarmonyLib;
using RimWorld;
using rjw;
using System;
using System.Collections.Generic;
@ -13,6 +14,8 @@ namespace RJW_Genes
public class Patch_AftersexUtility_TransferGeneticDiseases
{
public const int FACTION_GOODWILL_CHANGE = -2;
public static void Postfix(SexProps props)
{
if (!RJW_Genes_Settings.rjw_genes_genetic_disease_spread) return;
@ -48,9 +51,22 @@ namespace RJW_Genes
if ((new Random()).NextDouble() <= DiseaseHelper.LookupDiseaseInfectionChance(disease))
{
infected.genes.AddGene(disease, !RJW_Genes_Settings.rjw_genes_genetic_disease_as_endogenes);
HandleFactionGoodWillPenalties(infector, infected);
}
}
}
private static void HandleFactionGoodWillPenalties(Pawn actor, Pawn target)
{
if (
target.Faction != null && actor.Faction != null
&& target.Faction != actor.Faction
&& target.Faction != Faction.OfPlayer)
{
HistoryEventDef reason = DefDatabase<HistoryEventDef>.GetNamedSilentFail("rjw_genes_GoodwillChangedReason_spread_genetic_disease");
target.Faction.TryAffectGoodwillWith(actor.Faction, FACTION_GOODWILL_CHANGE, true, true, reason, target);
}
}
}
}