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 LootPulse v1.0.2
plugins\HiarlyScripter-LootPulse\LootPulse.dll
Decompiled 9 hours agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("LootPulse")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("LootPulse")] [assembly: AssemblyTitle("LootPulse")] [assembly: AssemblyVersion("1.0.0.0")] namespace LootPulse; [BepInPlugin("com.hiarlyscripter.repo.lootpulse", "LootPulse", "1.0.0")] public sealed class LootPulsePlugin : BaseUnityPlugin { internal static ConfigEntry<KeyCode> ScanKey; internal static ConfigEntry<float> ScanRange; internal static ConfigEntry<float> CooldownSeconds; internal static ConfigEntry<bool> EnableVisualBrackets; internal static ConfigEntry<bool> EnableMapIcons; internal static ConfigEntry<bool> RequireLevelOrRun; internal static ConfigEntry<bool> VerboseLogging; private float _lastScanTime = -999f; private static bool _discoverApiChecked; private static MethodInfo _discoverWithState; private static MethodInfo _discoverNoParam; private static object _discoverStateValue; internal static LootPulsePlugin Instance { get; private set; } internal static ManualLogSource Log { get; private set; } private void Awake() { //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Expected O, but got Unknown //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Expected O, but got Unknown //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) Instance = this; Log = ((BaseUnityPlugin)this).Logger; ScanKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Scanner", "ScanKey", (KeyCode)102, "Tecla para ativar o scanner de valuables."); ScanRange = ((BaseUnityPlugin)this).Config.Bind<float>("Scanner", "ScanRange", 30f, new ConfigDescription("Raio de detecção em metros.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(5f, 200f), Array.Empty<object>())); CooldownSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("Scanner", "CooldownSeconds", 4f, new ConfigDescription("Segundos mínimos entre dois scans consecutivos.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 60f), Array.Empty<object>())); EnableVisualBrackets = ((BaseUnityPlugin)this).Config.Bind<bool>("Scanner", "EnableVisualBrackets", true, "Exibir brackets visuais de descoberta nos valuables encontrados."); EnableMapIcons = ((BaseUnityPlugin)this).Config.Bind<bool>("Scanner", "EnableMapIcons", true, "Adicionar ícone de valuable no mapa ao escanear."); RequireLevelOrRun = ((BaseUnityPlugin)this).Config.Bind<bool>("Scanner", "RequireLevelOrRun", true, "Só escanear durante runs ativas (nível gerado). Desative para testar fora de um nível."); VerboseLogging = ((BaseUnityPlugin)this).Config.Bind<bool>("Scanner", "VerboseLogging", false, "Logar detalhes de cada item processado individualmente."); ManualLogSource log = Log; KeyCode value = ScanKey.Value; log.LogInfo((object)("[LootPulse] v1.0.0 carregado. Pressione " + ((object)(KeyCode)(ref value)).ToString() + " para escanear valuables.")); } private void Update() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) if (!Input.GetKeyDown(ScanKey.Value)) { return; } float time = Time.time; float num = time - _lastScanTime; if (num < CooldownSeconds.Value) { float num2 = CooldownSeconds.Value - num; Log.LogInfo((object)$"[LootPulse] Cooldown ativo: {num2:F1}s restantes."); return; } if (RequireLevelOrRun.Value) { bool flag = false; try { flag = SemiFunc.RunIsLevel(); } catch (Exception ex) { Log.LogWarning((object)("[LootPulse] RunIsLevel falhou (" + ex.Message + "). Prosseguindo sem validação.")); flag = true; } if (!flag) { if (VerboseLogging.Value) { Log.LogInfo((object)"[LootPulse] Ignorado — não está em nível ativo."); } return; } } _lastScanTime = time; RunScan(); } private void RunScan() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) Vector3 zero = Vector3.zero; try { PlayerAvatar val = SemiFunc.PlayerAvatarLocal(); if ((Object)(object)val == (Object)null) { Log.LogWarning((object)"[LootPulse] PlayerAvatarLocal retornou null. Abortando scan."); return; } if ((Object)(object)val.playerTransform == (Object)null) { Log.LogWarning((object)"[LootPulse] playerTransform é null. Abortando scan."); return; } zero = val.playerTransform.position; } catch (Exception ex) { Log.LogWarning((object)("[LootPulse] Erro ao obter posição do jogador: " + ex.Message + ". Abortando.")); return; } List<PhysGrabObject> list = null; bool flag = false; try { list = SemiFunc.PhysGrabObjectAllValuablesWithinRange(ScanRange.Value, zero, false, default(LayerMask)); flag = true; } catch (Exception ex2) { Log.LogWarning((object)("[LootPulse] PhysGrabObjectAllValuablesWithinRange falhou (" + ex2.Message + "). Usando fallback.")); list = FindValuablesFallback(zero, ScanRange.Value); } int num = list?.Count ?? 0; int num2 = 0; int num3 = 0; int num4 = 0; Log.LogInfo((object)($"[LootPulse] Scan executado | origem={zero:F1} | range={ScanRange.Value}m | " + "api=" + (flag ? "SemiFunc.PhysGrabObjectAllValuablesWithinRange" : "FindObjectsOfType fallback") + " | " + $"encontrados={num}")); if (list != null) { foreach (PhysGrabObject item in list) { if ((Object)(object)item == (Object)null) { continue; } try { ValuableObject component = ((Component)item).GetComponent<ValuableObject>(); if ((Object)(object)component == (Object)null) { if (VerboseLogging.Value) { Log.LogDebug((object)("[LootPulse] Sem ValuableObject em: " + ((Object)item).name)); } continue; } if (VerboseLogging.Value) { Log.LogDebug((object)("[LootPulse] Processando: " + ((Object)item).name)); } if (EnableVisualBrackets.Value && TryApplyBrackets(component)) { num2++; } if (EnableMapIcons.Value && TryAddToMap(component)) { num3++; } } catch (Exception ex3) { num4++; Log.LogWarning((object)("[LootPulse] Erro ao processar " + ((item != null) ? ((Object)item).name : null) + ": " + ex3.Message)); } } } Log.LogInfo((object)($"[LootPulse] Resultado | brackets={num2}/{num} | " + $"mapa={num3}/{num} | erros={num4}")); } private static bool TryApplyBrackets(ValuableObject vo) { try { ResolveDiscoverApi(); if (_discoverWithState != null) { _discoverWithState.Invoke(vo, new object[1] { _discoverStateValue }); return true; } if (_discoverNoParam != null) { _discoverNoParam.Invoke(vo, null); return true; } return false; } catch (Exception ex) { if (VerboseLogging.Value) { ManualLogSource log = Log; if (log != null) { log.LogDebug((object)("[LootPulse] Discover exception: " + ex.Message)); } } return false; } } private static void ResolveDiscoverApi() { if (_discoverApiChecked) { return; } _discoverApiChecked = true; Type typeFromHandle = typeof(ValuableObject); BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public; Type type = null; Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); for (int i = 0; i < assemblies.Length; i++) { type = assemblies[i].GetType("ValuableDiscoverGraphic"); if (type != null) { break; } } if (type != null) { Type nestedType = type.GetNestedType("State", BindingFlags.Public); if (nestedType != null && nestedType.IsEnum) { MethodInfo method = typeFromHandle.GetMethod("Discover", bindingAttr, null, new Type[1] { nestedType }, null); if (method != null) { _discoverWithState = method; _discoverStateValue = Enum.Parse(nestedType, "Discover"); ManualLogSource log = Log; if (log != null) { log.LogInfo((object)"[LootPulse] Discover API resolvida: ValuableObject.Discover(ValuableDiscoverGraphic.State)"); } return; } } } MethodInfo method2 = typeFromHandle.GetMethod("Discover", bindingAttr, null, Type.EmptyTypes, null); if (method2 != null) { _discoverNoParam = method2; ManualLogSource log2 = Log; if (log2 != null) { log2.LogInfo((object)"[LootPulse] Discover API resolvida: ValuableObject.Discover() [fallback sem parâmetro]"); } } else { ManualLogSource log3 = Log; if (log3 != null) { log3.LogWarning((object)"[LootPulse] Discover API não encontrada em nenhuma forma. Brackets visuais desabilitados."); } } } private static bool TryAddToMap(ValuableObject vo) { try { Map instance = Map.Instance; if ((Object)(object)instance == (Object)null) { if (VerboseLogging.Value) { ManualLogSource log = Log; if (log != null) { log.LogDebug((object)"[LootPulse] Map.Instance é null."); } } return false; } instance.AddValuable(vo); return true; } catch (Exception ex) { if (VerboseLogging.Value) { ManualLogSource log2 = Log; if (log2 != null) { log2.LogDebug((object)("[LootPulse] Map.AddValuable falhou: " + ex.Message)); } } return false; } } private static List<PhysGrabObject> FindValuablesFallback(Vector3 origin, float range) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) List<PhysGrabObject> list = new List<PhysGrabObject>(); float num = range * range; ValuableObject[] array = Object.FindObjectsOfType<ValuableObject>(); foreach (ValuableObject val in array) { if ((Object)(object)val == (Object)null) { continue; } Vector3 val2 = ((Component)val).transform.position - origin; if (!(((Vector3)(ref val2)).sqrMagnitude > num)) { PhysGrabObject component = ((Component)val).GetComponent<PhysGrabObject>(); if ((Object)(object)component != (Object)null) { list.Add(component); } } } ManualLogSource log = Log; if (log != null) { log.LogInfo((object)$"[LootPulse] Fallback: {list.Count} valuables encontrados via FindObjectsOfType."); } return list; } }