Skip to content

Commit

Permalink
last minute tinkering before release
Browse files Browse the repository at this point in the history
  • Loading branch information
Mehni committed Jul 26, 2018
1 parent fb6058a commit 8cf7405
Show file tree
Hide file tree
Showing 11 changed files with 48 additions and 29 deletions.
Binary file modified Assemblies/MoreFactionInteraction.dll
Binary file not shown.
1 change: 0 additions & 1 deletion MoreFactionInteraction/General/HarmonyPatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ private static void TraderStocker_OverStockerPostFix(ref List<Thing> __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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ public override IEnumerable<DiaOption> 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));
Expand All @@ -60,6 +60,7 @@ public override IEnumerable<DiaOption> 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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -51,10 +51,12 @@ public static FloatMenuAcceptanceReport CanVisit(Caravan caravan, FactionWarPeac

public static IEnumerable<FloatMenuOption> GetFloatMenuOptions(Caravan caravan, FactionWarPeaceTalks factionWarPeaceTalks)
{
return CaravanArrivalActionUtility.GetFloatMenuOptions<CaravanArrivalAction_VisitFactionWarPeaceTalks>(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);
}
}
}
7 changes: 4 additions & 3 deletions MoreFactionInteraction/MoreFactionWar/FactionWarDialogue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<WorldComponent_MFI_FactionWar>().StartWar(factionOne: factionOne, factionInstigator: factionInstigator, selfResolved: true);},
{ Find.World.GetComponent<WorldComponent_MFI_FactionWar>().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.")});
}
Expand All @@ -50,15 +50,15 @@ private static IEnumerable<DiaOption> 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 = () =>
{
DetermineOutcome(favouredFaction: factionOne, burdenedFaction: factionInstigator, pawn: pawn, desiredOutcome: 1, factionWarNegotiationsOutcome: out factionWarNegotiationsOutcome);
},
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 = () =>
{
Expand Down Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ public override IEnumerable<FloatMenuOption> 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<WorldComponent_MFI_FactionWar>().DetermineWarAsIfNoPlayerInteraction(this.factionOne, this.factionInstigator);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,12 @@ public override void CompTick()
CaravanVisitUtility.SettlementVisitedNow(caravan: (Caravan) this.parent)?.GetComponent<WorldObjectComp_SettlementBumperCropComp>().DoOutcome(caravan: (Caravan) this.parent);
}
}

public override void PostExposeData()
{
base.PostExposeData();
Scribe_Values.Look<int>(ref this.workWillBeDoneAtTick, "MFI_BumperCropWorkingCaravanWorkWillBeDoneAt");
Scribe_Values.Look<bool>(ref this.caravanIsWorking, "MFI_BumperCropCaravanIsWorking");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand All @@ -109,8 +110,17 @@ private static string GetLetterText(string baseText, Caravan caravan)

private static List<Pawn> 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<int>(ref this.expiration, "MFI_BumperCropExpiration");
Scribe_Values.Look<int>(ref this.workLeft, "MFI_BumperCropWorkLeft");
Scribe_Values.Look<bool>(ref this.workStarted, "MFI_BumperCropWorkStarted");
}
}
}

0 comments on commit 8cf7405

Please sign in to comment.