Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of CreatureTrackerMinimap v0.9.10
CreatureTrackerMinimap.dll
Decompiled 8 months agousing System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Splatform; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("CreatureTrackerMinimap")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("CreatureTrackerMinimap")] [assembly: AssemblyCopyright("Copyright © Fusionette 2025")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("fe2e4f38-7725-4b88-bc61-0efcd60fad48")] [assembly: AssemblyFileVersion("0.9.10.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("0.9.10.0")] namespace CreatureTrackerMinimap; internal class CreatureTrackerComponent : MonoBehaviour { private string displayName; private string displayLevel; private Sprite displayIcon; private PinData pinData; private bool isFish; private bool showName; public void Initialize(string displayName, Sprite displayIcon, int level, bool isFish) { this.displayName = displayName; this.displayIcon = displayIcon; this.isFish = isFish; SetLevel(level); } public void SetName(string displayName) { this.displayName = displayName; if (pinData != null) { pinData.m_name = GetDisplayName(); } } public void SetLevel(int level) { switch (level) { case 2: displayLevel = " ⭐"; break; case 3: displayLevel += " ⭐⭐"; break; default: displayLevel = string.Empty; break; } if (pinData != null) { pinData.m_name = GetDisplayName(); } } private string GetDisplayName() { if (!showName) { return ""; } return displayName + displayLevel; } private void Update() { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) if (isFish && !CreatureTrackerMinimap.cfgTrackFish.Value) { OnDestroy(); return; } if (pinData == null) { showName = CreatureTrackerMinimap.cfgShowNames.Value; pinData = Minimap.instance.AddPin(((Component)this).transform.position, (PinType)14, GetDisplayName(), false, false, 0L, default(PlatformUserID)); if ((Object)(object)displayIcon != (Object)null) { pinData.m_icon = displayIcon; pinData.m_worldSize = 0f; } } else if (showName != CreatureTrackerMinimap.cfgShowNames.Value) { showName = CreatureTrackerMinimap.cfgShowNames.Value; pinData.m_name = GetDisplayName(); } pinData.m_pos = ((Component)this).transform.position; } private void OnDestroy() { if (pinData != null) { Minimap.instance.RemovePin(pinData); pinData = null; } } } [BepInPlugin("Fusionette.CreatureTrackerMinimap", "Creature Tracker Minimap", "0.9.10")] public class CreatureTrackerMinimap : BaseUnityPlugin { private const string modGUID = "Fusionette.CreatureTrackerMinimap"; private const string modName = "Creature Tracker Minimap"; private const string modVersion = "0.9.10"; private readonly Harmony harmony = new Harmony("Fusionette.CreatureTrackerMinimap"); public static ConfigEntry<int> cfgNexusID; public static ConfigEntry<bool> cfgTrackFish; public static ConfigEntry<bool> cfgShowNames; public static ConfigEntry<float> cfgHudDistance; public static ConfigEntry<float> cfgHudDuration; private void Awake() { cfgNexusID = ((BaseUnityPlugin)this).Config.Bind<int>("General", "NexusID", 2706, "Nexus ID to check for updates."); cfgTrackFish = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "TrackFish", true, "Show Fish on the minimap."); cfgShowNames = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ShowNames", true, "Show creature names on the map screen."); cfgHudDistance = ((BaseUnityPlugin)this).Config.Bind<float>("Hud", "ShowDistance", 10f, "Show enemy health bars on mouse hover from this distance."); cfgHudDuration = ((BaseUnityPlugin)this).Config.Bind<float>("Hud", "ShowDuration", 60f, "Keep enemy health bars visible for this many seconds."); harmony.PatchAll(); } private void OnDestroy() { harmony.UnpatchSelf(); } } [HarmonyPatch] internal class CreatureTrackerPatch { [HarmonyPatch(typeof(Character), "Awake")] [HarmonyPostfix] private static void Character_Awake(Character __instance) { GameObject gameObject = ((Component)__instance).gameObject; Character component = gameObject.GetComponent<Character>(); if (component.IsPlayer()) { return; } string name = component.m_name; Sprite val = null; CharacterDrop component2 = gameObject.GetComponent<CharacterDrop>(); if ((Object)(object)component2 != (Object)null) { foreach (Drop drop in component2.m_drops) { bool flag = ((Object)drop.m_prefab).name.ToLower().StartsWith("trophy"); if (flag || (Object)(object)val == (Object)null) { val = drop.m_prefab.GetComponent<ItemDrop>().m_itemData.GetIcon(); if (flag) { break; } } } } gameObject.AddComponent<CreatureTrackerComponent>().Initialize(name, val, __instance.GetLevel(), isFish: false); } [HarmonyPatch(typeof(Fish), "Awake")] [HarmonyPostfix] private static void Fish_Awake(Fish __instance) { GameObject gameObject = ((Component)__instance).gameObject; ItemDrop component = ((Component)__instance).GetComponent<ItemDrop>(); if (!((Object)(object)component == (Object)null)) { string name = __instance.m_name; Sprite icon = component.m_itemData.GetIcon(); gameObject.AddComponent<CreatureTrackerComponent>().Initialize(name, icon, 0, isFish: true); } } [HarmonyPatch(typeof(Character), "SetLevel")] [HarmonyPostfix] private static void Character_SetLevel(Character __instance, int level) { ((Component)__instance).GetComponent<CreatureTrackerComponent>().SetLevel(__instance.GetLevel()); } [HarmonyPatch(typeof(Tameable), "Awake")] [HarmonyPostfix] private static void Tameable_Awake(Tameable __instance, Character ___m_character) { if (___m_character.IsTamed()) { ((Component)___m_character).GetComponent<CreatureTrackerComponent>().SetName(__instance.GetHoverName()); } } [HarmonyPatch(typeof(Tameable), "RPC_SetName")] [HarmonyPostfix] private static void Tameable_RPC_SetName(Tameable __instance, long sender, string name, string authorId) { ((Component)__instance).GetComponent<CreatureTrackerComponent>().SetName(__instance.GetHoverName()); } [HarmonyPatch(typeof(EnemyHud), "UpdateHuds")] [HarmonyPrefix] private static void EnemyHud_UpdateHuds(EnemyHud __instance, Player player, Sadle sadle, float dt) { __instance.m_maxShowDistance = CreatureTrackerMinimap.cfgHudDistance.Value; __instance.m_hoverShowDuration = CreatureTrackerMinimap.cfgHudDuration.Value; } }