diff --git a/Assemblies/MoreFactionInteraction.dll b/Assemblies/MoreFactionInteraction.dll index d321758..08026c3 100644 Binary files a/Assemblies/MoreFactionInteraction.dll and b/Assemblies/MoreFactionInteraction.dll differ diff --git a/MoreFactionInteraction/General/HarmonyPatches.cs b/MoreFactionInteraction/General/HarmonyPatches.cs index fc09ab4..d9aa179 100644 --- a/MoreFactionInteraction/General/HarmonyPatches.cs +++ b/MoreFactionInteraction/General/HarmonyPatches.cs @@ -90,7 +90,6 @@ private static void TraderStocker_OverStockerPostFix(ref List __result, r else if (Find.CurrentMap != null) map = Find.CurrentMap; - if (map != null && (parms.traderDef.orbital || parms.traderDef.defName.Contains(value: "Base_"))) { float silverCount = __result.First(predicate: x => x.def == ThingDefOf.Silver).stackCount; diff --git a/MoreFactionInteraction/More Flavour/ChoiceLetter_DiplomaticMarriage.cs b/MoreFactionInteraction/More Flavour/ChoiceLetter_DiplomaticMarriage.cs index b3079d3..cc33c65 100644 --- a/MoreFactionInteraction/More Flavour/ChoiceLetter_DiplomaticMarriage.cs +++ b/MoreFactionInteraction/More Flavour/ChoiceLetter_DiplomaticMarriage.cs @@ -46,8 +46,8 @@ public override IEnumerable Choices HealIfPossible(p: this.betrothed); caravan.RemovePawn(p: this.betrothed); } - DetermineAndDoOutcome(marriageSeeker: this.marriageSeeker, betrothed: this.betrothed); + Find.LetterStack.RemoveLetter(this); } }; DiaNode dialogueNodeAccept = new DiaNode(text: "MFI_AcceptedProposal".Translate(this.betrothed, this.marriageSeeker.Faction).CapitalizeFirst().AdjustedFor(this.marriageSeeker)); @@ -60,6 +60,7 @@ public override IEnumerable Choices { //if (Rand.Chance(0.2f)) this.marriageSeeker.Faction.TryAffectGoodwillWith(other: Faction.OfPlayer, goodwillChange: DiplomacyTuning.Goodwill_PeaceTalksBackfireRange.RandomInRange, canSendMessage: true, canSendHostilityLetter: true, reason: "LetterLabelRejectedProposal".Translate()); + Find.LetterStack.RemoveLetter(this); } }; DiaNode dialogueNodeReject = new DiaNode(text: "MFI_DejectedProposal".Translate(this.marriageSeeker.Name, this.marriageSeeker.Faction).CapitalizeFirst().AdjustedFor(this.marriageSeeker)); diff --git a/MoreFactionInteraction/MoreFactionWar/CaravanArrivalAction_VisitFactionWarPeaceTalks.cs b/MoreFactionInteraction/MoreFactionWar/CaravanArrivalAction_VisitFactionWarPeaceTalks.cs index bf90389..78868fd 100644 --- a/MoreFactionInteraction/MoreFactionWar/CaravanArrivalAction_VisitFactionWarPeaceTalks.cs +++ b/MoreFactionInteraction/MoreFactionWar/CaravanArrivalAction_VisitFactionWarPeaceTalks.cs @@ -9,9 +9,9 @@ public class CaravanArrivalAction_VisitFactionWarPeaceTalks : CaravanArrivalActi { private FactionWarPeaceTalks factionWarPeaceTalks; - public override string Label => "VisitPeaceTalks".Translate(args: new object[] {this.factionWarPeaceTalks.Label}); + public override string Label => "VisitPeaceTalks".Translate( factionWarPeaceTalks.Label ); - public override string ReportString => "CaravanVisiting".Translate(args: new object[] { this.factionWarPeaceTalks.Label }); + public override string ReportString => "CaravanVisiting".Translate( this.factionWarPeaceTalks.Label ); public override void Arrived(Caravan caravan) { @@ -51,10 +51,12 @@ public static FloatMenuAcceptanceReport CanVisit(Caravan caravan, FactionWarPeac public static IEnumerable GetFloatMenuOptions(Caravan caravan, FactionWarPeaceTalks factionWarPeaceTalks) { - return CaravanArrivalActionUtility.GetFloatMenuOptions(acceptanceReportGetter: () => CanVisit(caravan: caravan, factionWarPeaceTalks: factionWarPeaceTalks), arrivalActionGetter: () => new CaravanArrivalAction_VisitFactionWarPeaceTalks(factionWarPeaceTalks: factionWarPeaceTalks), label: "VisitPeaceTalks".Translate(args: new object[] - { - factionWarPeaceTalks.Label - }), caravan: caravan, pathDestination: factionWarPeaceTalks.Tile, revalidateWorldClickTarget: factionWarPeaceTalks); + return CaravanArrivalActionUtility.GetFloatMenuOptions(acceptanceReportGetter: + () => CanVisit(caravan: caravan, factionWarPeaceTalks: factionWarPeaceTalks), arrivalActionGetter: + () => new CaravanArrivalAction_VisitFactionWarPeaceTalks(factionWarPeaceTalks: factionWarPeaceTalks), + label: "VisitPeaceTalks".Translate(factionWarPeaceTalks.Label), + caravan: caravan, pathDestination: factionWarPeaceTalks.Tile, + revalidateWorldClickTarget: factionWarPeaceTalks); } } } diff --git a/MoreFactionInteraction/MoreFactionWar/FactionWarDialogue.cs b/MoreFactionInteraction/MoreFactionWar/FactionWarDialogue.cs index 65436ee..9e2a9c3 100644 --- a/MoreFactionInteraction/MoreFactionWar/FactionWarDialogue.cs +++ b/MoreFactionInteraction/MoreFactionWar/FactionWarDialogue.cs @@ -39,7 +39,7 @@ public static DiaNode FactionWarPeaceTalks(Pawn pawn, Faction factionOne, Factio { dialogueGreeting.options.Add(item: new DiaOption(text: "(Dev: start war)") { action =() => - { Find.World.GetComponent().StartWar(factionOne: factionOne, factionInstigator: factionInstigator, selfResolved: true);}, + { Find.World.GetComponent().StartWar(factionOne: factionOne, factionInstigator: factionInstigator, selfResolved: false);}, linkLateBind = () => DialogueResolver(textResult: "Alrighty. War started. Sorry about the lack of fancy flavour text for this dev mode only option.")}); } @@ -50,7 +50,7 @@ private static IEnumerable DialogueOptions(Pawn pawn, Faction faction { string factionWarNegotiationsOutcome = "Something went wrong with More Faction Interaction. Please contact mod author."; - yield return new DiaOption(text: "MFI_FactionWarPeaceTalksCurryFavour".Translate(args: new object[] { factionOne.Name })) + yield return new DiaOption(text: "MFI_FactionWarPeaceTalksCurryFavour".Translate( factionOne.Name )) { action = () => { @@ -58,7 +58,7 @@ private static IEnumerable DialogueOptions(Pawn pawn, Faction faction }, linkLateBind = () => DialogueResolver(textResult: factionWarNegotiationsOutcome), }; - yield return new DiaOption(text: "MFI_FactionWarPeaceTalksCurryFavour".Translate(args: new object[] { factionInstigator.Name })) + yield return new DiaOption(text: "MFI_FactionWarPeaceTalksCurryFavour".Translate( factionInstigator.Name )) { action = () => { @@ -365,6 +365,7 @@ private static void Outcome_TalksSabotageDisaster(Faction favouredFaction, Facti } Find.TickManager.CurTimeSpeed = TimeSpeed.Paused; + Find.TickManager.slower.SignalForceNormalSpeedShort(); }, textKey: "GeneratingMapForNewEncounter", doAsynchronously: false, exceptionHandler: null); } diff --git a/MoreFactionInteraction/MoreFactionWar/FactionWarPeaceTalks.cs b/MoreFactionInteraction/MoreFactionWar/FactionWarPeaceTalks.cs index 26b7b60..4b503e4 100644 --- a/MoreFactionInteraction/MoreFactionWar/FactionWarPeaceTalks.cs +++ b/MoreFactionInteraction/MoreFactionWar/FactionWarPeaceTalks.cs @@ -82,7 +82,6 @@ public override IEnumerable GetFloatMenuOptions(Caravan caravan public override void PostRemove() { base.PostRemove(); - //TODO: make so that this doesn't trigger upon MY removal of 'this' if (!this.canRemoveWithoutPostRemove) Find.World.GetComponent().DetermineWarAsIfNoPlayerInteraction(this.factionOne, this.factionInstigator); } diff --git a/MoreFactionInteraction/Spreading Pirates/IncidentWorker_Extortion.cs b/MoreFactionInteraction/Spreading Pirates/IncidentWorker_Extortion.cs index 32eb0b4..b725474 100644 --- a/MoreFactionInteraction/Spreading Pirates/IncidentWorker_Extortion.cs +++ b/MoreFactionInteraction/Spreading Pirates/IncidentWorker_Extortion.cs @@ -64,22 +64,22 @@ protected override bool TryExecuteWorker(IncidentParms parms) //update: seems they now do? thx Tynan. int extorsionDemand = Math.Max(val1: Rand.Range(min: 150, max: 300), val2: (int)parms.points) * NearbyHostileEncampments(forTile: map.Tile).Count(); - ChoiceLetter_ExtortionDemand choiceLetter_ExtortionDemand = (ChoiceLetter_ExtortionDemand)LetterMaker.MakeLetter(label: this.def.letterLabel, text: "MFI_ExtortionDemand".Translate(args: new object[] + ChoiceLetter_ExtortionDemand choiceLetterExtortionDemand = (ChoiceLetter_ExtortionDemand)LetterMaker.MakeLetter(label: this.def.letterLabel, text: "MFI_ExtortionDemand".Translate(args: new object[] { this.faction.leader.LabelShort, this.faction.def.leaderTitle, this.faction.Name, this.worldObject.def.label, this.worldObject.Label, extorsionDemand, }).AdjustedFor(p: this.faction.leader), def: this.def.letterDef); - choiceLetter_ExtortionDemand.title = "MFI_ExtortionDemandTitle".Translate(args: new object[] + choiceLetterExtortionDemand.title = "MFI_ExtortionDemandTitle".Translate(args: new object[] { map.info.parent.Label }).CapitalizeFirst(); - if (this.worldObject is Site) choiceLetter_ExtortionDemand.outpost = true; - choiceLetter_ExtortionDemand.radioMode = true; - choiceLetter_ExtortionDemand.faction = this.faction; - choiceLetter_ExtortionDemand.map = map; - choiceLetter_ExtortionDemand.fee = extorsionDemand; - choiceLetter_ExtortionDemand.StartTimeout(duration: TimeoutTicks); - Find.LetterStack.ReceiveLetter(@let: choiceLetter_ExtortionDemand); + if (this.worldObject is Site) choiceLetterExtortionDemand.outpost = true; + choiceLetterExtortionDemand.radioMode = true; + choiceLetterExtortionDemand.faction = this.faction; + choiceLetterExtortionDemand.map = map; + choiceLetterExtortionDemand.fee = extorsionDemand; + choiceLetterExtortionDemand.StartTimeout(duration: TimeoutTicks); + Find.LetterStack.ReceiveLetter(@let: choiceLetterExtortionDemand); return true; } return false; diff --git a/MoreFactionInteraction/Spreading Pirates/WorldComponent_OutpostGrower.cs b/MoreFactionInteraction/Spreading Pirates/WorldComponent_OutpostGrower.cs index 30617ce..f676db6 100644 --- a/MoreFactionInteraction/Spreading Pirates/WorldComponent_OutpostGrower.cs +++ b/MoreFactionInteraction/Spreading Pirates/WorldComponent_OutpostGrower.cs @@ -45,7 +45,7 @@ where site.Faction.HostileTo(other: Faction.OfPlayer) && site.Faction.def.perman Find.LetterStack.ReceiveLetter(label: "MFI_LetterLabelBanditOutpostUpgraded".Translate(), text: "MFI_LetterBanditOutpostUpgraded".Translate(args: new object[] { factionBase.Faction.Name, - }), textLetterDef: LetterDefOf.NeutralEvent, lookTargets: factionBase); + }), textLetterDef: LetterDefOf.NeutralEvent, lookTargets: factionBase, relatedFaction: toUpgrade.Faction); } } } diff --git a/MoreFactionInteraction/World Incidents/IncidentWorker_BumperCrop.cs b/MoreFactionInteraction/World Incidents/IncidentWorker_BumperCrop.cs index bd703bd..e2701ab 100644 --- a/MoreFactionInteraction/World Incidents/IncidentWorker_BumperCrop.cs +++ b/MoreFactionInteraction/World Incidents/IncidentWorker_BumperCrop.cs @@ -47,7 +47,7 @@ protected override bool TryExecuteWorker(IncidentParms parms) { settlement.Label, (component.expiration - Find.TickManager.TicksGame).ToStringTicksToDays(format: "F0") - }), textLetterDef: LetterDefOf.PositiveEvent, lookTargets: settlement); + }), textLetterDef: LetterDefOf.PositiveEvent, lookTargets: settlement, relatedFaction: settlement.Faction); return true; } diff --git a/MoreFactionInteraction/World Incidents/WorldObjectComp_CaravanComp.cs b/MoreFactionInteraction/World Incidents/WorldObjectComp_CaravanComp.cs index 36da263..6533c28 100644 --- a/MoreFactionInteraction/World Incidents/WorldObjectComp_CaravanComp.cs +++ b/MoreFactionInteraction/World Incidents/WorldObjectComp_CaravanComp.cs @@ -25,5 +25,12 @@ public override void CompTick() CaravanVisitUtility.SettlementVisitedNow(caravan: (Caravan) this.parent)?.GetComponent().DoOutcome(caravan: (Caravan) this.parent); } } + + public override void PostExposeData() + { + base.PostExposeData(); + Scribe_Values.Look(ref this.workWillBeDoneAtTick, "MFI_BumperCropWorkingCaravanWorkWillBeDoneAt"); + Scribe_Values.Look(ref this.caravanIsWorking, "MFI_BumperCropCaravanIsWorking"); + } } } diff --git a/MoreFactionInteraction/World Incidents/WorldObjectComp_SettlementBumperCropComp.cs b/MoreFactionInteraction/World Incidents/WorldObjectComp_SettlementBumperCropComp.cs index c828eac..ac091a5 100644 --- a/MoreFactionInteraction/World Incidents/WorldObjectComp_SettlementBumperCropComp.cs +++ b/MoreFactionInteraction/World Incidents/WorldObjectComp_SettlementBumperCropComp.cs @@ -71,18 +71,19 @@ private void Outcome_Triumph(Caravan caravan) float totalYieldPowerForCaravan = CalculateYieldForCaravan(caravanMembersCapableOfGrowing: allMembersCapableOfGrowing); //TODO: Calculate a good amount - float totalreward = basereward * totalYieldPowerForCaravan * allMembersCapableOfGrowing.Count * Mathf.Max(a: 1, b: (float)allMembersCapableOfGrowing.Average(selector: pawn => pawn.skills.GetSkill(skillDef: SkillDefOf.Plants).Level)); + float totalreward = basereward * totalYieldPowerForCaravan * allMembersCapableOfGrowing.Count + * Mathf.Max(a: 1, b: (float)allMembersCapableOfGrowing.Average(selector: pawn => pawn.skills.GetSkill(skillDef: SkillDefOf.Plants).Level)); Thing reward = ThingMaker.MakeThing(def: this.bumperCrop); reward.stackCount = Mathf.RoundToInt(f: totalreward); CaravanInventoryUtility.GiveThing(caravan: caravan, thing: reward); - Find.LetterStack.ReceiveLetter(label: "MFI_LetterLabelHarvest_Triumph".Translate(), text: GetLetterText(baseText: "MFI_Harvest_Triumph".Translate(args: new object[] - { + Find.LetterStack.ReceiveLetter(label: "MFI_LetterLabelHarvest_Triumph".Translate(), text: GetLetterText(baseText: "MFI_Harvest_Triumph".Translate( + this.parent.Faction.def.pawnsPlural, this.parent.Faction.Name, Mathf.RoundToInt(f: randomInRange), reward.LabelCap - }), caravan: caravan), textLetterDef: LetterDefOf.PositiveEvent, lookTargets: caravan); + ), caravan: caravan), textLetterDef: LetterDefOf.PositiveEvent, lookTargets: caravan, relatedFaction: this.parent.Faction); allMembersCapableOfGrowing.ForEach(action: pawn => pawn.skills.Learn(sDef: SkillDefOf.Plants, xp: expGain, direct: true)); } @@ -109,8 +110,17 @@ private static string GetLetterText(string baseText, Caravan caravan) private static List AllCaravanMembersCapableOfGrowing(Caravan caravan) { - return caravan.PawnsListForReading.Where(predicate: pawn => !pawn.Dead && !pawn.Downed && !pawn.InMentalState && caravan.IsOwner(p: pawn) && pawn.health.capacities.CanBeAwake - && !StatDefOf.PlantHarvestYield.Worker.IsDisabledFor(thing: pawn)).ToList(); + return caravan.PawnsListForReading.Where(predicate: pawn => !pawn.Dead && !pawn.Downed && !pawn.InMentalState + && caravan.IsOwner(p: pawn) && pawn.health.capacities.CanBeAwake + && !StatDefOf.PlantHarvestYield.Worker.IsDisabledFor(thing: pawn)).ToList(); + } + + public override void PostExposeData() + { + base.PostExposeData(); + Scribe_Values.Look(ref this.expiration, "MFI_BumperCropExpiration"); + Scribe_Values.Look(ref this.workLeft, "MFI_BumperCropWorkLeft"); + Scribe_Values.Look(ref this.workStarted, "MFI_BumperCropWorkStarted"); } } } \ No newline at end of file