public bool MoveNext() { uint num = (uint)this.$PC; this.$PC = -1; switch (num) { case 0u: if (this.def.rulePack != null) { this.$current = this.def.rulePack; if (!this.$disposing) { this.$PC = 1; } return(true); } break; case 1u: break; default: return(false); } this.$PC = -1; return(false); }
public static List <Rule> MergeRules(RulePack rules, string singleRule, string root) { List <Rule> list = new List <Rule>(); if (rules != null) { list.AddRange(rules.Rules); } if (!singleRule.NullOrEmpty()) { list.Add(new Rule_String(root, singleRule)); } return(list); }
public static string ResolveLocalTextWithDescriptionRules(RulePack localRules, string localRootKeyword = "root") { List <Rule> list = new List <Rule>(); list.AddRange(QuestGen.QuestDescriptionRulesReadOnly); if (localRules != null) { list.AddRange(AppendCurrentPrefix(localRules.Rules)); } string text = localRootKeyword; if (!QuestGen.slate.CurrentPrefix.NullOrEmpty()) { text = QuestGen.slate.CurrentPrefix + "/" + text; } text = NormalizeVarPath(text); return(ResolveAbsoluteText(list, QuestGen.QuestDescriptionConstantsReadOnly, text)); }
public override void ExposeData() { base.ExposeData(); for (int i = 0; i < rulesInit.Capacity; i++) { if (i + 1 > this.rulesInit.Count) { this.rulesInit.Add("r_logentry->" + "ConversationEnd".Translate() + " [RECIPIENT_nameDef]."); } string ruleText = this.rulesInit[i]; Scribe_Values.Look(ref ruleText, "rulesInit" + i, "r_logentry->" + "ConversationEnd".Translate()); this.rulesInit[i] = ruleText; } /*for (int i = 0; i < rulesRecip.Capacity; i++) * { * if (i+1 > this.rulesRecip.Count) * { * this.rulesRecip.Add("logentry->" + "ConversationEnd".Translate() + " [other_nameShortIndef]."); * } * string ruleText = this.rulesRecip[i]; * Scribe_Values.Look(ref ruleText, "rulesRecip" + i, "logentry->" + "ConversationEnd".Translate() + " [other_nameShortIndef]."); * this.rulesRecip[i] = ruleText; * }*/ FieldInfo IntDef = typeof(PlayLogEntry_Interaction).GetField("intDef", BindingFlags.Instance | BindingFlags.NonPublic); InteractionDef newIntDef = new InteractionDef(); newIntDef.defName = "EndConversation"; FieldInfo Symbol = typeof(InteractionDef).GetField("symbol", BindingFlags.Instance | BindingFlags.NonPublic); Symbol.SetValue(newIntDef, Symbol.GetValue(InteractionDefOfPsychology.EndConversation)); newIntDef.label = "ConversationEnded".Translate(); FieldInfo RuleStrings = typeof(RulePack).GetField("rulesStrings", BindingFlags.Instance | BindingFlags.NonPublic); RulePack initPack = new RulePack(); RuleStrings.SetValue(initPack, this.rulesInit); newIntDef.logRulesInitiator = initPack; /*RulePack recipPack = new RulePack(); * RuleStrings.SetValue(recipPack, this.rulesRecip); * newIntDef.logRulesRecipient = recipPack;*/ IntDef.SetValue(this, newIntDef); }
// XXX: This is mostly just for maxWordClasses, but you can't define a LoadDataFromXmlCustom for a // Dictionary, sadly. public void LoadDataFromXmlCustom(XmlNode xmlRoot) { foreach (XmlNode xmlMain in xmlRoot.ChildNodes) { if (xmlMain.NodeType != XmlNodeType.Element) { continue; } switch (xmlMain.Name) { case "defName": defName = ParseHelper.FromString <string>(xmlMain.FirstChild.Value); break; case "rulePack": RulePack rulePackFromXml = DirectXmlToObject.ObjectFromXml <RulePack>(xmlMain, false); // [Reflection] this.rulePack = rulePackFromXml; FieldInfo rulePackField = AccessTools.Field(typeof(RulePackDef), "rulePack"); rulePackField.SetValue(this, rulePackFromXml); break; case "disallowedAffixCombos": disallowedAffixCombos = DirectXmlToObject.ObjectFromXml <List <string> >(xmlMain, false); break; case "maxWordClasses": foreach (XmlNode node in xmlMain.ChildNodes) { string key = ParseHelper.FromString <string>(node.Name); int val = ParseHelper.FromString <int> (node.FirstChild.Value); maxWordClasses.Add(key, val); } break; default: Log.Error("XML error: " + xmlMain.Name + " doesn't correspond to any field in type " + this.GetType().Name + ". Context: " + xmlMain.OuterXml); break; } } }
public RulePack CreateRulePack() { var totalRules = dataSouce.Count() + dataSouce.Where(n => n.SubCategories.Count > 0).Sum(n => n.SubCategories.count()); var rulePack = new RulePack { RulePackID = Guid.NewGuid().ToString(), Description = "TeamMentor Secure Coding Rules version 1.0", Name = "TeamMentor Secure Coding Rules version 1.0", SKU = Guid.NewGuid().ToString(), Version = "1.0", Rules = new RulePackRules[1] }; //Creating rules rule = new RulePackRules { version = "3.11", RuleDefinitions = new RulePackRulesRuleDefinitionsCustomDescriptionRule[totalRules] }; AddRulesWithHtmlContent3(rulePack,totalRules); return rulePack; }
public static string ResolveLocalText(RulePack localRules, string localRootKeyword = "root") { return(ResolveLocalText(localRules?.Rules, null, localRootKeyword)); }
public static QuestPart_Message Message(this Quest quest, string message, MessageTypeDef messageType = null, bool getLookTargetsFromSignal = false, RulePack rules = null, LookTargets lookTargets = null, string inSignal = null) { QuestPart_Message questPart = new QuestPart_Message(); questPart.inSignal = QuestGenUtility.HardcodedSignalWithQuestID(inSignal) ?? QuestGen.slate.Get <string>("inSignal"); questPart.messageType = messageType ?? MessageTypeDefOf.NeutralEvent; questPart.lookTargets = lookTargets; questPart.getLookTargetsFromSignal = getLookTargetsFromSignal; QuestGen.AddTextRequest("root", delegate(string x) { questPart.message = x; }, QuestGenUtility.MergeRules(rules, message, "root")); QuestGen.quest.AddPart(questPart); return(questPart); }
public override IEnumerable <QuestPart> GenerateQuestParts(int index, RewardsGeneratorParams parms, string customLetterLabel, string customLetterText, RulePack customLetterLabelRules, RulePack customLetterTextRules) { Slate slate = RimWorld.QuestGen.QuestGen.slate; QuestPart_GiveRoyalFavor questPart_GiveRoyalFavor = new QuestPart_GiveRoyalFavor(); questPart_GiveRoyalFavor.faction = faction; questPart_GiveRoyalFavor.amount = amount; if (!parms.chosenPawnSignal.NullOrEmpty()) { questPart_GiveRoyalFavor.inSignal = QuestGenUtility.HardcodedSignalWithQuestID(parms.chosenPawnSignal); questPart_GiveRoyalFavor.signalListenMode = QuestPart.SignalListenMode.Always; } else { questPart_GiveRoyalFavor.inSignal = slate.Get <string>("inSignal"); questPart_GiveRoyalFavor.giveToAccepter = true; } yield return(questPart_GiveRoyalFavor); slate.Set("royalFavorReward_amount", amount); }
public static QuestPart_DropPods DropPods(this Quest quest, MapParent mapParent, IEnumerable <Thing> contents, string customLetterLabel = null, RulePack customLetterLabelRules = null, string customLetterText = null, RulePack customLetterTextRules = null, bool?sendStandardLetter = true, bool useTradeDropSpot = false, bool joinPlayer = false, bool makePrisoners = false, string inSignal = null, IEnumerable <Thing> thingsToExcludeFromHyperlinks = null, QuestPart.SignalListenMode signalListenMode = QuestPart.SignalListenMode.OngoingOnly, IntVec3?dropSpot = null, bool destroyItemsOnCleanup = true) { QuestPart_DropPods dropPods = new QuestPart_DropPods(); dropPods.inSignal = QuestGenUtility.HardcodedSignalWithQuestID(inSignal) ?? QuestGen.slate.Get <string>("inSignal"); dropPods.signalListenMode = signalListenMode; if (!customLetterLabel.NullOrEmpty() || customLetterLabelRules != null) { QuestGen.AddTextRequest("root", delegate(string x) { dropPods.customLetterLabel = x; }, QuestGenUtility.MergeRules(customLetterLabelRules, customLetterLabel, "root")); } if (!customLetterText.NullOrEmpty() || customLetterTextRules != null) { QuestGen.AddTextRequest("root", delegate(string x) { dropPods.customLetterText = x; }, QuestGenUtility.MergeRules(customLetterTextRules, customLetterText, "root")); } dropPods.sendStandardLetter = sendStandardLetter ?? dropPods.sendStandardLetter; dropPods.useTradeDropSpot = useTradeDropSpot; dropPods.joinPlayer = joinPlayer; dropPods.makePrisoners = makePrisoners; dropPods.mapParent = mapParent; dropPods.Things = contents; dropPods.destroyItemsOnCleanup = destroyItemsOnCleanup; if (dropSpot.HasValue) { dropPods.dropSpot = dropSpot.Value; } if (thingsToExcludeFromHyperlinks != null) { dropPods.thingsToExcludeFromHyperlinks.AddRange(thingsToExcludeFromHyperlinks.Select((Thing t) => t.GetInnerIfMinified().def)); } QuestGen.quest.AddPart(dropPods); return(dropPods); }
public static void AddQuestNameRules(RulePack rulePack) { AddQuestNameRules(rulePack.Rules); }
public static void AddTextRequest(string localKeyword, Action <string> setter, RulePack extraLocalRules = null) { AddTextRequest(localKeyword, setter, extraLocalRules?.Rules); }
private static void AddRulesWithHtmlContent3(RulePack rulePack,int totalrows) { var index = 0; foreach (var xrule in dataSouce) { AddCategory(xrule.ArticleUrl,xrule.FortifyCategoryDescription,index); if (xrule.SubCategories != null && xrule.SubCategories.count() > 0) { index++; foreach (var subCategory in xrule.SubCategories) { AddSubCategory(xrule.FortifyCategoryDescription, subCategory.SubCategoryDescription, subCategory.ArticleUrl, index); index++; } } else index++; } rulePack.Rules[0] = rule; driver.Close(); driver.Quit(); }
public override IEnumerable <QuestPart> GenerateQuestParts(int index, RewardsGeneratorParams parms, string customLetterLabel, string customLetterText, RulePack customLetterLabelRules, RulePack customLetterTextRules) { QuestPart_FactionGoodwillChange questPart_FactionGoodwillChange = new QuestPart_FactionGoodwillChange(); questPart_FactionGoodwillChange.change = amount; questPart_FactionGoodwillChange.faction = faction; questPart_FactionGoodwillChange.inSignal = RimWorld.QuestGen.QuestGen.slate.Get <string>("inSignal"); yield return(questPart_FactionGoodwillChange); }
//public void Login () //{ // var url = "http://checkmarx.teammentor.net"; // driver.Url = url; // driver.Navigate(); // driver.FindElement(By.Id("")) //} private static void AddRulesWithHtmlContent(RulePack rulePack) { ////Creating rules //var rule = new RulePackRules //{ // version = "3.11", // RuleDefinitions = new RulePackRulesRuleDefinitionsCustomDescriptionRule[mapping.count()] //}; int index = 0; foreach (var item in mapping) { var url = new Uri(item.Value); var articleUrl = @"<a href=""" + url.hostUrl() + "/article/"; driver.Url = item.Value; driver.Navigate(); System.Threading.Thread.Sleep(3000); ReadOnlyCollection<IWebElement> links = driver.FindElements(By.TagName("a")); //UpdateRelativeURl(links); rule.RuleDefinitions[index] = new RulePackRulesRuleDefinitionsCustomDescriptionRule { RuleID = Guid.NewGuid().ToString(), RuleMatch = new RulePackRulesRuleDefinitionsCustomDescriptionRuleRuleMatch[1], formatVersion = "3.2" }; rule.RuleDefinitions[index].RuleMatch[0] = new RulePackRulesRuleDefinitionsCustomDescriptionRuleRuleMatch(); rule.RuleDefinitions[index].RuleMatch[0].Category = new RulePackRulesRuleDefinitionsCustomDescriptionRuleRuleMatchCategory[1]; rule.RuleDefinitions[index].RuleMatch[0].Category[0] = new RulePackRulesRuleDefinitionsCustomDescriptionRuleRuleMatchCategory(); rule.RuleDefinitions[index].RuleMatch[0].Category[0].Value = item.Key; rule.RuleDefinitions[index].Description = new RulePackRulesRuleDefinitionsCustomDescriptionRuleDescription[1]; rule.RuleDefinitions[index].Description[0] = new RulePackRulesRuleDefinitionsCustomDescriptionRuleDescription(); //var description = driver.FindElement(By.Id("itemContent")).Text.replace("\r\n", "\r\n\r\n"); var description = new StringBuilder(); description.Append(driver.FindElement(By.Id("guidanceItem")).GetAttribute("innerHTML")); description = description.Replace("<h1>", ""); description = description.Replace("</h1>", "\r\n\r\n"); description = description.Replace("<h2>", ""); description = description.Replace("</h2>", "\r\n\r\n"); description = description.Replace("<h3>", ""); description = description.Replace("</h3>", "\r\n\r\n"); // description = description.Replace("<a href=\"/article/", articleUrl); rule.RuleDefinitions[index].Description[0].Explanation = description.ToString(); rule.RuleDefinitions[index].Description[0].Recommendations = "Please refer to : " + item.Value; index++; } rulePack.Rules[0] = rule; //driver.Close(); //driver.Quit(); }
private static void AddRulesWithHtmlContent2(RulePack rulePack) { //Creating rules var rule = new RulePackRules { version = "3.11", RuleDefinitions = new RulePackRulesRuleDefinitionsCustomDescriptionRule[dataSouce.count()] }; int index = 0; foreach (var item in dataSouce) { var url = new Uri(item.ArticleUrl); var articleUrl = @"<a href=""" + url.hostUrl() + "/article/"; var matchIndex = 0; if (item.SubCategories.notNull()) matchIndex = item.SubCategories.count() + 1; else matchIndex = 1; driver.Url = item.ArticleUrl; driver.Navigate(); System.Threading.Thread.Sleep(3000); ReadOnlyCollection<IWebElement> links = driver.FindElements(By.TagName("a")); // UpdateRelativeURl(links); rule.RuleDefinitions[index] = new RulePackRulesRuleDefinitionsCustomDescriptionRule { RuleID = Guid.NewGuid().ToString(), RuleMatch = new RulePackRulesRuleDefinitionsCustomDescriptionRuleRuleMatch[matchIndex], formatVersion = "3.2" }; rule.RuleDefinitions[index].RuleMatch[0] = new RulePackRulesRuleDefinitionsCustomDescriptionRuleRuleMatch(); rule.RuleDefinitions[index].RuleMatch[0].Category = new RulePackRulesRuleDefinitionsCustomDescriptionRuleRuleMatchCategory[1]; rule.RuleDefinitions[index].RuleMatch[0].Category[0] = new RulePackRulesRuleDefinitionsCustomDescriptionRuleRuleMatchCategory(); rule.RuleDefinitions[index].RuleMatch[0].Category[0].Value = item.FortifyCategoryDescription; if (item.SubCategories.notNull() && item.SubCategories.count() > 0) { rule.RuleDefinitions[index].RuleMatch[0].Subcategory = new RulePackRulesRuleDefinitionsCustomDescriptionRuleRuleMatchSubcategory[item.SubCategories.count()]; var newIndex = 0; foreach (var subCat in item.SubCategories) { rule.RuleDefinitions[index].RuleMatch[0].Subcategory [newIndex] = new RulePackRulesRuleDefinitionsCustomDescriptionRuleRuleMatchSubcategory(); rule.RuleDefinitions[index].RuleMatch[0].Subcategory[newIndex].Value = subCat.SubCategoryDescription; newIndex ++; } } rule.RuleDefinitions[index].Description = new RulePackRulesRuleDefinitionsCustomDescriptionRuleDescription[1]; rule.RuleDefinitions[index].Description[0] = new RulePackRulesRuleDefinitionsCustomDescriptionRuleDescription(); //var description = driver.FindElement(By.Id("itemContent")).Text.replace("\r\n", "\r\n\r\n"); var description = new StringBuilder(); description.Append(driver.FindElement(By.Id("guidanceItem")).GetAttribute("innerHTML")); description = description.Replace("<h1>", ""); description = description.Replace("</h1>", "\r\n\r\n"); description = description.Replace("<h2>", ""); description = description.Replace("</h2>", "\r\n\r\n"); description = description.Replace("<h3>", ""); description = description.Replace("</h3>", "\r\n\r\n"); // description = description.Replace("<a href=\"/article/", articleUrl); rule.RuleDefinitions[index].Description[0].Explanation = description.ToString(); rule.RuleDefinitions[index].Description[0].Recommendations = "Please refer to : " + item.ArticleUrl; index++; } rulePack.Rules[0] = rule; driver.Close(); driver.Quit(); }
public override IEnumerable <QuestPart> GenerateQuestParts(int index, RewardsGeneratorParams parms, string customLetterLabel, string customLetterText, RulePack customLetterLabelRules, RulePack customLetterTextRules) { Slate slate = RimWorld.QuestGen.QuestGen.slate; RimWorld.QuestGen.QuestGen.AddToGeneratedPawns(pawn); if (!pawn.IsWorldPawn()) { Find.WorldPawns.PassToWorld(pawn); } if (parms.giveToCaravan) { QuestPart_GiveToCaravan questPart_GiveToCaravan = new QuestPart_GiveToCaravan(); questPart_GiveToCaravan.inSignal = slate.Get <string>("inSignal"); questPart_GiveToCaravan.Things = Gen.YieldSingle(pawn); yield return(questPart_GiveToCaravan); yield break; } QuestPart_PawnsArrive pawnsArrive = new QuestPart_PawnsArrive(); pawnsArrive.inSignal = slate.Get <string>("inSignal"); pawnsArrive.pawns.Add(pawn); pawnsArrive.arrivalMode = ((arrivalMode == ArrivalMode.DropPod) ? PawnsArrivalModeDefOf.CenterDrop : PawnsArrivalModeDefOf.EdgeWalkIn); pawnsArrive.joinPlayer = true; pawnsArrive.mapParent = slate.Get <Map>("map").Parent; if (!customLetterLabel.NullOrEmpty() || customLetterLabelRules != null) { RimWorld.QuestGen.QuestGen.AddTextRequest("root", delegate(string x) { pawnsArrive.customLetterLabel = x; }, QuestGenUtility.MergeRules(customLetterLabelRules, customLetterLabel, "root")); } if (!customLetterText.NullOrEmpty() || customLetterTextRules != null) { RimWorld.QuestGen.QuestGen.AddTextRequest("root", delegate(string x) { pawnsArrive.customLetterText = x; }, QuestGenUtility.MergeRules(customLetterTextRules, customLetterText, "root")); } yield return(pawnsArrive); }
public static QuestPart_Choice GiveRewards(this Quest quest, RewardsGeneratorParams parms, string inSignal = null, string customLetterLabel = null, string customLetterText = null, RulePack customLetterLabelRules = null, RulePack customLetterTextRules = null, bool?useDifficultyFactor = null, Action runIfChosenPawnSignalUsed = null, int?variants = null, bool addCampLootReward = false, Pawn asker = null, bool addShuttleLootReward = false, bool addPossibleFutureReward = false) { try { Slate slate = QuestGen.slate; RewardsGeneratorParams parmsResolved = parms; parmsResolved.rewardValue = ((parmsResolved.rewardValue == 0f) ? slate.Get("rewardValue", 0f) : parmsResolved.rewardValue); if (useDifficultyFactor ?? true) { parmsResolved.rewardValue *= Find.Storyteller.difficultyValues.EffectiveQuestRewardValueFactor; parmsResolved.rewardValue = Math.Max(1f, parmsResolved.rewardValue); } if (slate.Get("debugDontGenerateRewardThings", defaultValue: false)) { DebugActionsQuests.lastQuestGeneratedRewardValue += Mathf.Max(parmsResolved.rewardValue, 250f); return(null); } parmsResolved.minGeneratedRewardValue = 250f; parmsResolved.giverFaction = parmsResolved.giverFaction ?? asker?.Faction; parmsResolved.populationIntent = QuestTuning.PopIncreasingRewardWeightByPopIntentCurve.Evaluate(StorytellerUtilityPopulation.PopulationIntentForQuest); if (parmsResolved.giverFaction == null || parmsResolved.giverFaction.def.permanentEnemy) { parmsResolved.allowGoodwill = false; } if (parmsResolved.giverFaction == null || asker.royalty == null || !asker.royalty.HasAnyTitleIn(asker.Faction) || parmsResolved.giverFaction.HostileTo(Faction.OfPlayer)) { parmsResolved.allowRoyalFavor = false; } Slate.VarRestoreInfo restoreInfo = slate.GetRestoreInfo("inSignal"); if (inSignal.NullOrEmpty()) { inSignal = slate.Get <string>("inSignal"); } else { slate.Set("inSignal", QuestGenUtility.HardcodedSignalWithQuestID(inSignal)); } try { QuestPart_Choice questPart_Choice = new QuestPart_Choice(); questPart_Choice.inSignalChoiceUsed = slate.Get <string>("inSignal"); bool chosenPawnSignalUsed = false; int num = ((parmsResolved.allowGoodwill && parmsResolved.giverFaction != null && parmsResolved.giverFaction.HostileTo(Faction.OfPlayer)) ? 1 : (variants ?? (QuestGen.quest.root.autoAccept ? 1 : 3))); generatedRewards.Clear(); for (int i = 0; i < num; i++) { QuestPart_Choice.Choice choice = new QuestPart_Choice.Choice(); List <Reward> list = GenerateRewards(parmsResolved, slate, i == 0, ref chosenPawnSignalUsed, choice, num, customLetterLabel, customLetterText, customLetterLabelRules, customLetterTextRules); if (list != null) { questPart_Choice.choices.Add(choice); generatedRewards.Add(list); } } generatedRewards.Clear(); if (addCampLootReward) { for (int j = 0; j < questPart_Choice.choices.Count; j++) { questPart_Choice.choices[j].rewards.Add(new Reward_CampLoot()); } } if (addShuttleLootReward) { for (int k = 0; k < questPart_Choice.choices.Count; k++) { questPart_Choice.choices[k].rewards.Add(new Reward_ShuttleLoot()); } } if (addPossibleFutureReward) { for (int l = 0; l < questPart_Choice.choices.Count; l++) { questPart_Choice.choices[l].rewards.Add(new Reward_PossibleFutureReward()); } } questPart_Choice.choices.SortByDescending(GetDisplayPriority); QuestGen.quest.AddPart(questPart_Choice); if (chosenPawnSignalUsed && runIfChosenPawnSignalUsed != null) { tmpPrevQuestParts.Clear(); tmpPrevQuestParts.AddRange(QuestGen.quest.PartsListForReading); runIfChosenPawnSignalUsed(); List <QuestPart> partsListForReading = QuestGen.quest.PartsListForReading; for (int m = 0; m < partsListForReading.Count; m++) { if (tmpPrevQuestParts.Contains(partsListForReading[m])) { continue; } for (int n = 0; n < questPart_Choice.choices.Count; n++) { bool flag = false; for (int num2 = 0; num2 < questPart_Choice.choices[n].rewards.Count; num2++) { if (questPart_Choice.choices[n].rewards[num2].MakesUseOfChosenPawnSignal) { flag = true; break; } } if (flag) { questPart_Choice.choices[n].questParts.Add(partsListForReading[m]); } } } tmpPrevQuestParts.Clear(); } return(questPart_Choice); } finally { slate.Restore(restoreInfo); } } finally { generatedRewards.Clear(); } }
private static List <Reward> GenerateRewards(RewardsGeneratorParams parmsResolved, Slate slate, bool addDescriptionRules, ref bool chosenPawnSignalUsed, QuestPart_Choice.Choice choice, int variants, string customLetterLabel, string customLetterText, RulePack customLetterLabelRules, RulePack customLetterTextRules) { List <string> list; List <string> list2; if (addDescriptionRules) { list = new List <string>(); list2 = new List <string>(); } else { list = null; list2 = null; } bool flag = false; bool flag2 = false; for (int i = 0; i < generatedRewards.Count; i++) { for (int j = 0; j < generatedRewards[i].Count; j++) { if (generatedRewards[i][j] is Reward_Pawn) { flag2 = true; break; } } if (flag2) { break; } } if (flag2) { parmsResolved.thingRewardItemsOnly = true; } List <Reward> list3 = null; if (variants >= 2 && !generatedRewards.Any() && parmsResolved.allowGoodwill && !parmsResolved.thingRewardRequired) { list3 = TryGenerateRewards_SocialOnly(parmsResolved, variants >= 3); if (list3.NullOrEmpty() && variants >= 3) { list3 = TryGenerateRewards_ThingsOnly(parmsResolved); } if (list3.NullOrEmpty()) { list3 = TryGenerateNonRepeatingRewards(parmsResolved); } } else if (variants >= 3 && generatedRewards.Count == 1 && parmsResolved.allowRoyalFavor && !parmsResolved.thingRewardRequired) { list3 = TryGenerateRewards_RoyalFavorOnly(parmsResolved); if (list3.NullOrEmpty()) { list3 = TryGenerateRewards_ThingsOnly(parmsResolved); } if (list3.NullOrEmpty()) { list3 = TryGenerateNonRepeatingRewards(parmsResolved); } } else if (variants >= 2 && generatedRewards.Any() && !parmsResolved.thingRewardDisallowed) { list3 = TryGenerateRewards_ThingsOnly(parmsResolved); if (list3.NullOrEmpty()) { list3 = TryGenerateNonRepeatingRewards(parmsResolved); } } else { list3 = TryGenerateNonRepeatingRewards(parmsResolved); } if (list3.NullOrEmpty()) { return(null); } Reward_Items reward_Items = (Reward_Items)list3.Find((Reward x) => x is Reward_Items); if (reward_Items == null) { List <Type> b = list3.Select((Reward x) => x.GetType()).ToList(); for (int k = 0; k < generatedRewards.Count; k++) { if (generatedRewards[k].Select((Reward x) => x.GetType()).ToList().ListsEqualIgnoreOrder(b)) { return(null); } } } else if (list3.Count == 1) { List <ThingDef> b2 = reward_Items.ItemsListForReading.Select((Thing x) => x.def).ToList(); for (int l = 0; l < generatedRewards.Count; l++) { Reward_Items reward_Items2 = (Reward_Items)generatedRewards[l].Find((Reward x) => x is Reward_Items); if (reward_Items2 != null && reward_Items2.ItemsListForReading.Select((Thing x) => x.def).ToList().ListsEqualIgnoreOrder(b2)) { return(null); } } } list3.SortBy((Reward x) => x is Reward_Items); choice.rewards.AddRange(list3); for (int m = 0; m < list3.Count; m++) { if (addDescriptionRules) { list.Add(list3[m].GetDescription(parmsResolved)); if (!(list3[m] is Reward_Items)) { list2.Add(list3[m].GetDescription(parmsResolved)); } else if (m == list3.Count - 1) { flag = true; } } foreach (QuestPart item in list3[m].GenerateQuestParts(m, parmsResolved, customLetterLabel, customLetterText, customLetterLabelRules, customLetterTextRules)) { QuestGen.quest.AddPart(item); choice.questParts.Add(item); } if (!parmsResolved.chosenPawnSignal.NullOrEmpty() && list3[m].MakesUseOfChosenPawnSignal) { chosenPawnSignalUsed = true; } } if (addDescriptionRules) { string text = list.AsEnumerable().ToList().ToClauseSequence() .Resolve() .UncapitalizeFirst(); if (flag) { text = text.TrimEnd('.'); } QuestGen.AddQuestDescriptionRules(new List <Rule> { new Rule_String("allRewardsDescriptions", text.UncapitalizeFirst()), new Rule_String("allRewardsDescriptionsExceptItems", list2.Any() ? list2.AsEnumerable().ToList().ToClauseSequence() .Resolve() .UncapitalizeFirst() : "") }); } return(list3); }
public override void PostRemoved() { base.PostRemoved(); if (this.pawn != null && this.otherPawn != null) { if (this.pawn.Dead || this.otherPawn.Dead || !PsycheHelper.PsychologyEnabled(pawn) || !PsycheHelper.PsychologyEnabled(otherPawn)) { return; } Hediff_Conversation otherConvo = otherPawn.health.hediffSet.hediffs.Find(h => h is Hediff_Conversation && ((Hediff_Conversation)h).otherPawn == this.pawn) as Hediff_Conversation; if (otherConvo != null) { this.otherPawn.health.RemoveHediff(otherConvo); this.startedFight = otherConvo.startedFight; } string talkDesc; if (this.ageTicks < 500) { int numShortTalks = int.Parse("NumberOfShortTalks".Translate()); talkDesc = "ShortTalk" + Rand.RangeInclusive(1, numShortTalks); } else if (this.ageTicks < GenDate.TicksPerHour / 2) { int numNormalTalks = int.Parse("NumberOfNormalTalks".Translate()); talkDesc = "NormalTalk" + Rand.RangeInclusive(1, numNormalTalks); } else if (this.ageTicks < GenDate.TicksPerHour * 2.5) { int numLongTalks = int.Parse("NumberOfLongTalks".Translate()); talkDesc = "LongTalk" + Rand.RangeInclusive(1, numLongTalks); } else { int numEpicTalks = int.Parse("NumberOfEpicTalks".Translate()); talkDesc = "EpicTalk" + Rand.RangeInclusive(1, numEpicTalks); } float opinionMod; ThoughtDef def = CreateSocialThought(out opinionMod); bool mattered = TryGainThought(def, Mathf.RoundToInt(opinionMod)); InteractionDef endConversation = new InteractionDef(); endConversation.socialFightBaseChance = 0.2f * PsycheHelper.Comp(pawn).Psyche.GetPersonalityRating(PersonalityNodeDefOf.Aggressive) * PopulationModifier * Mathf.InverseLerp(0f, -80f, opinionMod); endConversation.defName = "EndConversation"; endConversation.label = def.label; List <RulePackDef> socialFightPacks = new List <RulePackDef>(); if (otherConvo != null && (startedFight || (mattered && this.pawn.interactions.CheckSocialFightStart(endConversation, otherPawn)))) { if (startedFight) { socialFightPacks.Add(RulePackDefOfPsychology.Sentence_SocialFightConvoRecipientStarted); } else { socialFightPacks.Add(RulePackDefOfPsychology.Sentence_SocialFightConvoInitiatorStarted); } this.startedFight = true; if (!this.waveGoodbye && otherConvo.convoLog != null && !otherConvo.startedFight) { //The main conversation hediff was the other conversation, and didn't start a fight, so we have to add the extra sentence in after the fact. Traverse.Create(otherConvo.convoLog).Field("extraSentencePacks").GetValue <List <RulePackDef> >().AddRange(socialFightPacks); } } if (this.waveGoodbye && this.pawn.Map != null) { RulePack goodbyeText = new RulePack(); FieldInfo RuleStrings = typeof(RulePack).GetField("rulesStrings", BindingFlags.Instance | BindingFlags.NonPublic); List <string> text = new List <string>(1); text.Add("r_logentry->" + talkDesc.Translate(convoTopic, pawn.Named("INITIATOR"), otherPawn.Named("RECIPIENT"))); RuleStrings.SetValue(goodbyeText, text); endConversation.logRulesInitiator = goodbyeText; FieldInfo Symbol = typeof(InteractionDef).GetField("symbol", BindingFlags.Instance | BindingFlags.NonPublic); Symbol.SetValue(endConversation, Symbol.GetValue(InteractionDefOfPsychology.EndConversation)); PlayLogEntry_InteractionConversation log = new PlayLogEntry_InteractionConversation(endConversation, pawn, this.otherPawn, socialFightPacks); Find.PlayLog.Add(log); convoLog = log; MoteMaker.MakeInteractionBubble(this.pawn, this.otherPawn, InteractionDefOf.Chitchat.interactionMote, InteractionDefOf.Chitchat.Symbol); } } }
public override IEnumerable <QuestPart> GenerateQuestParts(int index, RewardsGeneratorParams parms, string customLetterLabel, string customLetterText, RulePack customLetterLabelRules, RulePack customLetterTextRules) { Slate slate = RimWorld.QuestGen.QuestGen.slate; for (int i = 0; i < items.Count; i++) { Pawn pawn = items[i] as Pawn; if (pawn != null) { RimWorld.QuestGen.QuestGen.AddToGeneratedPawns(pawn); if (!pawn.IsWorldPawn()) { Find.WorldPawns.PassToWorld(pawn); } } } if (parms.giveToCaravan) { QuestPart_GiveToCaravan questPart_GiveToCaravan = new QuestPart_GiveToCaravan(); questPart_GiveToCaravan.inSignal = slate.Get <string>("inSignal"); questPart_GiveToCaravan.Things = items; yield return(questPart_GiveToCaravan); } else { QuestPart_DropPods dropPods = new QuestPart_DropPods(); dropPods.inSignal = slate.Get <string>("inSignal"); if (!customLetterLabel.NullOrEmpty() || customLetterLabelRules != null) { RimWorld.QuestGen.QuestGen.AddTextRequest("root", delegate(string x) { dropPods.customLetterLabel = x; }, QuestGenUtility.MergeRules(customLetterLabelRules, customLetterLabel, "root")); } if (!customLetterText.NullOrEmpty() || customLetterTextRules != null) { RimWorld.QuestGen.QuestGen.AddTextRequest("root", delegate(string x) { dropPods.customLetterText = x; }, QuestGenUtility.MergeRules(customLetterTextRules, customLetterText, "root")); } dropPods.mapParent = slate.Get <Map>("map").Parent; dropPods.useTradeDropSpot = true; dropPods.Things = items; yield return(dropPods); } slate.Set("itemsReward_items", items); slate.Set("itemsReward_totalMarketValue", TotalMarketValue); }
public override IEnumerable <QuestPart> GenerateQuestParts(int index, RewardsGeneratorParams parms, string customLetterLabel, string customLetterText, RulePack customLetterLabelRules, RulePack customLetterTextRules) { throw new NotImplementedException(); }
public static void PawnsArrive(this Quest quest, IEnumerable <Pawn> pawns, string inSignal = null, MapParent mapParent = null, PawnsArrivalModeDef arrivalMode = null, bool joinPlayer = false, IntVec3?walkInSpot = null, string customLetterLabel = null, string customLetterText = null, RulePack customLetterLabelRules = null, RulePack customLetterTextRules = null, bool isSingleReward = false, bool rewardDetailsHidden = false) { _ = QuestGen.slate; PawnsArrivalModeDef pawnsArrivalModeDef = arrivalMode ?? PawnsArrivalModeDefOf.EdgeWalkIn; QuestPart_PawnsArrive pawnsArrive = new QuestPart_PawnsArrive(); pawnsArrive.inSignal = QuestGenUtility.HardcodedSignalWithQuestID(inSignal) ?? QuestGen.slate.Get <string>("inSignal"); pawnsArrive.pawns.AddRange(pawns); pawnsArrive.arrivalMode = pawnsArrivalModeDef; pawnsArrive.joinPlayer = joinPlayer; pawnsArrive.mapParent = mapParent ?? QuestGen.slate.Get <Map>("map").Parent; if (pawnsArrivalModeDef.walkIn) { pawnsArrive.spawnNear = walkInSpot ?? QuestGen.slate.Get <IntVec3?>("walkInSpot") ?? IntVec3.Invalid; } if (!customLetterLabel.NullOrEmpty() || customLetterLabelRules != null) { QuestGen.AddTextRequest("root", delegate(string x) { pawnsArrive.customLetterLabel = x; }, QuestGenUtility.MergeRules(customLetterLabelRules, customLetterLabel, "root")); } if (!customLetterText.NullOrEmpty() || customLetterTextRules != null) { QuestGen.AddTextRequest("root", delegate(string x) { pawnsArrive.customLetterText = x; }, QuestGenUtility.MergeRules(customLetterTextRules, customLetterText, "root")); } QuestGen.quest.AddPart(pawnsArrive); if (!isSingleReward) { return; } QuestPart_Choice questPart_Choice = new QuestPart_Choice(); questPart_Choice.inSignalChoiceUsed = pawnsArrive.inSignal; QuestPart_Choice.Choice choice = new QuestPart_Choice.Choice(); choice.questParts.Add(pawnsArrive); foreach (Pawn pawn in pawnsArrive.pawns) { choice.rewards.Add(new Reward_Pawn { pawn = pawn, detailsHidden = rewardDetailsHidden }); } questPart_Choice.choices.Add(choice); QuestGen.quest.AddPart(questPart_Choice); }
public static void AddQuestDescriptionRules(RulePack rulePack) { AddQuestDescriptionRules(rulePack.Rules); }
public abstract IEnumerable <QuestPart> GenerateQuestParts(int index, RewardsGeneratorParams parms, string customLetterLabel, string customLetterText, RulePack customLetterLabelRules, RulePack customLetterTextRules);
public static void AddQuestContentRules(RulePack rulePack) { AddQuestContentRules(rulePack.Rules); }
public static void Raid(this Quest quest, Map map, float points, Faction faction, string inSignalLeave = null, string customLetterLabel = null, string customLetterText = null, RulePack customLetterLabelRules = null, RulePack customLetterTextRules = null, IntVec3?walkInSpot = null, string tag = null, string inSignal = null, string rootSymbol = "root", PawnsArrivalModeDef raidArrivalMode = null) { QuestPart_Incident questPart_Incident = new QuestPart_Incident(); questPart_Incident.debugLabel = "raid"; questPart_Incident.incident = IncidentDefOf.RaidEnemy; IncidentParms incidentParms = new IncidentParms(); incidentParms.forced = true; incidentParms.target = map; incidentParms.points = Mathf.Max(points, faction.def.MinPointsToGeneratePawnGroup(PawnGroupKindDefOf.Combat)); incidentParms.faction = faction; incidentParms.pawnGroupMakerSeed = Rand.Int; incidentParms.inSignalEnd = inSignalLeave; incidentParms.questTag = QuestGenUtility.HardcodedTargetQuestTagWithQuestID(tag); incidentParms.raidArrivalMode = raidArrivalMode; if (!customLetterLabel.NullOrEmpty() || customLetterLabelRules != null) { QuestGen.AddTextRequest(rootSymbol, delegate(string x) { incidentParms.customLetterLabel = x; }, QuestGenUtility.MergeRules(customLetterLabelRules, customLetterLabel, rootSymbol)); } if (!customLetterText.NullOrEmpty() || customLetterTextRules != null) { QuestGen.AddTextRequest(rootSymbol, delegate(string x) { incidentParms.customLetterText = x; }, QuestGenUtility.MergeRules(customLetterTextRules, customLetterText, rootSymbol)); } IncidentWorker_Raid obj = (IncidentWorker_Raid)questPart_Incident.incident.Worker; obj.ResolveRaidStrategy(incidentParms, PawnGroupKindDefOf.Combat); obj.ResolveRaidArriveMode(incidentParms); if (incidentParms.raidArrivalMode.walkIn) { incidentParms.spawnCenter = walkInSpot ?? QuestGen.slate.Get <IntVec3?>("walkInSpot") ?? IntVec3.Invalid; } PawnGroupMakerParms defaultPawnGroupMakerParms = IncidentParmsUtility.GetDefaultPawnGroupMakerParms(PawnGroupKindDefOf.Combat, incidentParms); defaultPawnGroupMakerParms.points = IncidentWorker_Raid.AdjustedRaidPoints(defaultPawnGroupMakerParms.points, incidentParms.raidArrivalMode, incidentParms.raidStrategy, defaultPawnGroupMakerParms.faction, PawnGroupKindDefOf.Combat); IEnumerable <PawnKindDef> pawnKinds = PawnGroupMakerUtility.GeneratePawnKindsExample(defaultPawnGroupMakerParms); questPart_Incident.SetIncidentParmsAndRemoveTarget(incidentParms); questPart_Incident.inSignal = inSignal ?? QuestGen.slate.Get <string>("inSignal"); QuestGen.quest.AddPart(questPart_Incident); QuestGen.AddQuestDescriptionRules(new List <Rule> { new Rule_String("raidPawnKinds", PawnUtility.PawnKindsToLineList(pawnKinds, " - ", ColoredText.ThreatColor)), new Rule_String("raidArrivalModeInfo", incidentParms.raidArrivalMode.textWillArrive.Formatted(faction)) }); }
private void Finished() { if (PsycheHelper.PsychologyEnabled(mayor) && PsycheHelper.PsychologyEnabled(constituent)) { if (this.ticksInSameRoom > 0) { if (this.complaint) { ThoughtDef complaintDef = new ThoughtDef(); complaintDef.label = "MayorComplaint"; complaintDef.durationDays = 1f + 4f * this.mayor.GetStatValue(StatDefOf.SocialImpact); //Constituent thought duration affected by mayor's Social stat complaintDef.thoughtClass = typeof(Thought_MemoryDynamic); complaintDef.stackedEffectMultiplier = 1f; complaintDef.stackLimit = 999; ThoughtStage complaintStage = new ThoughtStage(); float complaintMood = 18f * (PsycheHelper.Comp(mayor).Psyche.GetPersonalityRating(PersonalityNodeDefOf.Empathetic) - 0.33f); //Base complaint mood determined by mayor's Empathetic trait complaintMood *= (float)this.ticksInSameRoom / (float)GenDate.TicksPerHour; //Length of meeting also affects mood complaintMood *= (complaintMood < 0f ? Mathf.Lerp(1.25f, 0.75f, PsycheHelper.Comp(constituent).Psyche.GetPersonalityRating(PersonalityNodeDefOf.Polite)) : 1f); //Negative meeting thoughts (unempathetic mayors) mitigated by mayor's politeness complaintMood += (BeautyUtility.AverageBeautyPerceptible(this.constituent.Position, this.constituent.Map) / 10f); //Beauty of the room has a net positive effect on the thought complaintMood *= 0.75f + (PsycheHelper.Comp(constituent).Psyche.GetPersonalityRating(PersonalityNodeDefOf.Judgmental) / 2f); //Constituent's Judgmental trait changes how much the thought affects them complaintStage.label = "ComplaintLabel".Translate(); complaintStage.description = "ComplaintDesc".Translate(); complaintStage.baseMoodEffect = Mathf.RoundToInt(complaintMood); complaintDef.defName = this.constituent.GetHashCode() + "MayorComplaint" + complaintStage.baseMoodEffect; complaintDef.stages.Add(complaintStage); if (complaintStage.baseMoodEffect != 0) { this.constituent.needs.mood.thoughts.memories.TryGainMemory(complaintDef, this.mayor); } } ThoughtDef visitDef = new ThoughtDef(); visitDef.label = "MayorVisited"; visitDef.durationDays = 0.75f + 2f * (1f - PsycheHelper.Comp(mayor).Psyche.GetPersonalityRating(PersonalityNodeDefOf.Independent)); //Mayor thought duration affected by mayor's Independent trait visitDef.thoughtClass = typeof(Thought_MemoryDynamic); visitDef.stackedEffectMultiplier = 1f; visitDef.stackLimit = 999; ThoughtStage stage = new ThoughtStage(); float mood = 7f * (complaint ? -0.5f - (1f - this.constituent.needs.mood.CurLevel) : 0.1f + (this.constituent.needs.mood.CurLevel * 0.65f)); //Base visit mood determined by the mood level of the constituent mood *= (float)this.ticksInSameRoom / (float)GenDate.TicksPerHour; //Length of meeting also affects mood mood *= (mood < 0f ? Mathf.Lerp(1.25f, 0.75f, PsycheHelper.Comp(constituent).Psyche.GetPersonalityRating(PersonalityNodeDefOf.Polite)) : 1f); //Negative meeting thoughts (unhappy constituents) mitigated by constituent's politeness mood *= 0.5f + (1f - PsycheHelper.Comp(this.mayor).Psyche.GetPersonalityRating(PersonalityNodeDefOf.LaidBack)); //Mayor's Laid-Back trait strongly impacts how much the thought affects them stage.label = "VisitLabel".Translate(); stage.description = "VisitDesc".Translate(); stage.baseMoodEffect = Mathf.RoundToInt(mood); visitDef.defName = this.mayor.GetHashCode() + "MayorVisited" + stage.baseMoodEffect; visitDef.stages.Add(stage); if (stage.baseMoodEffect != 0) { this.mayor.needs.mood.thoughts.memories.TryGainMemory(visitDef, this.constituent); } InteractionDef endConversation = new InteractionDef(); endConversation.defName = "EndConversation"; FieldInfo RuleStrings = typeof(RulePack).GetField("rulesStrings", BindingFlags.Instance | BindingFlags.NonPublic); RulePack goodbyeTextInit = new RulePack(); List <string> text = new List <string>(1); if (complaint) { text.Add("r_logentry->" + "Complained".Translate()); } else { text.Add("r_logentry->" + "Supported".Translate()); } RuleStrings.SetValue(goodbyeTextInit, text); endConversation.logRulesInitiator = goodbyeTextInit; FieldInfo Symbol = typeof(InteractionDef).GetField("symbol", BindingFlags.Instance | BindingFlags.NonPublic); Symbol.SetValue(endConversation, Symbol.GetValue(InteractionDefOfPsychology.HangOut)); PlayLogEntry_InteractionConversation log = new PlayLogEntry_InteractionConversation(endConversation, this.constituent, this.mayor, new List <RulePackDef>()); Find.PlayLog.Add(log); MoteMaker.MakeInteractionBubble(this.mayor, this.constituent, InteractionDefOf.Chitchat.interactionMote, InteractionDefOf.Chitchat.Symbol); } } }
public static Site GenerateSite(IEnumerable <SitePartDefWithParams> sitePartsParams, int tile, Faction faction, bool hiddenSitePartsPossible = false, RulePack singleSitePartRules = null) { _ = QuestGen.slate; bool flag = false; foreach (SitePartDefWithParams sitePartsParam in sitePartsParams) { if (sitePartsParam.def.defaultHidden) { flag = true; break; } } if (flag || hiddenSitePartsPossible) { SitePartParams parms = SitePartDefOf.PossibleUnknownThreatMarker.Worker.GenerateDefaultParams(0f, tile, faction); SitePartDefWithParams val = new SitePartDefWithParams(SitePartDefOf.PossibleUnknownThreatMarker, parms); sitePartsParams = sitePartsParams.Concat(Gen.YieldSingle(val)); } Site site = SiteMaker.MakeSite(sitePartsParams, tile, faction); List <Rule> list = new List <Rule>(); Dictionary <string, string> dictionary = new Dictionary <string, string>(); List <string> list2 = new List <string>(); int num = 0; for (int i = 0; i < site.parts.Count; i++) { List <Rule> list3 = new List <Rule>(); Dictionary <string, string> dictionary2 = new Dictionary <string, string>(); site.parts[i].def.Worker.Notify_GeneratedByQuestGen(site.parts[i], QuestGen.slate, list3, dictionary2); if (site.parts[i].hidden) { continue; } if (singleSitePartRules != null) { List <Rule> list4 = new List <Rule>(); list4.AddRange(list3); list4.AddRange(singleSitePartRules.Rules); string text = QuestGenUtility.ResolveLocalText(list4, dictionary2, "root", capitalizeFirstSentence: false); list.Add(new Rule_String("sitePart" + num + "_description", text)); if (!text.NullOrEmpty()) { list2.Add(text); } } for (int j = 0; j < list3.Count; j++) { Rule rule = list3[j].DeepCopy(); Rule_String rule_String = rule as Rule_String; if (rule_String != null && num != 0) { rule_String.keyword = "sitePart" + num + "_" + rule_String.keyword; } list.Add(rule); } foreach (KeyValuePair <string, string> item in dictionary2) { string text2 = item.Key; if (num != 0) { text2 = "sitePart" + num + "_" + text2; } if (!dictionary.ContainsKey(text2)) { dictionary.Add(text2, item.Value); } } num++; } if (!list2.Any()) { list.Add(new Rule_String("allSitePartsDescriptions", "HiddenOrNoSitePartDescription".Translate())); list.Add(new Rule_String("allSitePartsDescriptionsExceptFirst", "HiddenOrNoSitePartDescription".Translate())); } else { list.Add(new Rule_String("allSitePartsDescriptions", list2.ToClauseSequence().Resolve())); if (list2.Count >= 2) { list.Add(new Rule_String("allSitePartsDescriptionsExceptFirst", list2.Skip(1).ToList().ToClauseSequence())); } else { list.Add(new Rule_String("allSitePartsDescriptionsExceptFirst", "HiddenOrNoSitePartDescription".Translate())); } } QuestGen.AddQuestDescriptionRules(list); QuestGen.AddQuestNameRules(list); QuestGen.AddQuestDescriptionConstants(dictionary); QuestGen.AddQuestNameConstants(dictionary); QuestGen.AddQuestNameRules(new List <Rule> { new Rule_String("site_label", site.Label) }); return(site); }
public override void PostRemoved() { base.PostRemoved(); if (this.realPawn == null) { this.realPawn = this.pawn as PsychologyPawn; } if (this.realPawn != null && this.otherPawn != null) { Hediff otherConvo = otherPawn.health.hediffSet.hediffs.Find(h => h is Hediff_Conversation && ((Hediff_Conversation)h).otherPawn == this.realPawn); if (otherConvo != null) { this.otherPawn.health.RemoveHediff(otherConvo); } string talkDesc; if (this.ageTicks < 500) { int numShortTalks = int.Parse("NumberOfShortTalks".Translate()); talkDesc = "ShortTalk" + Rand.RangeInclusive(1, numShortTalks); } else if (this.ageTicks < 1500) { int numNormalTalks = int.Parse("NumberOfNormalTalks".Translate()); talkDesc = "NormalTalk" + Rand.RangeInclusive(1, numNormalTalks); } else if (this.ageTicks < 5000) { int numLongTalks = int.Parse("NumberOfLongTalks".Translate()); talkDesc = "LongTalk" + Rand.RangeInclusive(1, numLongTalks); } else { int numEpicTalks = int.Parse("NumberOfEpicTalks".Translate()); talkDesc = "EpicTalk" + Rand.RangeInclusive(1, numEpicTalks); } //We create a dynamic def to hold this thought so that the game won't worry about it being used anywhere else. ThoughtDef def = new ThoughtDef(); def.defName = this.pawn.GetHashCode() + "Conversation" + topic.defName; def.label = topic.defName; def.durationDays = 60f; def.nullifyingTraits = new List <TraitDef>(); def.nullifyingTraits.Add(TraitDefOf.Psychopath); def.thoughtClass = typeof(Thought_MemorySocialDynamic); ThoughtStage stage = new ThoughtStage(); //Base opinion mod is 5 to the power of controversiality. float opinionMod = Mathf.Pow(5f, topic.controversiality); //Multiplied by difference between their personality ratings, on an exponential scale. opinionMod *= Mathf.Lerp(-1.25f, 1.25f, Mathf.Pow(1f - Mathf.Abs(this.realPawn.psyche.GetPersonalityRating(topic) - this.otherPawn.psyche.GetPersonalityRating(topic)), 3)); //Cool pawns are liked more. opinionMod += Mathf.Pow(2f, topic.controversiality) * (0.5f - this.otherPawn.psyche.GetPersonalityRating(PersonalityNodeDefOf.Cool)); //The length of the talk has a large impact on how much the pawn cares. opinionMod *= 5f * (this.ageTicks / (GenDate.TicksPerHour * 2.25f)); //talkModifier[talkLength] //If they had a bad experience, the more polite the pawn is, the less they're bothered by it. opinionMod *= (opinionMod < 0f ? 0.5f + (1f - this.otherPawn.psyche.GetPersonalityRating(PersonalityNodeDefOf.Polite)) : 1f); //The more judgmental the pawn, the more they're affected by all conversations. opinionMod *= 0.5f + this.realPawn.psyche.GetPersonalityRating(PersonalityNodeDefOf.Judgmental); if (opinionMod < 0f) { opinionMod *= PopulationModifier; } stage.label = "ConversationStage".Translate() + " " + topic.conversationTopic; stage.baseOpinionOffset = Mathf.RoundToInt(opinionMod); def.stages.Add(stage); /* The more they know about someone, the less likely small thoughts are to have an impact on their opinion. * This helps declutter the Social card without preventing pawns from having conversations. * They just won't change their mind about the colonist as a result. */ if (Rand.Value < Mathf.InverseLerp(0f, this.realPawn.psyche.TotalThoughtOpinion(this.otherPawn), 250f + Mathf.Abs(stage.baseOpinionOffset)) && stage.baseOpinionOffset != 0) { this.pawn.needs.mood.thoughts.memories.TryGainMemory(def, this.otherPawn); } if (this.waveGoodbye && this.pawn.Map != null) { InteractionDef endConversation = new InteractionDef(); endConversation.defName = "EndConversation"; RulePack goodbyeText = new RulePack(); FieldInfo RuleStrings = typeof(RulePack).GetField("rulesStrings", BindingFlags.Instance | BindingFlags.NonPublic); List <string> text = new List <string>(1); text.Add("logentry->" + talkDesc.Translate(topic.conversationTopic)); RuleStrings.SetValue(goodbyeText, text); endConversation.logRulesInitiator = goodbyeText; endConversation.logRulesRecipient = goodbyeText; FieldInfo Symbol = typeof(InteractionDef).GetField("symbol", BindingFlags.Instance | BindingFlags.NonPublic); Symbol.SetValue(endConversation, Symbol.GetValue(InteractionDefOf.DeepTalk)); PlayLogEntry_InteractionConversation log = new PlayLogEntry_InteractionConversation(endConversation, realPawn, this.otherPawn, new List <RulePackDef>()); Find.PlayLog.Add(log); MoteMaker.MakeInteractionBubble(this.pawn, this.otherPawn, InteractionDefOf.Chitchat.interactionMote, InteractionDefOf.Chitchat.Symbol); } } }
public static QuestPart_Letter Letter(this Quest quest, LetterDef letterDef, string inSignal = null, string chosenPawnSignal = null, Faction relatedFaction = null, MapParent useColonistsOnMap = null, bool useColonistsFromCaravanArg = false, QuestPart.SignalListenMode signalListenMode = QuestPart.SignalListenMode.OngoingOnly, IEnumerable <object> lookTargets = null, bool filterDeadPawnsFromLookTargets = false, string text = null, RulePack textRules = null, string label = null, RulePack labelRules = null, string getColonistsFromSignal = null) { Slate slate = QuestGen.slate; QuestPart_Letter questPart_Letter = new QuestPart_Letter(); questPart_Letter.inSignal = QuestGenUtility.HardcodedSignalWithQuestID(inSignal) ?? slate.Get <string>("inSignal"); LetterDef letterDef2 = letterDef ?? LetterDefOf.NeutralEvent; if (typeof(ChoiceLetter).IsAssignableFrom(letterDef2.letterClass)) { ChoiceLetter choiceLetter = LetterMaker.MakeLetter("error", "error", letterDef2, QuestGenUtility.ToLookTargets(lookTargets), relatedFaction, QuestGen.quest); questPart_Letter.letter = choiceLetter; QuestGen.AddTextRequest("root", delegate(string x) { choiceLetter.label = x; }, QuestGenUtility.MergeRules(labelRules, label, "root")); QuestGen.AddTextRequest("root", delegate(string x) { choiceLetter.text = x; }, QuestGenUtility.MergeRules(textRules, text, "root")); } else { questPart_Letter.letter = LetterMaker.MakeLetter(letterDef2); questPart_Letter.letter.lookTargets = QuestGenUtility.ToLookTargets(lookTargets); questPart_Letter.letter.relatedFaction = relatedFaction; } questPart_Letter.chosenPawnSignal = QuestGenUtility.HardcodedSignalWithQuestID(chosenPawnSignal); questPart_Letter.useColonistsOnMap = useColonistsOnMap; questPart_Letter.useColonistsFromCaravanArg = useColonistsFromCaravanArg; questPart_Letter.signalListenMode = signalListenMode; questPart_Letter.filterDeadPawnsFromLookTargets = filterDeadPawnsFromLookTargets; questPart_Letter.getColonistsFromSignal = getColonistsFromSignal; QuestGen.quest.AddPart(questPart_Letter); return(questPart_Letter); }