/// <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; } } }
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."); }
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 }
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); } }