public TaleReference GetRandomTaleReferenceForArt(ArtGenerationContext source) { if (source == ArtGenerationContext.Outsider) { return(TaleReference.Taleless); } if (this.tales.Count == 0) { return(TaleReference.Taleless); } if (Rand.Value < 0.25) { return(TaleReference.Taleless); } Tale tale = default(Tale); if (!(from x in this.tales where x.def.usableForArt select x).TryRandomElementByWeight <Tale>((Func <Tale, float>)((Tale ta) => ta.InterestLevel), out tale)) { return(TaleReference.Taleless); } tale.Notify_NewlyUsed(); return(new TaleReference(tale)); }
public TaleReference GetRandomTaleReferenceForArtConcerning(Thing th) { if (this.tales.Count == 0) { return(TaleReference.Taleless); } Tale tale = default(Tale); if (!(from x in this.tales where x.def.usableForArt && x.Concerns(th) select x).TryRandomElementByWeight <Tale>((Func <Tale, float>)((Tale x) => x.InterestLevel), out tale)) { return(TaleReference.Taleless); } tale.Notify_NewlyUsed(); return(new TaleReference(tale)); }