protected override GrammarRequest GenerateGrammarRequest() { GrammarRequest result = base.GenerateGrammarRequest(); if (subjectPawn != null) { result.Rules.AddRange(GrammarUtility.RulesForPawn("SUBJECT", subjectPawn, result.Constants)); } else if (subjectThing != null) { result.Rules.AddRange(GrammarUtility.RulesForDef("SUBJECT", subjectThing)); } result.Includes.Add(transitionDef); if (initiator != null) { result.Rules.AddRange(GrammarUtility.RulesForPawn("INITIATOR", initiator, result.Constants)); } if (culpritHediffDef != null) { result.Rules.AddRange(GrammarUtility.RulesForHediffDef("CULPRITHEDIFF", culpritHediffDef, culpritHediffTargetPart)); } if (culpritHediffTargetPart != null) { result.Rules.AddRange(GrammarUtility.RulesForBodyPartRecord("CULPRITHEDIFF_target", culpritHediffTargetPart)); } if (culpritTargetPart != null) { result.Rules.AddRange(GrammarUtility.RulesForBodyPartRecord("CULPRITHEDIFF_originaltarget", culpritTargetPart)); } return(result); }
protected override GrammarRequest GenerateGrammarRequest() { GrammarRequest result = base.GenerateGrammarRequest(); result.Rules.AddRange(GrammarUtility.RulesForPawn("INITIATOR", this.initiator, result.Constants)); if (this.recipientPawn != null) { result.Rules.AddRange(GrammarUtility.RulesForPawn("RECIPIENT", this.recipientPawn, result.Constants)); } else if (this.recipientThing != null) { result.Rules.AddRange(GrammarUtility.RulesForDef("RECIPIENT", this.recipientThing)); } result.Includes.Add(this.ruleDef); if (!this.toolLabel.NullOrEmpty()) { result.Rules.Add(new Rule_String("TOOL_label", this.toolLabel)); } if (this.implementType != null && !this.implementType.implementOwnerRuleName.NullOrEmpty()) { if (this.ownerEquipmentDef != null) { result.Rules.AddRange(GrammarUtility.RulesForDef(this.implementType.implementOwnerRuleName, this.ownerEquipmentDef)); } else if (this.ownerHediffDef != null) { result.Rules.AddRange(GrammarUtility.RulesForDef(this.implementType.implementOwnerRuleName, this.ownerHediffDef)); } } if (this.implementType != null && !this.implementType.implementOwnerTypeValue.NullOrEmpty()) { result.Constants["IMPLEMENTOWNER_type"] = this.implementType.implementOwnerTypeValue; } return(result); }
public override void Notify_GeneratedByQuestGen(SitePart part, Slate slate, List <Rule> outExtraDescriptionRules, Dictionary <string, string> outExtraDescriptionConstants) { // Duplicate code so modularize in Util Util.SitePartWorker_Base_Notify_GeneratedByQuestGen(part, outExtraDescriptionRules, outExtraDescriptionConstants); // Replaces PrisonerWillingToJoinQuestUtility.GeneratePrisoner Pawn pawn = GameComponent.GetRandomAllyForSpawning(); pawn.guest.SetGuestStatus(part.site.Faction, true); Util.DressPawnIfCold(pawn, part.site.Tile); part.things = new ThingOwner <Pawn>(part, true, LookMode.Deep); part.things.TryAdd(pawn, true); string text; PawnRelationUtility.Notify_PawnsSeenByPlayer(Gen.YieldSingle <Pawn>(pawn), out text, true, false); outExtraDescriptionRules.AddRange(GrammarUtility.RulesForPawn("prisoner", pawn, outExtraDescriptionConstants, true, true)); string output; if (!text.NullOrEmpty()) { output = "\n\n" + "PawnHasTheseRelationshipsWithColonists".Translate(pawn.LabelShort, pawn) + "\n\n" + text; } else { output = ""; } outExtraDescriptionRules.Add(new Rule_String("prisonerFullRelationInfo", output)); }
protected override string ToGameStringFromPOV_Worker(Thing pov, bool forceLog) { string result; if (this.initiator == null || this.recipient == null) { Log.ErrorOnce("PlayLogEntry_Interaction has a null pawn reference.", 34422, false); result = "[" + this.intDef.label + " error: null pawn reference]"; } else { Rand.PushState(); Rand.Seed = this.logID; GrammarRequest request = base.GenerateGrammarRequest(); string text; if (pov == this.initiator) { request.IncludesBare.Add(this.intDef.logRulesInitiator); request.Rules.AddRange(GrammarUtility.RulesForPawn("ME", this.initiator, request.Constants)); request.Rules.AddRange(GrammarUtility.RulesForPawn("OTHER", this.recipient, request.Constants)); request.Rules.AddRange(GrammarUtility.RulesForPawn("INITIATOR", this.initiator, request.Constants)); request.Rules.AddRange(GrammarUtility.RulesForPawn("RECIPIENT", this.recipient, request.Constants)); text = GrammarResolver.Resolve("r_logentry", request, "interaction from initiator", forceLog); } else if (pov == this.recipient) { if (this.intDef.logRulesRecipient != null) { request.IncludesBare.Add(this.intDef.logRulesRecipient); } else { request.IncludesBare.Add(this.intDef.logRulesInitiator); } request.Rules.AddRange(GrammarUtility.RulesForPawn("ME", this.recipient, request.Constants)); request.Rules.AddRange(GrammarUtility.RulesForPawn("OTHER", this.initiator, request.Constants)); request.Rules.AddRange(GrammarUtility.RulesForPawn("INITIATOR", this.initiator, request.Constants)); request.Rules.AddRange(GrammarUtility.RulesForPawn("RECIPIENT", this.recipient, request.Constants)); text = GrammarResolver.Resolve("r_logentry", request, "interaction from recipient", forceLog); } else { Log.ErrorOnce("Cannot display PlayLogEntry_Interaction from POV who isn't initiator or recipient.", 51251, false); text = this.ToString(); } if (this.extraSentencePacks != null) { for (int i = 0; i < this.extraSentencePacks.Count; i++) { request.Clear(); request.Includes.Add(this.extraSentencePacks[i]); request.Rules.AddRange(GrammarUtility.RulesForPawn("INITIATOR", this.initiator, request.Constants)); request.Rules.AddRange(GrammarUtility.RulesForPawn("RECIPIENT", this.recipient, request.Constants)); text = text + " " + GrammarResolver.Resolve(this.extraSentencePacks[i].RulesPlusIncludes[0].keyword, request, "extraSentencePack", forceLog); } } Rand.PopState(); result = text; } return result; }
public static string History(Faction subject = null, Faction victim = null, Settlement town = null, Pawn pawn = null, string towndestroyed = null) { GrammarRequest request = new GrammarRequest(); request.Includes.Add(EndGameDefOf.FE_History); if (pawn != null) { request.Rules.AddRange(GrammarUtility.RulesForPawn("Pawn", pawn)); return(GrammarResolver.Resolve("r_history_pawn", request, null, false, null)); } if (town != null) { request.Rules.AddRange(RulesForTown("AffectedTown", town)); return(GrammarResolver.Resolve("r_history_town", request, null, false, null)); } if (subject != null && victim != null) { request.Rules.AddRange(GrammarUtility.RulesForFaction("FACTION1", subject)); request.Rules.AddRange(GrammarUtility.RulesForFaction("FACTION2", victim)); return(GrammarResolver.Resolve("r_history_faction", request, null, false, null)); } if (subject != null) { request.Rules.AddRange(GrammarUtility.RulesForFaction("FACTION1", subject)); request.Rules.AddRange(RulesForString("FACTION2", NameGenerator.GenerateName(subject.def.factionNameMaker, Find.FactionManager.AllFactionsVisible.Select(fac => fac.Name)))); return(GrammarResolver.Resolve("r_history_factiondead", request, null, false, null)); } if (towndestroyed != null) { request.Rules.AddRange(RulesForString("AffectedTown", towndestroyed)); return(GrammarResolver.Resolve("r_history_townDestroyed", request, null, false, null)); } return(GrammarResolver.Resolve("r_history_generic", request, null, false, null)); }
protected override GrammarRequest GenerateGrammarRequest() { GrammarRequest result = base.GenerateGrammarRequest(); if (this.recipientPawn != null || this.recipientThing != null) { result.Includes.Add((!this.deflected) ? RulePackDefOf.Combat_RangedDamage : RulePackDefOf.Combat_RangedDeflect); } else { result.Includes.Add(RulePackDefOf.Combat_RangedMiss); } if (this.initiatorPawn != null) { result.Rules.AddRange(GrammarUtility.RulesForPawn("INITIATOR", this.initiatorPawn, result.Constants)); } else if (this.initiatorThing != null) { result.Rules.AddRange(GrammarUtility.RulesForDef("INITIATOR", this.initiatorThing)); } else { result.Constants["INITIATOR_missing"] = "True"; } if (this.recipientPawn != null) { result.Rules.AddRange(GrammarUtility.RulesForPawn("RECIPIENT", this.recipientPawn, result.Constants)); } else if (this.recipientThing != null) { result.Rules.AddRange(GrammarUtility.RulesForDef("RECIPIENT", this.recipientThing)); } else { result.Constants["RECIPIENT_missing"] = "True"; } if (this.originalTargetPawn != this.recipientPawn || this.originalTargetThing != this.recipientThing) { if (this.originalTargetPawn != null) { result.Rules.AddRange(GrammarUtility.RulesForPawn("ORIGINALTARGET", this.originalTargetPawn, result.Constants)); result.Constants["ORIGINALTARGET_mobile"] = this.originalTargetMobile.ToString(); } else if (this.originalTargetThing != null) { result.Rules.AddRange(GrammarUtility.RulesForDef("ORIGINALTARGET", this.originalTargetThing)); } else { result.Constants["ORIGINALTARGET_missing"] = "True"; } } result.Rules.AddRange(PlayLogEntryUtility.RulesForOptionalWeapon("WEAPON", this.weaponDef, this.projectileDef)); result.Constants["COVER_missing"] = ((this.coverDef == null) ? "True" : "False"); if (this.coverDef != null) { result.Rules.AddRange(GrammarUtility.RulesForDef("COVER", this.coverDef)); } return(result); }
public static string AdjustedFor(this string text, Pawn p, string pawnSymbol = "PAWN") { GrammarRequest request = default(GrammarRequest); request.Includes.Add(RulePackDefOf.DynamicWrapper); request.Rules.Add(new Rule_String("RULE", text)); request.Rules.AddRange(GrammarUtility.RulesForPawn(pawnSymbol, p, null)); return(GrammarResolver.Resolve("r_root", request, null, false, null)); }
protected override GrammarRequest GenerateGrammarRequest() { GrammarRequest result = base.GenerateGrammarRequest(); if (recipientPawn == null) { Log.ErrorOnce("BattleLogEntry_DamageTaken has a null recipient.", 60465709); } result.Includes.Add(ruleDef); result.Rules.AddRange(GrammarUtility.RulesForPawn("RECIPIENT", recipientPawn, result.Constants)); return(result); }
protected override GrammarRequest GenerateGrammarRequest() { GrammarRequest result = base.GenerateGrammarRequest(); if (initiatorPawn == null && initiatorThing == null) { Log.ErrorOnce("BattleLogEntry_RangedFire has a null initiator.", 60465709); } if (weaponDef != null && weaponDef.Verbs[0].rangedFireRulepack != null) { result.Includes.Add(weaponDef.Verbs[0].rangedFireRulepack); } else { result.Includes.Add(RulePackDefOf.Combat_RangedFire); } if (initiatorPawn != null) { result.Rules.AddRange(GrammarUtility.RulesForPawn("INITIATOR", initiatorPawn, result.Constants)); } else if (initiatorThing != null) { result.Rules.AddRange(GrammarUtility.RulesForDef("INITIATOR", initiatorThing)); } else { result.Constants["INITIATOR_missing"] = "True"; } if (recipientPawn != null) { result.Rules.AddRange(GrammarUtility.RulesForPawn("RECIPIENT", recipientPawn, result.Constants)); } else if (recipientThing != null) { result.Rules.AddRange(GrammarUtility.RulesForDef("RECIPIENT", recipientThing)); } else { result.Constants["RECIPIENT_missing"] = "True"; } result.Rules.AddRange(PlayLogEntryUtility.RulesForOptionalWeapon("WEAPON", weaponDef, projectileDef)); if (initiatorPawn != null && initiatorPawn.skills != null) { result.Constants["INITIATOR_skill"] = initiatorPawn.skills.GetSkill(SkillDefOf.Shooting).Level.ToStringCached(); } if (recipientPawn != null && recipientPawn.skills != null) { result.Constants["RECIPIENT_skill"] = recipientPawn.skills.GetSkill(SkillDefOf.Shooting).Level.ToStringCached(); } result.Constants["BURST"] = burst.ToString(); return(result); }
public override string ToGameStringFromPOV(Thing pov) { if (this.initiator == null || this.recipient == null) { Log.ErrorOnce("PlayLogEntry_Interaction has a null pawn reference.", 34422); return("[" + this.intDef.label + " error: null pawn reference]"); } Rand.PushState(); Rand.Seed = this.randSeed; GrammarRequest request = default(GrammarRequest); string text; if (pov == this.initiator) { request.Rules.AddRange(this.intDef.logRulesInitiator.Rules); request.Rules.AddRange(GrammarUtility.RulesForPawn("me", this.initiator, request.Constants)); request.Rules.AddRange(GrammarUtility.RulesForPawn("other", this.recipient, request.Constants)); text = GrammarResolver.Resolve("logentry", request, "interaction from initiator", false); } else if (pov == this.recipient) { if (this.intDef.logRulesRecipient != null) { request.Rules.AddRange(this.intDef.logRulesRecipient.Rules); } else { request.Rules.AddRange(this.intDef.logRulesInitiator.Rules); } request.Rules.AddRange(GrammarUtility.RulesForPawn("me", this.recipient, request.Constants)); request.Rules.AddRange(GrammarUtility.RulesForPawn("other", this.initiator, request.Constants)); text = GrammarResolver.Resolve("logentry", request, "interaction from recipient", false); } else { Log.ErrorOnce("Cannot display PlayLogEntry_Interaction from POV who isn't initiator or recipient.", 51251); text = this.ToString(); } if (this.extraSentencePacks != null) { for (int i = 0; i < this.extraSentencePacks.Count; i++) { request.Clear(); request.Includes.Add(this.extraSentencePacks[i]); request.Rules.AddRange(GrammarUtility.RulesForPawn("initiator", this.initiator, request.Constants)); request.Rules.AddRange(GrammarUtility.RulesForPawn("recipient", this.recipient, request.Constants)); text = text + " " + GrammarResolver.Resolve(this.extraSentencePacks[i].RulesPlusIncludes[0].keyword, request, "extraSentencePack", false); } } Rand.PopState(); return(text); }
protected override string ToGameStringFromPOV_Worker(Thing pov, bool forceLog) { if (initiator == null || recipient == null) { Log.ErrorOnce("PlayLogEntry_Interaction has a null pawn reference.", 34422); return("[" + intDef.label + " error: null pawn reference]"); } Rand.PushState(); Rand.Seed = logID; GrammarRequest request = base.GenerateGrammarRequest(); string text; if (pov == initiator) { request.IncludesBare.Add(intDef.logRulesInitiator); request.Rules.AddRange(GrammarUtility.RulesForPawn("INITIATOR", initiator, request.Constants)); request.Rules.AddRange(GrammarUtility.RulesForPawn("RECIPIENT", recipient, request.Constants)); text = GrammarResolver.Resolve("r_logentry", request, "interaction from initiator", forceLog); } else if (pov == recipient) { if (intDef.logRulesRecipient != null) { request.IncludesBare.Add(intDef.logRulesRecipient); } else { request.IncludesBare.Add(intDef.logRulesInitiator); } request.Rules.AddRange(GrammarUtility.RulesForPawn("INITIATOR", initiator, request.Constants)); request.Rules.AddRange(GrammarUtility.RulesForPawn("RECIPIENT", recipient, request.Constants)); text = GrammarResolver.Resolve("r_logentry", request, "interaction from recipient", forceLog); } else { Log.ErrorOnce("Cannot display PlayLogEntry_Interaction from POV who isn't initiator or recipient.", 51251); text = ToString(); } if (extraSentencePacks != null) { for (int i = 0; i < extraSentencePacks.Count; i++) { request.Clear(); request.Includes.Add(extraSentencePacks[i]); request.Rules.AddRange(GrammarUtility.RulesForPawn("INITIATOR", initiator, request.Constants)); request.Rules.AddRange(GrammarUtility.RulesForPawn("RECIPIENT", recipient, request.Constants)); text = text + " " + GrammarResolver.Resolve(extraSentencePacks[i].FirstRuleKeyword, request, "extraSentencePack", forceLog, extraSentencePacks[i].FirstUntranslatedRuleKeyword); } } Rand.PopState(); return(text); }
public override string ToGameStringFromPOV(Thing pov) { Rand.PushState(); Rand.Seed = base.randSeed; GrammarRequest request = default(GrammarRequest); request.Includes.Add(RulePackDefOf.Combat_ExplosionImpact); if (this.initiatorPawn != null) { request.Rules.AddRange(GrammarUtility.RulesForPawn("initiator", this.initiatorPawn, request.Constants)); } else if (this.initiatorThing != null) { request.Rules.AddRange(GrammarUtility.RulesForDef("initiator", this.initiatorThing)); } else { request.Constants["initiator_missing"] = "True"; } if (this.recipientPawn != null) { request.Rules.AddRange(GrammarUtility.RulesForPawn("recipient", this.recipientPawn, request.Constants)); } else if (this.recipientThing != null) { request.Rules.AddRange(GrammarUtility.RulesForDef("recipient", this.recipientThing)); } else { request.Constants["recipient_missing"] = "True"; } request.Rules.AddRange(PlayLogEntryUtility.RulesForOptionalWeapon("weapon", this.weaponDef, this.projectileDef)); if (this.projectileDef != null) { request.Rules.AddRange(GrammarUtility.RulesForDef("projectile", this.projectileDef)); } if (this.damageDef != null && this.damageDef.combatLogRules != null) { request.Includes.Add(this.damageDef.combatLogRules); } request.Rules.AddRange(PlayLogEntryUtility.RulesForDamagedParts("recipient_part", this.damagedParts, this.damagedPartsDestroyed, request.Constants)); string result = GrammarResolver.Resolve("logentry", request, "ranged explosion", false); Rand.PopState(); return(result); }
protected override GrammarRequest GenerateGrammarRequest() { GrammarRequest result = base.GenerateGrammarRequest(); result.Rules.AddRange(GrammarUtility.RulesForPawn("INITIATOR", initiator, result.Constants)); if (recipientPawn != null) { result.Rules.AddRange(GrammarUtility.RulesForPawn("RECIPIENT", recipientPawn, result.Constants)); } else if (recipientThing != null) { result.Rules.AddRange(GrammarUtility.RulesForDef("RECIPIENT", recipientThing)); } result.Includes.Add(ruleDef); if (!toolLabel.NullOrEmpty()) { result.Rules.Add(new Rule_String("TOOL_label", toolLabel)); result.Rules.Add(new Rule_String("TOOL_definite", Find.ActiveLanguageWorker.WithDefiniteArticle(toolLabel))); result.Rules.Add(new Rule_String("TOOL_indefinite", Find.ActiveLanguageWorker.WithIndefiniteArticle(toolLabel))); result.Constants["TOOL_gender"] = LanguageDatabase.activeLanguage.ResolveGender(toolLabel).ToString(); } if (implementType != null && !implementType.implementOwnerRuleName.NullOrEmpty()) { if (ownerEquipmentDef != null) { result.Rules.AddRange(GrammarUtility.RulesForDef(implementType.implementOwnerRuleName, ownerEquipmentDef)); } else if (ownerHediffDef != null) { result.Rules.AddRange(GrammarUtility.RulesForDef(implementType.implementOwnerRuleName, ownerHediffDef)); } } if (initiator != null && initiator.skills != null) { result.Constants["INITIATOR_skill"] = initiator.skills.GetSkill(SkillDefOf.Melee).Level.ToStringCached(); } if (recipientPawn != null && recipientPawn.skills != null) { result.Constants["RECIPIENT_skill"] = recipientPawn.skills.GetSkill(SkillDefOf.Melee).Level.ToStringCached(); } if (implementType != null && !implementType.implementOwnerTypeValue.NullOrEmpty()) { result.Constants["IMPLEMENTOWNER_type"] = implementType.implementOwnerTypeValue; } return(result); }
protected override GrammarRequest GenerateGrammarRequest() { GrammarRequest result = base.GenerateGrammarRequest(); if (this.initiatorPawn == null && this.initiatorThing == null) { Log.ErrorOnce("BattleLogEntry_RangedFire has a null initiator.", 60465709, false); } if (this.weaponDef != null && this.weaponDef.Verbs[0].rangedFireRulepack != null) { result.Includes.Add(this.weaponDef.Verbs[0].rangedFireRulepack); } else { result.Includes.Add(RulePackDefOf.Combat_RangedFire); } if (this.initiatorPawn != null) { result.Rules.AddRange(GrammarUtility.RulesForPawn("INITIATOR", this.initiatorPawn, result.Constants)); } else if (this.initiatorThing != null) { result.Rules.AddRange(GrammarUtility.RulesForDef("INITIATOR", this.initiatorThing)); } else { result.Constants["INITIATOR_missing"] = "True"; } if (this.recipientPawn != null) { result.Rules.AddRange(GrammarUtility.RulesForPawn("RECIPIENT", this.recipientPawn, result.Constants)); } else if (this.recipientThing != null) { result.Rules.AddRange(GrammarUtility.RulesForDef("RECIPIENT", this.recipientThing)); } else { result.Constants["RECIPIENT_missing"] = "True"; } result.Rules.AddRange(PlayLogEntryUtility.RulesForOptionalWeapon("WEAPON", this.weaponDef, this.projectileDef)); result.Constants["BURST"] = this.burst.ToString(); return(result); }
/// <summary> /// create the main log text /// </summary> /// <param name="pov">The pov.</param> /// <param name="forceLog">if set to <c>true</c> [force log].</param> /// <returns></returns> protected override string ToGameStringFromPOV_Worker(Thing pov, bool forceLog) { Assert(pov == _pawn, "pov == _pawn"); Rand.PushState(logID); // Does not need a MP-safe seed. try { GrammarRequest grammarRequest = GenerateGrammarRequest(); RulePackDef mutationRulePack = (_mutationDef as MutationDef)?.mutationLogRulePack; if (mutationRulePack != null) { grammarRequest.Includes.Add(mutationRulePack); } else { grammarRequest.Includes.Add(PMRulePackDefOf.GetDefaultPackForMutation(_mutationDef)); grammarRequest.Rules.Add(new Rule_String("DATE", GenDate.DateFullStringAt(ticksAbs, Vector2.zero))); } AddCustomRules(grammarRequest.Rules); IEnumerable <Rule> pawnR = GrammarUtility.RulesForPawn(PAWN_IDENTIFIER, _pawn, grammarRequest.Constants); BodyPartRecord partR = BodyDefOf.Human.AllParts.Where(r => _mutatedRecords.Contains(r.def)).RandomElement(); IEnumerable <Rule> partRules = GrammarUtility.RulesForBodyPartRecord(PART_LABEL, partR); IEnumerable <Rule> mutR = GrammarUtility.RulesForHediffDef(MUTATION_IDENTIFIER, _mutationDef, partR); // Add the rules. grammarRequest.Rules.AddRange(pawnR); grammarRequest.Rules.AddRange(mutR); grammarRequest.Rules.AddRange(partRules); return(GrammarResolver.Resolve(RP_ROOT_RULE, grammarRequest, "mutation log", forceLog)); } catch (Exception exception) { Log.Error($"encountered {exception.GetType().Name} exception while generating string for mutation log\n\t{exception}"); } finally { Rand.PopState(); // Make sure to always pop rand. } return(_mutationDef.LabelCap); //TODO generate string }
public override string ToGameStringFromPOV(Thing pov) { if (this.recipientPawn == null) { Log.ErrorOnce("BattleLogEntry_DamageTaken has a null recipient.", 60465709); return("[BattleLogEntry_DamageTaken error: null pawn reference]"); } Rand.PushState(); Rand.Seed = base.randSeed; GrammarRequest request = default(GrammarRequest); request.Includes.Add(this.ruleDef); request.Rules.AddRange(GrammarUtility.RulesForPawn("recipient", this.recipientPawn, request.Constants)); request.Rules.AddRange(PlayLogEntryUtility.RulesForDamagedParts("recipient_part", this.damagedParts, this.damagedPartsDestroyed, request.Constants)); string result = GrammarResolver.Resolve("logentry", request, "damage taken", false); Rand.PopState(); return(result); }
public override string ToGameStringFromPOV(Thing pov) { if (this.initiatorPawn == null && this.initiatorThing == null) { Log.ErrorOnce("BattleLogEntry_RangedFire has a null initiator.", 60465709); return("[BattleLogEntry_RangedFire error: null pawn reference]"); } Rand.PushState(); Rand.Seed = base.randSeed; GrammarRequest request = default(GrammarRequest); request.Includes.Add(RulePackDefOf.Combat_RangedFire); if (this.initiatorPawn != null) { request.Rules.AddRange(GrammarUtility.RulesForPawn("initiator", this.initiatorPawn, request.Constants)); } else if (this.initiatorThing != null) { request.Rules.AddRange(GrammarUtility.RulesForDef("initiator", this.initiatorThing)); } else { request.Constants["initiator_missing"] = "True"; } if (this.recipientPawn != null) { request.Rules.AddRange(GrammarUtility.RulesForPawn("recipient", this.recipientPawn, request.Constants)); } else if (this.recipientThing != null) { request.Rules.AddRange(GrammarUtility.RulesForDef("recipient", this.recipientThing)); } else { request.Constants["recipient_missing"] = "True"; } request.Rules.AddRange(PlayLogEntryUtility.RulesForOptionalWeapon("weapon", this.weaponDef, this.projectileDef)); request.Constants["burst"] = this.burst.ToString(); string result = GrammarResolver.Resolve("logentry", request, "ranged fire", false); Rand.PopState(); return(result); }
public string GetName() { if (this.battleName.NullOrEmpty()) { HashSet <Faction> hashSet = new HashSet <Faction>(from p in this.concerns select p.Faction); GrammarRequest request = default(GrammarRequest); if (this.concerns.Count == 1) { if (hashSet.Count((Faction f) => f != null) < 2) { request.Includes.Add(RulePackDefOf.Battle_Solo); request.Rules.AddRange(GrammarUtility.RulesForPawn("PARTICIPANT1", this.concerns.First <Pawn>(), null)); goto IL_1CC; } } if (this.concerns.Count == 2) { request.Includes.Add(RulePackDefOf.Battle_Duel); request.Rules.AddRange(GrammarUtility.RulesForPawn("PARTICIPANT1", this.concerns.First <Pawn>(), null)); request.Rules.AddRange(GrammarUtility.RulesForPawn("PARTICIPANT2", this.concerns.Last <Pawn>(), null)); } else if (hashSet.Count == 1) { request.Includes.Add(RulePackDefOf.Battle_Internal); request.Rules.AddRange(GrammarUtility.RulesForFaction("FACTION1", hashSet.First <Faction>())); } else if (hashSet.Count == 2) { request.Includes.Add(RulePackDefOf.Battle_War); request.Rules.AddRange(GrammarUtility.RulesForFaction("FACTION1", hashSet.First <Faction>())); request.Rules.AddRange(GrammarUtility.RulesForFaction("FACTION2", hashSet.Last <Faction>())); } else { request.Includes.Add(RulePackDefOf.Battle_Brawl); } IL_1CC: this.battleName = GrammarResolver.Resolve("r_battlename", request, null, false, null); } return(this.battleName); }
public override string ToGameStringFromPOV(Thing pov) { Rand.PushState(); Rand.Seed = base.randSeed; GrammarRequest request = default(GrammarRequest); request.Rules.AddRange(GrammarUtility.RulesForPawn("initiator", this.initiator, request.Constants)); if (this.recipientPawn != null) { request.Rules.AddRange(GrammarUtility.RulesForPawn("recipient", this.recipientPawn, request.Constants)); } else if (this.recipientThing != null) { request.Rules.AddRange(GrammarUtility.RulesForDef("recipient", this.recipientThing)); } request.Includes.Add(this.outcomeRuleDef); request.Includes.Add(this.maneuverRuleDef); if (!this.toolLabel.NullOrEmpty()) { request.Rules.Add(new Rule_String("tool_label", this.toolLabel)); } if (this.implementType != null && !this.implementType.implementOwnerRuleName.NullOrEmpty()) { if (this.ownerEquipmentDef != null) { request.Rules.AddRange(GrammarUtility.RulesForDef(this.implementType.implementOwnerRuleName, this.ownerEquipmentDef)); } else if (this.ownerHediffDef != null) { request.Rules.AddRange(GrammarUtility.RulesForDef(this.implementType.implementOwnerRuleName, this.ownerHediffDef)); } } if (this.implementType != null && !this.implementType.implementOwnerTypeValue.NullOrEmpty()) { request.Constants["implementOwnerType"] = this.implementType.implementOwnerTypeValue; } request.Rules.AddRange(PlayLogEntryUtility.RulesForDamagedParts("recipient_part", this.damagedParts, this.damagedPartsDestroyed, request.Constants)); string result = GrammarResolver.Resolve("logentry", request, "combat interaction", false); Rand.PopState(); return(result); }
protected override GrammarRequest GenerateGrammarRequest() { GrammarRequest result = base.GenerateGrammarRequest(); result.Includes.Add(RulePackDefOf.Combat_ExplosionImpact); if (this.initiatorPawn != null) { result.Rules.AddRange(GrammarUtility.RulesForPawn("INITIATOR", this.initiatorPawn, result.Constants)); } else if (this.initiatorThing != null) { result.Rules.AddRange(GrammarUtility.RulesForDef("INITIATOR", this.initiatorThing)); } else { result.Constants["INITIATOR_missing"] = "True"; } if (this.recipientPawn != null) { result.Rules.AddRange(GrammarUtility.RulesForPawn("RECIPIENT", this.recipientPawn, result.Constants)); } else if (this.recipientThing != null) { result.Rules.AddRange(GrammarUtility.RulesForDef("RECIPIENT", this.recipientThing)); } else { result.Constants["RECIPIENT_missing"] = "True"; } result.Rules.AddRange(PlayLogEntryUtility.RulesForOptionalWeapon("WEAPON", this.weaponDef, this.projectileDef)); if (this.projectileDef != null) { result.Rules.AddRange(GrammarUtility.RulesForDef("PROJECTILE", this.projectileDef)); } if (this.damageDef != null && this.damageDef.combatLogRules != null) { result.Includes.Add(this.damageDef.combatLogRules); } return(result); }
public override void Notify_GeneratedByQuestGen(SitePart part, Slate slate, List <Rule> outExtraDescriptionRules, Dictionary <string, string> outExtraDescriptionConstants) { // Duplicate code so modularize in Util Util.SitePartWorker_Base_Notify_GeneratedByQuestGen(part, outExtraDescriptionRules, outExtraDescriptionConstants); // Replaces DownedRefugeeQuestUtility.GenerateRefugee Pawn pawn = GameComponent.GetRandomAllyForSpawning(); Util.DressPawnIfCold(pawn, part.site.Tile); HealthUtility.DamageUntilDowned(pawn, false); HealthUtility.DamageLegsUntilIncapableOfMoving(pawn, false); part.things = new ThingOwner <Pawn>(part, true, LookMode.Deep); part.things.TryAdd(pawn, true); if (pawn.relations != null) { pawn.relations.everSeenByPlayer = true; } Pawn mostImportantColonyRelative = PawnRelationUtility.GetMostImportantColonyRelative(pawn); if (mostImportantColonyRelative != null) { PawnRelationDef mostImportantRelation = mostImportantColonyRelative.GetMostImportantRelation(pawn); TaggedString taggedString = ""; if (mostImportantRelation != null && mostImportantRelation.opinionOffset > 0) { pawn.relations.relativeInvolvedInRescueQuest = mostImportantColonyRelative; taggedString = "\n\n" + "RelatedPawnInvolvedInQuest".Translate(mostImportantColonyRelative.LabelShort, mostImportantRelation.GetGenderSpecificLabel(pawn), mostImportantColonyRelative.Named("RELATIVE"), pawn.Named("PAWN")).AdjustedFor(pawn, "PAWN", true); } else { PawnRelationUtility.TryAppendRelationsWithColonistsInfo(ref taggedString, pawn); } outExtraDescriptionRules.Add(new Rule_String("pawnInvolvedInQuestInfo", taggedString)); } outExtraDescriptionRules.AddRange(GrammarUtility.RulesForPawn("refugee", pawn, outExtraDescriptionConstants, true, true)); }
protected override GrammarRequest GenerateGrammarRequest() { GrammarRequest result = base.GenerateGrammarRequest(); result.Includes.Add(this.eventDef); if (this.subjectPawn != null) { result.Rules.AddRange(GrammarUtility.RulesForPawn("SUBJECT", this.subjectPawn, result.Constants)); } else if (this.subjectThing != null) { result.Rules.AddRange(GrammarUtility.RulesForDef("SUBJECT", this.subjectThing)); } if (this.initiatorPawn != null) { result.Rules.AddRange(GrammarUtility.RulesForPawn("INITIATOR", this.initiatorPawn, result.Constants)); } else if (this.initiatorThing != null) { result.Rules.AddRange(GrammarUtility.RulesForDef("INITIATOR", this.initiatorThing)); } return(result); }
public string GetName() { if (battleName.NullOrEmpty()) { HashSet <Faction> hashSet = new HashSet <Faction>(concerns.Select((Pawn p) => p.Faction)); GrammarRequest request = default(GrammarRequest); if (concerns.Count == 1 && hashSet.Count((Faction f) => f != null) < 2) { request.Includes.Add(RulePackDefOf.Battle_Solo); request.Rules.AddRange(GrammarUtility.RulesForPawn("PARTICIPANT1", concerns.First())); } else if (concerns.Count == 2) { request.Includes.Add(RulePackDefOf.Battle_Duel); request.Rules.AddRange(GrammarUtility.RulesForPawn("PARTICIPANT1", concerns.First())); request.Rules.AddRange(GrammarUtility.RulesForPawn("PARTICIPANT2", concerns.Last())); } else if (hashSet.Count == 1) { request.Includes.Add(RulePackDefOf.Battle_Internal); request.Rules.AddRange(GrammarUtility.RulesForFaction("FACTION1", hashSet.First())); } else if (hashSet.Count == 2) { request.Includes.Add(RulePackDefOf.Battle_War); request.Rules.AddRange(GrammarUtility.RulesForFaction("FACTION1", hashSet.First())); request.Rules.AddRange(GrammarUtility.RulesForFaction("FACTION2", hashSet.Last())); } else { request.Includes.Add(RulePackDefOf.Battle_Brawl); } battleName = GrammarResolver.Resolve("r_battlename", request); } return(battleName); }
public override string ToGameStringFromPOV(Thing pov) { Rand.PushState(); Rand.Seed = base.randSeed; GrammarRequest request = default(GrammarRequest); if (this.subjectPawn != null) { request.Rules.AddRange(GrammarUtility.RulesForPawn("subject", this.subjectPawn, request.Constants)); } else if (this.subjectThing != null) { request.Rules.AddRange(GrammarUtility.RulesForDef("subject", this.subjectThing)); } request.Includes.Add(this.transitionDef); if (this.initiator != null) { request.Rules.AddRange(GrammarUtility.RulesForPawn("initiator", this.initiator, request.Constants)); } if (this.culpritHediffDef != null) { request.Rules.AddRange(GrammarUtility.RulesForDef("culpritHediff", this.culpritHediffDef)); } if (this.culpritHediffTargetDef != null) { request.Rules.AddRange(GrammarUtility.RulesForDef("culpritHediff_target", this.culpritHediffTargetDef)); } if (this.culpritTargetDef != null) { request.Rules.AddRange(GrammarUtility.RulesForDef("culpritHediff_originaltarget", this.culpritTargetDef)); } string result = GrammarResolver.Resolve("logentry", request, "state transition", false); Rand.PopState(); return(result); }
public override IEnumerable <Rule> GetRules(string prefix) { return(GrammarUtility.RulesForPawn(prefix, name, title, kind, gender, faction, age, chronologicalAge, relationInfo, everBeenColonistOrTameAnimal, everBeenQuestLodger, isFactionLeader, royalTitles)); }
public override IEnumerable <Rule> GetRules(string prefix) { return(GrammarUtility.RulesForPawn(prefix, name, title, kind, gender, faction)); }
protected override GrammarRequest GenerateGrammarRequest() { GrammarRequest result = base.GenerateGrammarRequest(); if (recipientPawn != null || recipientThing != null) { result.Includes.Add(deflected ? RulePackDefOf.Combat_RangedDeflect : RulePackDefOf.Combat_RangedDamage); } else { result.Includes.Add(RulePackDefOf.Combat_RangedMiss); } if (initiatorPawn != null) { result.Rules.AddRange(GrammarUtility.RulesForPawn("INITIATOR", initiatorPawn, result.Constants)); } else if (initiatorThing != null) { result.Rules.AddRange(GrammarUtility.RulesForDef("INITIATOR", initiatorThing)); } else { result.Constants["INITIATOR_missing"] = "True"; } if (recipientPawn != null) { result.Rules.AddRange(GrammarUtility.RulesForPawn("RECIPIENT", recipientPawn, result.Constants)); } else if (recipientThing != null) { result.Rules.AddRange(GrammarUtility.RulesForDef("RECIPIENT", recipientThing)); } else { result.Constants["RECIPIENT_missing"] = "True"; } if (originalTargetPawn != recipientPawn || originalTargetThing != recipientThing) { if (originalTargetPawn != null) { result.Rules.AddRange(GrammarUtility.RulesForPawn("ORIGINALTARGET", originalTargetPawn, result.Constants)); result.Constants["ORIGINALTARGET_mobile"] = originalTargetMobile.ToString(); } else if (originalTargetThing != null) { result.Rules.AddRange(GrammarUtility.RulesForDef("ORIGINALTARGET", originalTargetThing)); } else { result.Constants["ORIGINALTARGET_missing"] = "True"; } } result.Rules.AddRange(PlayLogEntryUtility.RulesForOptionalWeapon("WEAPON", weaponDef, projectileDef)); if (initiatorPawn != null && initiatorPawn.skills != null) { result.Constants["INITIATOR_skill"] = initiatorPawn.skills.GetSkill(SkillDefOf.Shooting).Level.ToStringCached(); } if (recipientPawn != null && recipientPawn.skills != null) { result.Constants["RECIPIENT_skill"] = recipientPawn.skills.GetSkill(SkillDefOf.Shooting).Level.ToStringCached(); } result.Constants["COVER_missing"] = ((coverDef != null) ? "False" : "True"); if (coverDef != null) { result.Rules.AddRange(GrammarUtility.RulesForDef("COVER", coverDef)); } return(result); }
protected override void RunInt() { if (!ModLister.RoyaltyInstalled) { Log.ErrorOnce("Bestowing ceremony is a Royalty-specific game system. If you want to use this code please check ModLister.RoyaltyInstalled before calling it. See rules on the Ludeon forum for more info.", 3454535); return; } Quest quest = QuestGen.quest; Slate slate = QuestGen.slate; if (!TryGetCeremonyTarget(QuestGen.slate, out var pawn, out var bestowingFaction)) { return; } RoyalTitleDef titleAwardedWhenUpdating = pawn.royalty.GetTitleAwardedWhenUpdating(bestowingFaction, pawn.royalty.GetFavor(bestowingFaction)); string text = QuestGenUtility.HardcodedTargetQuestTagWithQuestID("Bestowing"); string text2 = QuestGenUtility.QuestTagSignal(text, "CeremonyExpired"); string inSignal = QuestGenUtility.QuestTagSignal(text, "CeremonyFailed"); string inSignal2 = QuestGenUtility.QuestTagSignal(text, "CeremonyDone"); string inSignal3 = QuestGenUtility.QuestTagSignal(text, "TitleAwardedWhenUpdatingChanged"); Thing thing = QuestGen_Shuttle.GenerateShuttle(bestowingFaction, null, null, acceptColonists: false, onlyAcceptColonists: false, onlyAcceptHealthy: false, 0, dropEverythingIfUnsatisfied: false, leaveImmediatelyWhenSatisfied: true, dropEverythingOnArrival: true, stayAfterDroppedEverythingOnArrival: true); Pawn pawn2 = quest.GetPawn(new QuestGen_Pawns.GetPawnParms { mustBeOfKind = PawnKindDefOf.Empire_Royal_Bestower, canGeneratePawn = true, mustBeOfFaction = bestowingFaction, mustBeWorldPawn = true }); QuestUtility.AddQuestTag(ref thing.questTags, text); QuestUtility.AddQuestTag(ref pawn.questTags, text); ThingOwner <Thing> innerContainer = pawn2.inventory.innerContainer; for (int num = innerContainer.Count - 1; num >= 0; num--) { if (innerContainer[num].def == ThingDefOf.PsychicAmplifier) { Thing thing2 = innerContainer[num]; innerContainer.RemoveAt(num); thing2.Destroy(); } } int num2 = titleAwardedWhenUpdating.maxPsylinkLevel - pawn.GetPsylinkLevel(); for (int i = 0; i < num2 + 1; i++) { innerContainer.TryAdd(ThingMaker.MakeThing(ThingDefOf.PsychicAmplifier), 1); } List <Pawn> list = new List <Pawn>(); list.Add(pawn2); slate.Set("shuttleContents", list); slate.Set("shuttle", thing); slate.Set("target", pawn); slate.Set("bestowingFaction", bestowingFaction); List <Pawn> list2 = new List <Pawn>(); for (int j = 0; j < 6; j++) { Pawn item = quest.GeneratePawn(PawnKindDefOf.Empire_Fighter_Janissary, bestowingFaction); list.Add(item); list2.Add(item); } slate.Set("defenders", list2); CompShuttle compShuttle = thing.TryGetComp <CompShuttle>(); compShuttle.requiredPawns = list; compShuttle.sendAwayIfAllDespawned = list.Cast <Thing>().ToList(); compShuttle.sendAwayIfAllPawnsLeftToLoadAreNotOfFaction = bestowingFaction; quest.AddContentsToShuttle(thing, list); quest.SpawnSkyfaller(null, ThingDefOf.ShuttleIncoming, Gen.YieldSingle(thing), Faction.OfPlayer, null, null, lookForSafeSpot: true, tryLandInShipLandingZone: true, null, pawn); quest.FactionGoodwillChange(bestowingFaction, -5, QuestGenUtility.HardcodedSignalWithQuestID("defenders.Killed"), canSendMessage: true, canSendHostilityLetter: true, "GoodwillChangeReason_AttackedFaction".Translate(bestowingFaction)); QuestPart_BestowingCeremony questPart_BestowingCeremony = new QuestPart_BestowingCeremony(); questPart_BestowingCeremony.inSignal = QuestGen.slate.Get <string>("inSignal"); questPart_BestowingCeremony.pawns.Add(pawn2); questPart_BestowingCeremony.mapOfPawn = pawn; questPart_BestowingCeremony.faction = pawn2.Faction; questPart_BestowingCeremony.bestower = pawn2; questPart_BestowingCeremony.target = pawn; questPart_BestowingCeremony.shuttle = thing; questPart_BestowingCeremony.questTag = text; quest.AddPart(questPart_BestowingCeremony); QuestPart_EscortPawn questPart_EscortPawn = new QuestPart_EscortPawn(); questPart_EscortPawn.inSignal = QuestGen.slate.Get <string>("inSignal"); questPart_EscortPawn.escortee = pawn2; questPart_EscortPawn.pawns.AddRange(list2); questPart_EscortPawn.mapOfPawn = pawn; questPart_EscortPawn.faction = pawn2.Faction; questPart_EscortPawn.shuttle = thing; quest.AddPart(questPart_EscortPawn); string inSignal4 = QuestGenUtility.HardcodedSignalWithQuestID("shuttle.Killed"); quest.SetFactionRelations(bestowingFaction, FactionRelationKind.Hostile, inSignal4); quest.End(QuestEndOutcome.Fail, 0, null, inSignal4, QuestPart.SignalListenMode.OngoingOnly, sendStandardLetter: true); QuestPart_RequirementsToAcceptThroneRoom questPart_RequirementsToAcceptThroneRoom = new QuestPart_RequirementsToAcceptThroneRoom(); questPart_RequirementsToAcceptThroneRoom.faction = bestowingFaction; questPart_RequirementsToAcceptThroneRoom.forPawn = pawn; questPart_RequirementsToAcceptThroneRoom.forTitle = titleAwardedWhenUpdating; quest.AddPart(questPart_RequirementsToAcceptThroneRoom); QuestPart_RequirementsToAcceptPawnOnColonyMap questPart_RequirementsToAcceptPawnOnColonyMap = new QuestPart_RequirementsToAcceptPawnOnColonyMap(); questPart_RequirementsToAcceptPawnOnColonyMap.pawn = pawn; quest.AddPart(questPart_RequirementsToAcceptPawnOnColonyMap); QuestPart_RequirementsToAcceptNoDanger questPart_RequirementsToAcceptNoDanger = new QuestPart_RequirementsToAcceptNoDanger(); questPart_RequirementsToAcceptNoDanger.map = pawn.Map; questPart_RequirementsToAcceptNoDanger.dangerTo = bestowingFaction; quest.AddPart(questPart_RequirementsToAcceptNoDanger); string inSignal5 = QuestGenUtility.HardcodedSignalWithQuestID("shuttleContents.Recruited"); string inSignal6 = QuestGenUtility.HardcodedSignalWithQuestID("bestowingFaction.BecameHostileToPlayer"); quest.Signal(inSignal5, delegate { quest.End(QuestEndOutcome.Fail, 0, null, null, QuestPart.SignalListenMode.OngoingOnly, sendStandardLetter: true); }); quest.End(QuestEndOutcome.Fail, 0, null, QuestGenUtility.HardcodedSignalWithQuestID("target.Killed"), QuestPart.SignalListenMode.OngoingOrNotYetAccepted, sendStandardLetter: true); quest.Letter(LetterDefOf.NegativeEvent, text2, null, null, null, useColonistsFromCaravanArg: false, QuestPart.SignalListenMode.OngoingOnly, null, filterDeadPawnsFromLookTargets: false, label: "LetterLabelBestowingCeremonyExpired".Translate(), text: "LetterTextBestowingCeremonyExpired".Translate(pawn.Named("TARGET"))); quest.End(QuestEndOutcome.Fail, 0, null, text2); quest.End(QuestEndOutcome.Fail, 0, null, inSignal6, QuestPart.SignalListenMode.OngoingOrNotYetAccepted, sendStandardLetter: true); quest.End(QuestEndOutcome.Fail, 0, null, inSignal, QuestPart.SignalListenMode.OngoingOnly, sendStandardLetter: true); quest.End(QuestEndOutcome.Fail, 0, null, inSignal3, QuestPart.SignalListenMode.OngoingOrNotYetAccepted, sendStandardLetter: true); quest.End(QuestEndOutcome.Success, 0, null, inSignal2); QuestPart_Choice questPart_Choice = quest.RewardChoice(); QuestPart_Choice.Choice item2 = new QuestPart_Choice.Choice { rewards = { (Reward) new Reward_BestowingCeremony { targetPawnName = pawn.NameShortColored.Resolve(), titleName = titleAwardedWhenUpdating.GetLabelCapFor(pawn), awardingFaction = bestowingFaction, givePsylink = (titleAwardedWhenUpdating.maxPsylinkLevel > pawn.GetPsylinkLevel()), royalTitle = titleAwardedWhenUpdating } } }; questPart_Choice.choices.Add(item2); List <Rule> list3 = new List <Rule>(); list3.AddRange(GrammarUtility.RulesForPawn("pawn", pawn)); list3.Add(new Rule_String("newTitle", titleAwardedWhenUpdating.GetLabelCapFor(pawn))); QuestGen.AddQuestNameRules(list3); List <Rule> list4 = new List <Rule>(); list4.AddRange(GrammarUtility.RulesForFaction("faction", bestowingFaction)); list4.AddRange(GrammarUtility.RulesForPawn("pawn", pawn)); list4.Add(new Rule_String("newTitle", pawn.royalty.GetTitleAwardedWhenUpdating(bestowingFaction, pawn.royalty.GetFavor(bestowingFaction)).GetLabelFor(pawn))); list4.Add(new Rule_String("psylinkLevel", titleAwardedWhenUpdating.maxPsylinkLevel.ToString())); QuestGen.AddQuestDescriptionRules(list4); }
private static void AddSlateVar(ref GrammarRequest req, string absoluteName, object obj) { if (obj == null) { return; } if (obj is BodyPartRecord) { req.Rules.AddRange(GrammarUtility.RulesForBodyPartRecord(absoluteName, (BodyPartRecord)obj)); } else if (obj is Def) { req.Rules.AddRange(GrammarUtility.RulesForDef(absoluteName, (Def)obj)); } else if (obj is Faction) { Faction faction = (Faction)obj; req.Rules.AddRange(GrammarUtility.RulesForFaction(absoluteName, faction)); if (faction.leader != null) { req.Rules.AddRange(GrammarUtility.RulesForPawn(absoluteName + "_leader", faction.leader, req.Constants)); } } else if (obj is Pawn) { Pawn pawn = (Pawn)obj; req.Rules.AddRange(GrammarUtility.RulesForPawn(absoluteName, pawn, req.Constants)); if (pawn.Faction != null) { req.Rules.AddRange(GrammarUtility.RulesForFaction(absoluteName + "_faction", pawn.Faction)); } } else if (obj is WorldObject) { req.Rules.AddRange(GrammarUtility.RulesForWorldObject(absoluteName, (WorldObject)obj)); } else if (obj is Map) { req.Rules.AddRange(GrammarUtility.RulesForWorldObject(absoluteName, ((Map)obj).Parent)); } else if (obj is IntVec2) { req.Rules.Add(new Rule_String(absoluteName, ((IntVec2)obj).ToStringCross())); } else if (obj is IEnumerable && !(obj is string)) { if (obj is IEnumerable <Thing> ) { req.Rules.Add(new Rule_String(absoluteName, GenLabel.ThingsLabel(((IEnumerable <Thing>)obj).Where((Thing x) => x != null)))); } else if (obj is IEnumerable <Pawn> ) { req.Rules.Add(new Rule_String(absoluteName, GenLabel.ThingsLabel(((IEnumerable <Pawn>)obj).Where((Pawn x) => x != null).Cast <Thing>()))); } else if (obj is IEnumerable <object> && ((IEnumerable <object>)obj).Any() && ((IEnumerable <object>)obj).All((object x) => x is Thing)) { req.Rules.Add(new Rule_String(absoluteName, GenLabel.ThingsLabel(((IEnumerable <object>)obj).Where((object x) => x != null).Cast <Thing>()))); } else { List <string> list = new List <string>(); foreach (object item in (IEnumerable)obj) { if (item != null) { list.Add(item.ToString()); } } req.Rules.Add(new Rule_String(absoluteName, list.ToCommaList(useAnd: true))); } req.Rules.Add(new Rule_String(absoluteName + "_count", ((IEnumerable)obj).EnumerableCount().ToString())); int num = 0; foreach (object item2 in (IEnumerable)obj) { AddSlateVar(ref req, absoluteName + num, item2); num++; } } else { req.Rules.Add(new Rule_String(absoluteName, obj.ToString())); if (ConvertHelper.CanConvert <int>(obj)) { req.Rules.Add(new Rule_String(absoluteName + "_duration", ConvertHelper.Convert <int>(obj).ToStringTicksToPeriod(allowSeconds: true, shortForm: false, canUseDecimals: true, allowYears: false).Colorize(ColoredText.DateTimeColor))); } if (ConvertHelper.CanConvert <float>(obj)) { req.Rules.Add(new Rule_String(absoluteName + "_money", ConvertHelper.Convert <float>(obj).ToStringMoney())); } if (ConvertHelper.CanConvert <float>(obj)) { req.Rules.Add(new Rule_String(absoluteName + "_percent", ConvertHelper.Convert <float>(obj).ToStringPercent())); } if (ConvertHelper.CanConvert <FloatRange>(obj)) { AddSlateVar(ref req, absoluteName + "_average", ConvertHelper.Convert <FloatRange>(obj).Average); } if (ConvertHelper.CanConvert <FloatRange>(obj)) { AddSlateVar(ref req, absoluteName + "_min", ConvertHelper.Convert <FloatRange>(obj).min); } if (ConvertHelper.CanConvert <FloatRange>(obj)) { AddSlateVar(ref req, absoluteName + "_max", ConvertHelper.Convert <FloatRange>(obj).max); } } if (obj is Def) { if (!req.Constants.ContainsKey(absoluteName)) { req.Constants.Add(absoluteName, ((Def)obj).defName); } } else if (obj is Faction) { if (!req.Constants.ContainsKey(absoluteName)) { req.Constants.Add(absoluteName, ((Faction)obj).def.defName); } } else if ((obj.GetType().IsPrimitive || obj is string || obj.GetType().IsEnum) && !req.Constants.ContainsKey(absoluteName)) { req.Constants.Add(absoluteName, obj.ToString()); } if (obj is IEnumerable && !(obj is string)) { string key = absoluteName + "_count"; if (!req.Constants.ContainsKey(key)) { req.Constants.Add(key, ((IEnumerable)obj).EnumerableCount().ToString()); } } }
public override IEnumerable <Rule> GetRules(string prefix) { return(GrammarUtility.RulesForPawn(prefix, this.name, this.kind, this.gender, this.faction, null)); }