Try to call PregnancyLogEntry.IsVisibleNotification at OnApplicationTick().
I tried, it was not letting me do that, so I tried adding in a secondary class (Utility) to get the instance:
插入代码块:
public static PregnancyLogEntry GetPregnancyLogEntryInstance()
{
return Campaign.Current.CampaignBehaviorManager.GetBehavior<PregnancyLogEntry>();
}
Then I called it on the
OnApplicationTick().
插入代码块:
protected override void OnApplicationTick(float dt)
{
PregnancyLogEntry MyPregnancyLog = Utillty.GetPregnancyLogEntryInstance();
}
And yes, I was able to access to
MyPregnancyLog.IsVisibleNotification but since it is a bool thing, it can not figure out what to do next, I tried
MyPregnancyLog.IsVisibleNotification = false; but I was unable to modify it since it is read only.
Anyway, I managed to solve my problem using a different way, I realized that trying to patch and use the native
PregnancyLogEntry class was kinda worthless compared to the fact that I could implement my own class for this log notification, so I did.
I simply patched the CommentPregnancyBehavior.OnChildConceived() instead, which is the function calling the PregnancyLogEntry Class, and it works as intended:
1.- Create an exact copy of the PregnancyLogEntry Class with all his functions:
插入代码块:
public class PregnancyControlLogEntry : LogEntry, IEncyclopediaLog, IChatNotification
{
//Excluded
}
2.- Modify whatever is needed.
3.- Patch the calling function:
插入代码块:
using System;
using TaleWorlds.CampaignSystem.LogEntries;
using HarmonyLib;
using TaleWorlds.CampaignSystem;
using TaleWorlds.CampaignSystem.SandBox.CampaignBehaviors.CommentBehaviors;
namespace FixedPregnancyControl
{
[HarmonyPatch(typeof(CommentPregnancyBehavior), "OnChildConceived")]
public class PregnancyControlCommentPatch
{
private PregnancyControlCommentPatch()
{
}
public static bool Prefix(CommentPregnancyBehavior __instance, ref Hero mother)
{
LogEntry.AddLogEntry(new PregnancyControlLogEntry(mother));
return false;
}
}
}
Thanks so much for helping.