Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Harmony;
- using Pathea.ActorNs;
- using Pathea.MapNs;
- using Pathea.ModuleNs;
- using Pathea.UISystemNs;
- using System.Reflection;
- using UnityEngine;
- namespace AlwaysMinimapPortraits
- {
- [HarmonyPatch(typeof(Actor_IMap))]
- [HarmonyPatch("GetIconInfo")]
- public static class GetIconInfoPatch
- {
- private static FieldInfo overrideSpriteField = null;
- public static void Postfix(Actor_IMap __instance, ref PresetIcon __iconInfo, ref Actor __mActor)
- {
- if ( overrideSpriteField == null )
- {
- overrideSpriteField = typeof(PresetIcon).GetField("overrideSprite", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
- }
- var sprite = overrideSpriteField.GetValue(__iconInfo);
- if ( __instance.GetIcon() == MapIcon.NPC )
- {
- ActorInfo actorInfo = Module<ActorMgr>.Self.GetActorInfo(__mActor.TmpltId);
- if (!string.IsNullOrEmpty(actorInfo.miniHeadIcon))
- {
- __iconInfo.SetOverrideSprite(UIUtils.GetSpriteByPath(actorInfo.miniHeadIcon), false, Vector2.zero);
- }
- else
- {
- __iconInfo.SetOverrideSprite(UIUtils.GetSpriteByPath(actorInfo.icon), true, new Vector2(30f, 31.5f));
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement