Example #1
0
        internal static void Init(ShopMenu __instance, string who)
        {
            ModEntry.monitor.Log(who);

            if (who is null && __instance.portraitPerson?.Name is null)
            {
                return;
            }

            string name = __instance.portraitPerson?.Name is not null?
                          __instance.portraitPerson.getTextureName() : NPC.getTextureNameForCharacter(who);

            string suffix = null;

            if (__instance.portraitPerson is not null)
            {
                suffix = PortraitDrawPatch.GetSuffix(__instance.portraitPerson);
            }

            if (ModEntry.TryGetMetadata(name, suffix, out var meta))
            {
                PortraitDrawPatch.lastLoaded.Value.Add(meta);
                PortraitDrawPatch.currentMeta.Value = meta;
                meta.Reload();
            }
        }
Example #2
0
        public static void Init(DialogueBox __instance)
        {
            bool overriden = __instance.characterDialogue?.overridePortrait != null;
            NPC  npc       = __instance.characterDialogue?.speaker;

            if (npc != null || overriden)
            {
                if (ModEntry.TryGetMetadata(overriden ? PortraitDrawPatch.overrideName.Value ?? "NULL" : npc.getTextureName(), PortraitDrawPatch.GetSuffix(npc), out var meta))
                {
                    PortraitDrawPatch.lastLoaded.Value.Add(meta);
                    PortraitDrawPatch.currentMeta.Value = meta;
                    meta.Reload();
                }
                else
                {
                    PortraitDrawPatch.currentMeta.Value = null;
                }
            }
        }