Пример #1
0
        /// <summary>
        /// Calculates and updates the news importance. If the importance score is low enough, the news is forgotten.
        /// </summary>
        /// <param name="forceRecheck"></param>
        public void UpdateNewsImportance(bool forceRecheck = false)
        {
            if (!forceRecheck && NewsIsLocallyForgotten)
            {
                return;
            }
            if (ReferencedTaleNews.PermanentlyForgotten)
            {
                // It's pointless to calculate an importance of something that does not exist.
                newsImportance = null;
            }
            else
            {
                float result = ReferencedTaleNews.CalculateNewsImportanceForPawn(cachedSubject, this);

                if (result < 1)
                {
                    // Forgets
                    newsImportance = null;
                }
                else
                {
                    newsImportance = result;
                }
            }
        }
Пример #2
0
 /// <summary>
 /// Attempts to activate news, and let the recipient react to the news.
 /// <para/>
 /// Will do nothing if the news has already been activated before.
 /// </summary>
 public void ActivateNews()
 {
     if (!hasBeenActivated)
     {
         // First time activating.
         ReferencedTaleNews.ActivateForReceipient(CachedSubject);
         UpdateNewsImportance(true);
         tickReceived     = Find.TickManager.TicksGame;
         hasBeenActivated = true;
     }
 }
Пример #3
0
        public void RecalculateNewsImportance()
        {
            // Safety checks; should not attempt to calculate importance score when the news is forgotten
            // The importance should technically be null, but let's make it simpler by using a 0 here.
            if (IsLocallyForgotten)
            {
                cachedImportance = 0;
            }
            else
            {
                cachedImportance = ReferencedTaleNews.CalculateNewsImportanceForPawn(CachedSubject, this);
            }

            // DesynchronizedMain.LogError("Recalculated #" + ReferencedTaleNews.UniqueID + " to have " + cachedImportance + " importance.");
        }
Пример #4
0
        public void Notify_UpdateNewsImportance()
        {
            if (IsLocallyForgotten || ReferencedTaleNews.PermanentlyForgotten)
            {
                // Just to be safe. Do nothing and return.
                DesynchronizedMain.LogWarning("Someone attempted to update importance score of a forgotten tale-news reference. This is unsafe behavior, and has been prevented.\n" + Environment.StackTrace);
                return;
            }

            cachedImportance = ReferencedTaleNews.CalculateNewsImportanceForPawn(CachedSubject, this);

            if (cachedImportance < 1)
            {
                Forget();
            }
            // CachedNewsImportance can already return 0 when IsLocallyForgotten
        }
Пример #5
0
        internal void Notify_ConductImportanceUpdateCycle()
        {
            switch (ForgetState)
            {
            case ForgetfulnessState.KNOWN:
                cachedImportance = ReferencedTaleNews.CalculateNewsImportanceForPawn(CachedSubject, this);
                if (cachedImportance < 1)
                {
                    locallyForgotten = true;
                    cachedImportance = 0;
                }
                break;

            case ForgetfulnessState.LOCALLY_FORGOT:
            case ForgetfulnessState.PERM_FORGOT:
                cachedImportance = 0;
                break;

            default:
                break;
            }
            if (!locallyForgotten)
            {
            }


            // Safety checks; should not attempt to calculate importance score when the news is forgotten
            // The importance should technically be null, but let's make it simpler by using a 0 here.
            if (ReferencedTaleNews.PermanentlyForgotten)
            {
                IsLocallyForgotten = true;
            }
            if (locallyForgotten)
            {
                cachedImportance = 0;
            }
            else
            {
                cachedImportance = ReferencedTaleNews.CalculateNewsImportanceForPawn(CachedSubject, this);
            }
        }