Centralized Faction Goodwill Penalties in a single Helper

This commit is contained in:
Vegapnk 2024-07-05 15:20:09 +02:00
parent f5917052ab
commit 4623333605
7 changed files with 49 additions and 59 deletions

View file

@ -54,23 +54,11 @@ namespace RJW_Genes
if ((new Random()).NextDouble() < application_chance)
{
partner.genes.AddGene(diseaseGeneDef, !RJW_Genes_Settings.rjw_genes_genetic_disease_as_endogenes);
HandleFactionGoodWillPenalties(infector, partner);
FactionUtility.HandleFactionGoodWillPenalties(infector, partner, "rjw_genes_GoodwillChangedReason_infected_with_disease",FACTION_GOODWILL_CHANGE);
}
}
}
}
private static void HandleFactionGoodWillPenalties(Pawn infector, Pawn partner)
{
if (
partner.Faction != null && infector.Faction != null
&& partner.Faction != infector.Faction
&& partner.Faction != Faction.OfPlayer)
{
HistoryEventDef reason = DefDatabase<HistoryEventDef>.GetNamedSilentFail("rjw_genes_GoodwillChangedReason_infected_with_disease");
partner.Faction.TryAffectGoodwillWith(infector.Faction, FACTION_GOODWILL_CHANGE, true, true, reason, partner);
}
}
}
}

View file

@ -51,22 +51,10 @@ 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);
FactionUtility.HandleFactionGoodWillPenalties(infector, infected, "rjw_genes_GoodwillChangedReason_spread_genetic_disease", FACTION_GOODWILL_CHANGE);
}
}
}
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);
}
}
}
}