搜索结果: *

  1. nachomastero

    BL Coding How to make the rounded map notifications?

    Can you give a link to that thread? Thanks.
    Sorry for the delay, this is the thread
  2. nachomastero

    BL Coding How to make the rounded map notifications?

    What rounded map notification are you referring to? Can you take a screenshot of an example?
    I found a thread back there and a developer solved the question already, I mean the clickable notifications you get for when an army is gathered and such.
    Thank you anyway.
  3. nachomastero

    BL Coding Creating conversation on the world map

    You can try something like this:

    插入代码块:
       public void Initialize()
            {
                ScreenManager.OnPushScreen += OnScreenManagerPushScreen;
            }
    
       
    
            private void OnScreenManagerPushScreen(ScreenBase pushedScreen)
            {
                if (!_registered && pushedScreen is MapScreen mapScreen)
                {
                    mapScreen.MapNotificationView.RegisterMapNotificationType(typeof(MiscarriageNotification),
                                                                              typeof(MiscarriageNotificationVM));
                    _registered = true;
                }
            }
    
            public void OnGameEnd()
            {
                ScreenManager.OnPushScreen -= OnScreenManagerPushScreen;
                _registered = false;
            }

    Call Initialize() in your submodule class.
    Note that this is an older code, may need some tweaks.

    It works as intended!, thank you.
  4. nachomastero

    BL Coding How to make the rounded map notifications?

    Hi guys, hope someone could help, I cant figure out how to create that rounded map notifications, I couldn't find any guide, I am trying to create a custom notification but nothing worked so far. I have this two classes : public class MiscarriageNotification : InformationData...
  5. nachomastero

    BL Coding Can't Patch Getter with Harmony Anymore BL 1.7.1

    I suspect that the problem are related to the class names to be too long.
    I just noticed that other of my patches was also not working, and I fixed it by shorting the names, in both of the falied patches I was using long names:
    插入代码块:
    internal class PregLogEntrySetIsVisibleNotificationPatch
    {
    
    }

    插入代码块:
    public class PregnancyCheckOffspringsToDeliverPatch
    {
    }

    Curious that only the long-name classes has the issue, I correct the second one by remplacing to another class with a shorter name and it is now working.
  6. nachomastero

    BL Coding Can't Patch Getter with Harmony Anymore BL 1.7.1

    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.
  7. nachomastero

    BL Coding Can't Patch Getter with Harmony Anymore BL 1.7.1

    It is executed when a child is conceived, I call MakePregnantAction.Apply(Hero mother). My mod Pregnancy control, basically adds all the heroes you talk to a list, and a function will be executed on daily tick hero
    插入代码块:
    CheckAddNewPregnancies(Hero mother)
    , it will make all the heroes on the list pregnant with MakePregnantAction.Apply(Hero mother). after this point, Native code will handle the pregnancy, at some point, it will call the
    插入代码块:
    PregnancyLogEntry.IsVisibleNotification
    , BUT the problem with this function is, it will try to read the mother's clan (DNspy prove).
    插入代码块:
    public bool IsVisibleNotification
    {
        get
        {
            return this.Mother.Clan.Equals(Hero.MainHero.Clan);
        }
    }
    if you make pregnant a notable or a wanderer, this will crash the game with a null exception cause they has no clan, that's why I patched the function with an harmony prefix.
    You can see the complete call stack on this crash report (Caused by a notable, because the patch is not working :p)


    Sorry for my poor tech speech, I am actually a novice at programing. also sorry for my poor english, thanks for answer and try to help, I appreciate that.
  8. nachomastero

    BL Coding Can't Patch Getter with Harmony Anymore BL 1.7.1

    Hey, instead of a prefix bool returning false, can you try a postfix void?
    Tried that, but the patch persist with no effect. What could it be.. It worked fine since ever until now, I checked the native code and no changes was made to that function, not even to the entire PregnancyLogEntry class, I tried with the new and the old Harmony update, no effect
  9. nachomastero

    BL Coding Can't Patch Getter with Harmony Anymore BL 1.7.1

    Since BL 1.7.1 update, my patch for Getter IsVisibleNotification is no longer working, patch is ignored like not existed. the BL code for this function seems not changed. Is somebody experiencing similar issues trying to patch getters? I am not getting the printed message anymore, I also try...
后退
顶部 底部