44using System ;
55using System . Collections . Generic ;
66using System . Linq ;
7- using System . Reflection ;
7+
88using Verse ;
9- using VFE_Settlers . Workers ;
109
1110namespace CallForIntel
1211{
@@ -16,14 +15,15 @@ static class MyPatcher
1615 {
1716 static MyPatcher ( )
1817 {
19- Harmony harmony = new Harmony ( "rimworld.8z .callforintel" ) ;
18+ Harmony harmony = new Harmony ( "com.theonly8z .callforintel" ) ;
2019 harmony . PatchAll ( ) ;
2120 }
2221
2322 }
2423
2524 // A class that holds an action (function that generates intel) and a relative weight
2625 // Used to generate a intel for a specfic choice when multiple are possible
26+
2727 public class WeightedIntel
2828 {
2929 public int weight ;
@@ -57,26 +57,40 @@ public static void Choose(List<WeightedIntel> intel, Faction faction)
5757 // Best to pop a notification or something
5858 faction . lastTraderRequestTick = Find . TickManager . TicksGame ;
5959 Find . LetterStack . ReceiveLetter ( "IntelFailedLabel" , "IntelFailedDialouge" . Translate ( faction . leader ) . CapitalizeFirst ( ) , LetterDefOf . NeutralEvent ) ;
60-
6160 }
6261 }
6362
63+ #if V12
6464 [ HarmonyPatch ( typeof ( FactionDialogMaker ) ) ]
6565 [ HarmonyPatch ( "FactionDialogFor" ) ]
66+ #elif V13
67+ [ HarmonyPatch ( typeof ( FactionDialogMaker ) , nameof ( FactionDialogMaker . FactionDialogFor ) ) ]
68+ #endif
6669 public static class FactionDialogMakerPatch
6770 {
6871
6972 static string [ ] VikingHunts = { "VFEV_FenrirHunt" , "VFEV_LothurrHunt" , "VFEV_NjorunHunt" , "VFEV_OdinHunt" , "VFEV_ThrumboHunt" } ;
7073
74+ static void ChargeGoodwill ( Faction faction , int amount )
75+ {
76+ faction . lastTraderRequestTick = Find . TickManager . TicksGame ;
77+
78+ // Function changed in 1.3 to use a HistoryEventDef instead of a translation string for "reason".
79+ #if V12
80+ faction . TryAffectGoodwillWith ( Faction . OfPlayer , - amount , canSendMessage : false , canSendHostilityLetter : true , "GoodwillChangedReason_RequestedIntel" . Translate ( ) ) ;
81+ #elif V13
82+ faction . TryAffectGoodwillWith ( Faction . OfPlayer , - amount , canSendMessage : false , canSendHostilityLetter : true , ( HistoryEventDef ) GenDefDatabase . GetDef ( typeof ( HistoryEventDef ) , "RequestedIntel" ) ) ;
83+ #endif
84+ }
85+
7186 static void GenerateIntelQuest ( Faction faction , string name , int goodwill )
7287 {
7388 Slate slate = new Slate ( ) ;
7489 slate . Set ( "points" , StorytellerUtility . DefaultThreatPointsNow ( Find . World ) ) ;
7590 slate . Set ( "asker" , faction . leader ) ;
7691 Quest newQuest = QuestUtility . GenerateQuestAndMakeAvailable ( DefDatabase < QuestScriptDef > . GetNamed ( name ) , slate ) ;
7792 QuestUtility . SendLetterQuestAvailable ( newQuest ) ;
78- faction . lastTraderRequestTick = Find . TickManager . TicksGame ;
79- faction . TryAffectGoodwillWith ( Faction . OfPlayer , - goodwill , canSendMessage : false , canSendHostilityLetter : true , "GoodwillChangedReason_RequestedIntel" . Translate ( ) ) ;
93+ ChargeGoodwill ( faction , - goodwill ) ;
8094 }
8195
8296 static void GenerateIntelIncident ( Faction faction , string name , IncidentParms parms , int goodwill )
@@ -85,8 +99,7 @@ static void GenerateIntelIncident(Faction faction, string name, IncidentParms pa
8599 bool execute = incident . Worker . TryExecute ( parms ) ;
86100 if ( execute )
87101 {
88- faction . lastTraderRequestTick = Find . TickManager . TicksGame ;
89- faction . TryAffectGoodwillWith ( Faction . OfPlayer , - goodwill , canSendMessage : false , canSendHostilityLetter : true , "GoodwillChangedReason_RequestedIntel" . Translate ( ) ) ;
102+ ChargeGoodwill ( faction , - goodwill ) ;
90103 } else
91104 {
92105 // It is possible to fail a incident execution, in which case we do not charge goodwill
0 commit comments