Ejemplo n.º 1
0
        public static TaleNews GenerateTaleNewsGenerally(TaleNewsTypeEnum typeEnum)
        {
            TaleNews newsInstance = Activator.CreateInstance(typeEnum.GetTypeForEnum()) as TaleNews;

            DesynchronizedMain.TaleNewsDatabaseSystem.RegisterNewTaleNews(newsInstance);
            return(newsInstance);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 4
0
        /// <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.
     }
 }
Ejemplo n.º 6
0
        /// <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();
        }
Ejemplo n.º 8
0
 public bool IsReferencingTaleNews(TaleNews news)
 {
     return(uidOfReferencedTaleNews == news.UniqueID);
 }
Ejemplo n.º 9
0
 public TaleNewsReference(TaleNewsReference reference, Pawn recipient)
 {
     underlyingTaleNews = reference.UnderlyingTaleNews;
     this.recipient     = recipient;
 }