public TaleReference GetRandomTaleReferenceForArt(ArtGenerationContext source) { TaleReference result; Tale tale; if (source == ArtGenerationContext.Outsider) { result = TaleReference.Taleless; } else if (this.tales.Count == 0) { result = TaleReference.Taleless; } else if (Rand.Value < 0.25f) { result = TaleReference.Taleless; } else if (!(from x in this.tales where x.def.usableForArt select x).TryRandomElementByWeight((Tale ta) => ta.InterestLevel, out tale)) { result = TaleReference.Taleless; } else { tale.Notify_NewlyUsed(); result = new TaleReference(tale); } return(result); }
private void InitializeArt(Thing relatedThing, ArtGenerationContext source) { if (taleRef != null) { taleRef.ReferenceDestroyed(); taleRef = null; } if (CanShowArt) { if (Current.ProgramState == ProgramState.Playing) { if (relatedThing != null) { taleRef = Find.TaleManager.GetRandomTaleReferenceForArtConcerning(relatedThing); } else { taleRef = Find.TaleManager.GetRandomTaleReferenceForArt(source); } } else { taleRef = TaleReference.Taleless; } titleInt = GenerateTitle(); } else { titleInt = null; taleRef = null; } }
private static string RandomArtworkName(TaleReference tr) { List <Rule> list = new List <Rule>(); switch (Rand.RangeInclusive(0, 4)) { case 0: list.AddRange(RulePackDefOf.ArtName_Sculpture.RulesPlusIncludes); break; case 1: list.AddRange(RulePackDefOf.ArtName_WeaponMelee.RulesPlusIncludes); break; case 2: list.AddRange(RulePackDefOf.ArtName_WeaponGun.RulesPlusIncludes); break; case 3: list.AddRange(RulePackDefOf.ArtName_Furniture.RulesPlusIncludes); break; case 4: list.AddRange(RulePackDefOf.ArtName_SarcophagusPlate.RulesPlusIncludes); break; } return(tr.GenerateText(TextGenerationPurpose.ArtName, list)); }
public override void PostDestroy(DestroyMode mode, Map previousMap) { base.PostDestroy(mode, previousMap); if (taleRef != null) { taleRef.ReferenceDestroyed(); taleRef = null; } }
public void Clear() { authorNameInt = null; titleInt = null; if (taleRef != null) { taleRef.ReferenceDestroyed(); taleRef = null; } }
protected override void FillTab() { Rect rect = new Rect(0f, 0f, WinSize.x, WinSize.y).ContractedBy(10f); Text.Font = GameFont.Medium; Widgets.Label(rect, SelectedCompArt.Title); if (cachedImageSource != SelectedCompArt || cachedTaleRef != SelectedCompArt.TaleRef) { cachedImageDescription = SelectedCompArt.GenerateImageDescription(); cachedImageSource = SelectedCompArt; cachedTaleRef = SelectedCompArt.TaleRef; } Rect rect2 = rect; rect2.yMin += 35f; Text.Font = GameFont.Small; Widgets.Label(rect2, cachedImageDescription); }
protected override void FillTab() { Rect rect = new Rect(0f, 0f, ITab_Art.WinSize.x, ITab_Art.WinSize.y).ContractedBy(10f); Rect rect2 = rect; Text.Font = GameFont.Medium; Widgets.Label(rect2, this.SelectedCompArt.Title); if (ITab_Art.cachedImageSource != this.SelectedCompArt || ITab_Art.cachedTaleRef != this.SelectedCompArt.TaleRef) { ITab_Art.cachedImageDescription = this.SelectedCompArt.GenerateImageDescription(); ITab_Art.cachedImageSource = this.SelectedCompArt; ITab_Art.cachedTaleRef = this.SelectedCompArt.TaleRef; } Rect rect3 = rect; rect3.yMin += 35f; Text.Font = GameFont.Small; Widgets.Label(rect3, ITab_Art.cachedImageDescription); }
public TaleReference GetRandomTaleReferenceForArtConcerning(Thing th) { TaleReference result; Tale tale; if (this.tales.Count == 0) { result = TaleReference.Taleless; } else if (!(from x in this.tales where x.def.usableForArt && x.Concerns(th) select x).TryRandomElementByWeight((Tale x) => x.InterestLevel, out tale)) { result = TaleReference.Taleless; } else { tale.Notify_NewlyUsed(); result = new TaleReference(tale); } return(result); }
private static void LogTales(IEnumerable <Tale> tales) { StringBuilder stringBuilder = new StringBuilder(); int num = 0; foreach (Tale current in tales) { TaleReference tr = new TaleReference(current); stringBuilder.AppendLine(TaleTester.RandomArtworkName(tr)); stringBuilder.AppendLine(TaleTester.RandomArtworkDescription(tr)); stringBuilder.AppendLine(); num++; if (num % 20 == 0) { Log.Message(stringBuilder.ToString()); stringBuilder = new StringBuilder(); } } if (!stringBuilder.ToString().NullOrEmpty()) { Log.Message(stringBuilder.ToString()); } }
private void InitializeArt(Thing relatedThing, ArtGenerationContext source) { if (taleRef != null) { //Is there any scenario where this should happen more than once? //Yes, theoretically. For example, we bury a corpse in a sarcophagus, then dig him up and bury another. //The art changes in response. But is this correct? taleRef.ReferenceDestroyed(); taleRef = null; } if (CanShowArt) { if (Current.ProgramState == ProgramState.Playing) { if (relatedThing != null) { taleRef = Find.TaleManager.GetRandomTaleReferenceForArtConcerning(relatedThing); } else { taleRef = Find.TaleManager.GetRandomTaleReferenceForArt(source); } } else { taleRef = TaleReference.Taleless; //Todo add some chance of getting taleless art even in map play } titleInt = GenerateTitle(); } else { titleInt = null; taleRef = null; } }