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 Sense v1.0.3
Sense.dll
Decompiled 28 minutes agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using Microsoft.CodeAnalysis; 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: IgnoresAccessChecksTo("")] [assembly: AssemblyCompany("headclef")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.3.0")] [assembly: AssemblyInformationalVersion("1.0.3+05483145082e0c48c4b3d1797b7fde25a147b067")] [assembly: AssemblyProduct("Sense")] [assembly: AssemblyTitle("Sense")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.3.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace Sense { internal static class EnemyRadar { private struct Marker { public GameObject Src; public MapCustomEntity Entity; } private const float ScanInterval = 0.2f; private static float _nextScan; private static readonly Dictionary<EnemyParent, Marker> _markers = new Dictionary<EnemyParent, Marker>(); private static readonly List<EnemyParent> _remove = new List<EnemyParent>(); private static Sprite? _blip; internal static void Tick() { //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) if (!Sense.Enabled.Value || (Object)(object)Map.Instance == (Object)null || !SemiFunc.RunIsLevel()) { if (_markers.Count > 0) { ClearAll(); } } else { if (Time.time < _nextScan) { return; } _nextScan = Time.time + 0.2f; PlayerController instance = PlayerController.instance; EnemyDirector instance2 = EnemyDirector.instance; if ((Object)(object)instance == (Object)null || (Object)(object)instance2 == (Object)null) { return; } Vector3 position = ((Component)instance).transform.position; float value = Sense.Radius.Value; float sqrRadius = value * value; Color color = MarkerColor(); foreach (EnemyParent item in instance2.enemiesSpawned) { if (!IsTrackable(item, position, sqrRadius)) { continue; } if (_markers.TryGetValue(item, out var value2)) { if ((Object)(object)value2.Entity != (Object)null && (Object)(object)value2.Src != (Object)null) { continue; } DestroyMarker(item); } if (TryCreateMarker(item, color, out var marker)) { _markers[item] = marker; } } _remove.Clear(); foreach (KeyValuePair<EnemyParent, Marker> marker2 in _markers) { if (!IsTrackable(marker2.Key, position, sqrRadius)) { _remove.Add(marker2.Key); } } foreach (EnemyParent item2 in _remove) { DestroyMarker(item2); } } } private static bool IsTrackable(EnemyParent? enemy, Vector3 origin, float sqrRadius) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)enemy == (Object)null || !enemy.Spawned) { return false; } Transform val = Anchor(enemy); if ((Object)(object)val == (Object)null) { return false; } Vector3 val2 = val.position - origin; return ((Vector3)(ref val2)).sqrMagnitude <= sqrRadius; } private static Transform? Anchor(EnemyParent enemy) { Enemy enemy2 = enemy.Enemy; if ((Object)(object)enemy2 == (Object)null) { return null; } if (!((Object)(object)enemy2.CenterTransform != (Object)null)) { return ((Component)enemy2).transform; } return enemy2.CenterTransform; } private static bool TryCreateMarker(EnemyParent enemy, Color color, out Marker marker) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) marker = default(Marker); Transform val = Anchor(enemy); if ((Object)(object)val == (Object)null) { return false; } GameObject val2 = new GameObject("SenseEnemyMarker"); val2.transform.SetParent(val, false); val2.transform.localPosition = Vector3.zero; MapCustom val3 = val2.AddComponent<MapCustom>(); val3.autoAdd = false; val3.color = color; val3.sprite = Blip(); Map.Instance.AddCustom(val3, val3.sprite, color); if ((Object)(object)val3.mapCustomEntity == (Object)null) { Object.Destroy((Object)(object)val2); return false; } marker = new Marker { Src = val2, Entity = val3.mapCustomEntity }; return true; } private static void DestroyMarker(EnemyParent enemy) { if (_markers.TryGetValue(enemy, out var value)) { if ((Object)(object)value.Entity != (Object)null) { Object.Destroy((Object)(object)((Component)value.Entity).gameObject); } if ((Object)(object)value.Src != (Object)null) { Object.Destroy((Object)(object)value.Src); } } _markers.Remove(enemy); } internal static void ClearAll() { foreach (KeyValuePair<EnemyParent, Marker> marker in _markers) { if ((Object)(object)marker.Value.Entity != (Object)null) { Object.Destroy((Object)(object)((Component)marker.Value.Entity).gameObject); } if ((Object)(object)marker.Value.Src != (Object)null) { Object.Destroy((Object)(object)marker.Value.Src); } } _markers.Clear(); } private static Sprite Blip() { if ((Object)(object)_blip != (Object)null) { return _blip; } GameObject val = (((Object)(object)Map.Instance != (Object)null) ? Map.Instance.ValuableObject : null); MapValuable val2 = (((Object)(object)val != (Object)null) ? val.GetComponent<MapValuable>() : null); _blip = (Sprite?)(((Object)(object)val2 != (Object)null && (Object)(object)val2.spriteSmall != (Object)null) ? ((object)val2.spriteSmall) : ((object)MakeDot())); return _blip; } private static Color MarkerColor() { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) string value = Sense.MarkerColor.Value; Color result = default(Color); if (!string.IsNullOrWhiteSpace(value) && ColorUtility.TryParseHtmlString("#" + value.TrimStart('#'), ref result)) { result.a = 1f; return result; } return Color.red; } private static Sprite MakeDot() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_0050: 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_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(32, 32, (TextureFormat)4, false) { wrapMode = (TextureWrapMode)1, filterMode = (FilterMode)1 }; float num = 16f; Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(num - 0.5f, num - 0.5f); Color[] array = (Color[])(object)new Color[1024]; for (int i = 0; i < 32; i++) { for (int j = 0; j < 32; j++) { float num2 = Vector2.Distance(new Vector2((float)j, (float)i), val2); float num3 = Mathf.Clamp01(num - 1f - num2); array[i * 32 + j] = new Color(1f, 1f, 1f, num3); } } val.SetPixels(array); val.Apply(); return Sprite.Create(val, new Rect(0f, 0f, 32f, 32f), new Vector2(0.5f, 0.5f), 100f); } } [BepInPlugin("headclef.Sense", "Sense", "1.0.3")] public class Sense : BaseUnityPlugin { private const string PluginGuid = "headclef.Sense"; private const string PluginName = "Sense"; private const string PluginVersion = "1.0.3"; internal static ConfigEntry<bool> Enabled; internal static ConfigEntry<float> Radius; internal static ConfigEntry<string> MarkerColor; internal static Sense Instance { get; private set; } internal static ManualLogSource Logger => Instance._logger; private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger; private void Awake() { Instance = this; ((Component)this).gameObject.transform.parent = null; ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; BindConfiguration(); Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!"); } private void Update() { EnemyRadar.Tick(); } private void OnDestroy() { EnemyRadar.ClearAll(); } private void BindConfiguration() { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Sense", "Enabled", true, "Master switch. While on, enemies within range are continuously marked on the map."); Radius = ((BaseUnityPlugin)this).Config.Bind<float>("Sense", "Radius", 30f, new ConfigDescription("Radius in meters around you within which enemies are marked on the map.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(5f, 100f), Array.Empty<object>())); MarkerColor = ((BaseUnityPlugin)this).Config.Bind<string>("Sense", "Marker Color", "FF0000", "Hex RGB colour of the enemy map markers (e.g. FF0000 = red, FF8800 = orange)."); } } }