public static TaleNews GenerateTaleNewsGenerally(TaleNewsTypeEnum typeEnum) { TaleNews newsInstance = Activator.CreateInstance(typeEnum.GetTypeForEnum()) as TaleNews; DesynchronizedMain.TaleNewsDatabaseSystem.RegisterNewTaleNews(newsInstance); return(newsInstance); }
public TaleNewsReference(TaleNews news, Pawn recipient) : this(recipient) { if (!news.IsRegistered) { throw new ArgumentException("Unregisterd TaleNews received."); } uidOfReferencedTaleNews = news.UniqueID; }
public TaleNewsReference AttemptToObtainExistingReference(TaleNews news) { foreach (var reference in newsKnowledgeList) { if (reference.ReferencedTaleNews.UniqueID == news.UniqueID) { return(reference); } } return(null); }
/// <summary> /// Registers a TaleNews object by giving it a valid UID, then adding it to the List. /// <para/> /// In current implementation, the constructor of TaleNews will also register itself to here. /// </summary> /// <param name="news"></param> public void RegisterNewTaleNews(TaleNews news) { if (news == null) { DesynchronizedMain.LogError("An unexpected null TaleNews was received. Report this to Desynchronized.\n" + Environment.StackTrace); return; } if (!news.IsRegistered) { news.ReceiveRegistrationID(GetNextUID()); talesOfImportance.Add(news); } }
/// <summary> /// Finds the TaleNewsReference of the given TaleNews in the known list (or generates a new one if it does not exist), and activates it. /// </summary> /// <param name="news"></param> public void KnowNews(TaleNews news) { if (AttemptToObtainExistingReference(news) == null) { // Pawn is receiving this for the first time. TaleNewsReference newReference = news.CreateReferenceForReceipient(Pawn); newsKnowledgeList.Add(newReference); newReference.ActivateNews(); } else { // Pawn might have forgotten about the news, so let's see. // Not implemented for now. } }
/// <summary> /// Finds the TaleNewsReference of the given TaleNews in the known list (or generates a new one if it does not exist), and activates it. /// </summary> /// <param name="news"></param> public void KnowNews(TaleNews news, WitnessShockGrade shockGrade) { foreach (TaleNewsReference reference in newsKnowledgeList) { if (reference.IsReferencingTaleNews(news)) { reference.ActivateNews(shockGrade); return; } } TaleNewsReference newReference = news.CreateReferenceForReceipient(Pawn); newsKnowledgeList.Add(newReference); newReference.ActivateNews(shockGrade); return; }
/// <summary> /// Finds the TaleNewsReference of the given TaleNews in the known list (or generates a new one if it does not exist), /// and activates it. /// </summary> /// <param name="news"></param> public void KnowNews(TaleNews news) { if (news == null) { return; } if (AttemptToObtainExistingReference(news) != null) { return; } // Pawn is receiving this for the first time. var newReference = news.CreateReferenceForReceipient(Pawn); newsKnowledgeList.Add(newReference); newReference.ActivateNews(); }
public bool IsReferencingTaleNews(TaleNews news) { return(uidOfReferencedTaleNews == news.UniqueID); }
public TaleNewsReference(TaleNewsReference reference, Pawn recipient) { underlyingTaleNews = reference.UnderlyingTaleNews; this.recipient = recipient; }