public static TaggedString GenerateTextFromTale(TextGenerationPurpose purpose, Tale tale, int seed, RulePackDef extraInclude, CompBook compBook) { Rand.PushState(); Rand.Seed = seed; string rootKeyword = null; GrammarRequest request = default(GrammarRequest); request.Includes.Add(extraInclude); switch (purpose) { case TextGenerationPurpose.ArtDescription: rootKeyword = compBook.Props.nameMaker.RulesImmediate .Where(x => x.keyword != null && x.keyword.Length > 0).RandomElement().keyword; //Log.Message("rootKeyword for description: " + rootKeyword); if (tale != null && !Rand.Chance(0.2f)) { request.Includes.Add(RulePackDefOf.ArtDescriptionRoot_HasTale); request.IncludesBare.AddRange(tale.GetTextGenerationIncludes()); request.Rules.AddRange(tale.GetTextGenerationRules()); } else { request.Includes.Add(RulePackDefOf.ArtDescriptionRoot_Taleless); request.Includes.Add(RulePackDefOf.TalelessImages); } request.Includes.Add(RulePackDefOf.ArtDescriptionUtility_Global); break; case TextGenerationPurpose.ArtName: rootKeyword = compBook.Props.descriptionMaker.RulesImmediate .Where(x => x.keyword != null && x.keyword.Length > 0).RandomElement().keyword; //Log.Message("rootKeyword for name: " + rootKeyword); if (tale != null) { request.IncludesBare.AddRange(tale.GetTextGenerationIncludes()); request.Rules.AddRange(tale.GetTextGenerationRules()); } break; } string str = GrammarResolver.Resolve(rootKeyword, request, (tale != null) ? tale.def.defName : "null_tale"); Rand.PopState(); return(str); }
public static TaggedString GenerateTextFromTale(TextGenerationPurpose purpose, Tale tale, int seed, RulePackDef extraInclude) { Rand.PushState(); Rand.Seed = seed; string rootKeyword = null; GrammarRequest request = default(GrammarRequest); request.Includes.Add(extraInclude); switch (purpose) { case TextGenerationPurpose.ArtDescription: rootKeyword = "r_art_description"; if (tale != null && !Rand.Chance(0.2f)) { request.Includes.Add(RulePackDefOf.ArtDescriptionRoot_HasTale); request.IncludesBare.AddRange(tale.GetTextGenerationIncludes()); request.Rules.AddRange(tale.GetTextGenerationRules()); } else { request.Includes.Add(RulePackDefOf.ArtDescriptionRoot_Taleless); request.Includes.Add(RulePackDefOf.TalelessImages); } request.Includes.Add(RulePackDefOf.ArtDescriptionUtility_Global); break; case TextGenerationPurpose.ArtName: rootKeyword = "r_art_name"; if (tale != null) { request.IncludesBare.AddRange(tale.GetTextGenerationIncludes()); request.Rules.AddRange(tale.GetTextGenerationRules()); } break; } string str = GrammarResolver.Resolve(rootKeyword, request, (tale != null) ? tale.def.defName : "null_tale"); Rand.PopState(); return(str); }
public static string GenerateTextFromTale(TextGenerationPurpose purpose, Tale tale, int seed, List <Rule> extraRules) { Rand.PushState(); Rand.Seed = seed; string rootKeyword = null; GrammarRequest request = default(GrammarRequest); request.Rules.AddRange(extraRules); switch (purpose) { case TextGenerationPurpose.ArtDescription: rootKeyword = "art_description_root"; if (tale != null && Rand.Value > 0.20000000298023224) { request.Includes.Add(RulePackDefOf.ArtDescriptionRoot_HasTale); request.Rules.AddRange(tale.GetTextGenerationRules()); } else { request.Includes.Add(RulePackDefOf.ArtDescriptionRoot_Taleless); request.Includes.Add(RulePackDefOf.TalelessImages); } request.Includes.Add(RulePackDefOf.ArtDescriptionUtility_Global); break; case TextGenerationPurpose.ArtName: rootKeyword = "art_name"; if (tale != null) { request.Rules.AddRange(tale.GetTextGenerationRules()); } break; } string result = GrammarResolver.Resolve(rootKeyword, request, (tale == null) ? "null_tale" : tale.def.defName, false); Rand.PopState(); return(result); }
public string GenerateText(TextGenerationPurpose purpose, RulePackDef extraInclude) { return(TaleTextGenerator.GenerateTextFromTale(purpose, this.tale, this.seed, extraInclude)); }
public string GenerateText(TextGenerationPurpose purpose, List <Rule> extraRules) { return(TaleTextGenerator.GenerateTextFromTale(purpose, this.tale, this.seed, extraRules)); }
public TaggedString GenerateText(TextGenerationPurpose purpose, RulePackDef extraInclude, CompBook compBook) { return(TaleTextGenerator.GenerateTextFromTale(purpose, tale, seed, extraInclude, compBook)); }