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 Cosmetics Radar v1.0.5
Cosmetics_Radar.dll
Decompiled 2 days agousing System; using System.Collections.Generic; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Photon.Pun; using UnityEngine; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: AssemblyVersion("0.0.0.0")] namespace CosmeticsRadarMod; [BepInPlugin("com.atakakota.cosmeticsradar", "Cosmetics Radar", "1.0.5")] public class CosmeticsRadarPlugin : BaseUnityPlugin { public class CosmeticLEDInfo { public GameObject ledObject; public Material ledMaterial; public CosmeticWorldObject cosmeticWorldObject; public Color color = Color.white; public bool isExtracted = false; public bool isDestroyed = false; } public static CosmeticsRadarPlugin Instance; public static ConfigEntry<bool> RadarEnabled; public static ConfigEntry<float> DetectionDistanceMax; public static ConfigEntry<float> DetectionDistanceMin; public static ConfigEntry<float> LedXOffset; public static List<CosmeticLEDInfo> ledInfos = new List<CosmeticLEDInfo>(); public static float blinkTimer = 0f; private void Awake() { //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Expected O, but got Unknown Instance = this; RadarEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "RadarEnabled", true, "Enable LED cosmetic tracker on map tool"); DetectionDistanceMax = ((BaseUnityPlugin)this).Config.Bind<float>("Settings", "DetectionDistanceMax", 30f, "Max detection distance for slow blink"); DetectionDistanceMin = ((BaseUnityPlugin)this).Config.Bind<float>("Settings", "DetectionDistanceMin", 5f, "Min detection distance for fast blink"); LedXOffset = ((BaseUnityPlugin)this).Config.Bind<float>("Positioning", "LedXOffset", -0.0685f, "Horizontal position of the LEDs on the bezel (more negative = further left, away from screen)"); SceneManager.activeSceneChanged += OnSceneChanged; Harmony val = new Harmony("com.atakakota.cosmeticsradar"); val.PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Cosmetics Radar v1.0.5 loaded successfully!"); } private void OnDestroy() { SceneManager.activeSceneChanged -= OnSceneChanged; } private void OnSceneChanged(Scene oldScene, Scene newScene) { ledInfos.Clear(); blinkTimer = 0f; } public static void QuickRerollLevel(bool newTheme) { try { if ((Object)(object)RunManager.instance == (Object)null || !SemiFunc.RunIsLevel()) { return; } Traverse val = Traverse.Create((object)RunManager.instance); if (val.Field<bool>("restarting").Value || (SemiFunc.IsMultiplayer() && !PhotonNetwork.IsMasterClient)) { return; } if ((Object)(object)DebugCommandHandler.instance != (Object)null) { Traverse val2 = Traverse.Create((object)DebugCommandHandler.instance); val2.Method("ResetLevelProgress", new object[0]).GetValue(); val2.Method("CommandSuccessEffect", new object[0]).GetValue(); } if (newTheme) { RunManager.instance.ChangeLevel(false, false, (ChangeLevelType)1); return; } RunManager.instance.RestartScene(); if (!SemiFunc.RunIsTutorial()) { val.Field("gameOver").SetValue((object)false); SemiFunc.OnSceneSwitch(false, false); } } catch (Exception ex) { Debug.LogError((object)("[Cosmetics Radar] Quick restart error: " + ex)); } } private void Update() { //IL_0321: Unknown result type (might be due to invalid IL or missing references) //IL_0326: Unknown result type (might be due to invalid IL or missing references) //IL_0290: Unknown result type (might be due to invalid IL or missing references) //IL_0295: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_0299: Unknown result type (might be due to invalid IL or missing references) //IL_02a5: Unknown result type (might be due to invalid IL or missing references) //IL_02a7: Unknown result type (might be due to invalid IL or missing references) //IL_0375: Unknown result type (might be due to invalid IL or missing references) //IL_037a: Unknown result type (might be due to invalid IL or missing references) //IL_038d: Unknown result type (might be due to invalid IL or missing references) //IL_0392: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_02cb: Unknown result type (might be due to invalid IL or missing references) //IL_02cd: Unknown result type (might be due to invalid IL or missing references) //IL_03e3: Unknown result type (might be due to invalid IL or missing references) //IL_03f0: Unknown result type (might be due to invalid IL or missing references) //IL_03f5: Unknown result type (might be due to invalid IL or missing references) //IL_03fc: Unknown result type (might be due to invalid IL or missing references) //IL_0401: Unknown result type (might be due to invalid IL or missing references) //IL_0406: Unknown result type (might be due to invalid IL or missing references) //IL_04b5: Unknown result type (might be due to invalid IL or missing references) //IL_0427: Unknown result type (might be due to invalid IL or missing references) //IL_0434: Unknown result type (might be due to invalid IL or missing references) //IL_049b: Unknown result type (might be due to invalid IL or missing references) //IL_04a2: Unknown result type (might be due to invalid IL or missing references) //IL_04a7: Unknown result type (might be due to invalid IL or missing references) if (!RadarEnabled.Value) { foreach (CosmeticLEDInfo ledInfo in ledInfos) { if ((Object)(object)ledInfo.ledObject != (Object)null && ledInfo.ledObject.activeSelf) { ledInfo.ledObject.SetActive(false); } } return; } PlayerAvatar val = null; if ((Object)(object)PlayerController.instance != (Object)null) { val = PlayerController.instance.playerAvatarScript; } if ((Object)(object)val == (Object)null) { return; } bool flag = SemiFunc.RunIsLevel(); bool flag2 = false; if ((Object)(object)MapToolController.instance != (Object)null) { try { flag2 = Traverse.Create((object)MapToolController.instance).Field<bool>("Active").Value; } catch { } } bool flag3 = flag && flag2; foreach (CosmeticLEDInfo ledInfo2 in ledInfos) { if ((Object)(object)ledInfo2.ledObject != (Object)null && ledInfo2.ledObject.activeSelf != flag3) { ledInfo2.ledObject.SetActive(flag3); } } if (!flag3) { blinkTimer = 0f; { foreach (CosmeticLEDInfo ledInfo3 in ledInfos) { if ((Object)(object)ledInfo3.ledMaterial != (Object)null) { ledInfo3.ledMaterial.SetColor("_EmissionColor", Color.black); } } return; } } if ((Object)(object)RoundDirector.instance != (Object)null && RoundDirector.instance.cosmeticWorldObjects != null) { List<CosmeticWorldObject> cosmeticWorldObjects = RoundDirector.instance.cosmeticWorldObjects; for (int i = 0; i < cosmeticWorldObjects.Count && i < ledInfos.Count; i++) { CosmeticWorldObject val2 = cosmeticWorldObjects[i]; if (!((Object)(object)val2 != (Object)null) || !((Object)(object)ledInfos[i].cosmeticWorldObject == (Object)null)) { continue; } ledInfos[i].cosmeticWorldObject = val2; try { Color value = Traverse.Create((object)val2).Field<Color>("blinkMaterialDefault").Value; if (value != Color.clear && value != Color.black) { ledInfos[i].color = value; } } catch { } } } blinkTimer += Time.deltaTime; Vector3 position = ((Component)val).transform.position; float value2 = DetectionDistanceMax.Value; float value3 = DetectionDistanceMin.Value; foreach (CosmeticLEDInfo ledInfo4 in ledInfos) { if (!((Object)(object)ledInfo4.ledMaterial == (Object)null)) { Color val3 = Color.black; if (ledInfo4.isExtracted) { val3 = ledInfo4.color; } else if (ledInfo4.isDestroyed) { float num = Mathf.Sin(blinkTimer * 1.25f * (float)Math.PI * 2f); float num2 = Mathf.Pow((num + 1f) * 0.5f, 2.857143f); val3 = ledInfo4.color * (1f - num2) + Color.red * num2; } else if ((Object)(object)ledInfo4.cosmeticWorldObject != (Object)null) { float num3 = Vector3.Distance(position, ((Component)ledInfo4.cosmeticWorldObject).transform.position); float num4 = Mathf.InverseLerp(value2, value3, num3); float num5 = Mathf.Lerp(1f, 2.75f, num4); float num = Mathf.Sin(blinkTimer * num5 * (float)Math.PI * 2f); float num6 = Mathf.SmoothStep(0f, 1f, (num + 1f) * 0.5f); val3 = ledInfo4.color * num6; } ledInfo4.ledMaterial.SetColor("_EmissionColor", val3); } } } } [HarmonyPatch(typeof(MapToolController), "Start")] public static class Patch_MapToolController_Start { public static void Postfix(MapToolController __instance) { //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_0294: Unknown result type (might be due to invalid IL or missing references) //IL_029b: Expected O, but got Unknown //IL_02af: Unknown result type (might be due to invalid IL or missing references) //IL_02c1: Unknown result type (might be due to invalid IL or missing references) //IL_0306: Unknown result type (might be due to invalid IL or missing references) //IL_0328: Unknown result type (might be due to invalid IL or missing references) //IL_03e8: Unknown result type (might be due to invalid IL or missing references) //IL_03ed: Unknown result type (might be due to invalid IL or missing references) //IL_03ef: Unknown result type (might be due to invalid IL or missing references) //IL_03f1: Unknown result type (might be due to invalid IL or missing references) //IL_03fd: Unknown result type (might be due to invalid IL or missing references) //IL_03ff: Unknown result type (might be due to invalid IL or missing references) //IL_0423: Unknown result type (might be due to invalid IL or missing references) //IL_0425: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)__instance == (Object)null) { return; } if (GameManager.Multiplayer()) { PhotonView component = ((Component)__instance).GetComponent<PhotonView>(); if ((Object)(object)component != (Object)null && !component.IsMine) { return; } } try { CosmeticsRadarPlugin.ledInfos.Clear(); Transform val = Traverse.Create((object)__instance).Field<Transform>("displaySpringTransform").Value; if ((Object)(object)val == (Object)null) { val = ((Component)__instance).transform; } Transform val2 = val.Find("LED - L"); GameObject val3 = (((Object)(object)val2 != (Object)null) ? ((Component)val2).gameObject : null); Renderer val4 = (((Object)(object)val3 != (Object)null) ? val3.GetComponent<Renderer>() : null); int num = 5; if ((Object)(object)ValuableDirector.instance != (Object)null) { num = ValuableDirector.instance.cosmeticWorldObjectsLevelLoopsMax + 1; } num = Mathf.Clamp(num, 1, 8); float num2 = 0.025f; float num3 = 0.1f + (float)(num - 1) * num2 * 0.5f; float num4 = ((CosmeticsRadarPlugin.LedXOffset != null) ? CosmeticsRadarPlugin.LedXOffset.Value : (-0.0685f)); for (int i = 0; i < num; i++) { GameObject val5; Material val6; if ((Object)(object)val3 != (Object)null && (Object)(object)val4 != (Object)null) { val5 = Object.Instantiate<GameObject>(val3, val, false); ((Object)val5).name = "Left Side LED - Cosmetics Indicator " + (i + 1); val6 = Object.Instantiate<Material>(val4.material); ((Object)val6).name = "Dirt Finder - LED Cosmetics Indicator " + (i + 1); val6.SetColor("_Color", Color.black); val6.SetColor("_EmissionColor", Color.black); Renderer component2 = val5.GetComponent<Renderer>(); if ((Object)(object)component2 != (Object)null) { component2.material = val6; } val5.transform.localScale = val3.transform.localScale; val5.transform.localPosition = new Vector3(num4, 0f, num3 - (float)i * num2); } else { val5 = GameObject.CreatePrimitive((PrimitiveType)0); ((Object)val5).name = "CosmeticsRadar_LED_" + i; val5.transform.SetParent(val, false); Collider component3 = val5.GetComponent<Collider>(); if ((Object)(object)component3 != (Object)null) { Object.Destroy((Object)(object)component3); } val6 = new Material(Shader.Find("Universal Render Pipeline/Lit") ?? Shader.Find("Standard")); val6.EnableKeyword("_EMISSION"); val6.SetColor("_Color", Color.black); val6.SetColor("_EmissionColor", Color.black); Renderer component2 = val5.GetComponent<Renderer>(); if ((Object)(object)component2 != (Object)null) { component2.material = val6; } val5.transform.localScale = new Vector3(0.012f, 0.012f, 0.012f); val5.transform.localPosition = new Vector3(num4, 0f, num3 - (float)i * num2); } CosmeticsRadarPlugin.CosmeticLEDInfo cosmeticLEDInfo = new CosmeticsRadarPlugin.CosmeticLEDInfo(); cosmeticLEDInfo.ledObject = val5; cosmeticLEDInfo.ledMaterial = val6; CosmeticsRadarPlugin.ledInfos.Add(cosmeticLEDInfo); } CosmeticWorldObject[] array = Object.FindObjectsOfType<CosmeticWorldObject>(); if (array == null) { return; } int num5 = 0; CosmeticWorldObject[] array2 = array; foreach (CosmeticWorldObject val7 in array2) { if ((Object)(object)val7 != (Object)null && num5 < CosmeticsRadarPlugin.ledInfos.Count) { CosmeticsRadarPlugin.ledInfos[num5].cosmeticWorldObject = val7; Color value = Traverse.Create((object)val7).Field<Color>("blinkMaterialDefault").Value; if (value != Color.clear && value != Color.black) { CosmeticsRadarPlugin.ledInfos[num5].color = value; } num5++; } } } catch (Exception ex) { Debug.LogError((object)("[Cosmetics Radar] Failed to initialize map LEDs: " + ex)); } } } [HarmonyPatch(typeof(CosmeticWorldObject), "Start")] public static class Patch_CosmeticWorldObject_Start { public static void Postfix(CosmeticWorldObject __instance, Color ___blinkMaterialDefault) { //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)__instance == (Object)null) { return; } try { foreach (CosmeticsRadarPlugin.CosmeticLEDInfo ledInfo in CosmeticsRadarPlugin.ledInfos) { if ((Object)(object)ledInfo.cosmeticWorldObject == (Object)null || (Object)(object)ledInfo.cosmeticWorldObject == (Object)(object)__instance) { ledInfo.cosmeticWorldObject = __instance; ledInfo.color = ___blinkMaterialDefault; ledInfo.isExtracted = false; ledInfo.isDestroyed = false; break; } } } catch (Exception) { } } } [HarmonyPatch(typeof(CosmeticWorldObject), "ExtractRPC")] public static class Patch_CosmeticWorldObject_ExtractRPC { public static void Postfix(CosmeticWorldObject __instance) { if ((Object)(object)__instance == (Object)null) { return; } try { foreach (CosmeticsRadarPlugin.CosmeticLEDInfo ledInfo in CosmeticsRadarPlugin.ledInfos) { if ((Object)(object)ledInfo.cosmeticWorldObject == (Object)(object)__instance) { ledInfo.isExtracted = true; break; } } } catch (Exception) { } } } [HarmonyPatch(typeof(PhysGrabObject), "DestroyPhysGrabObject")] public static class Patch_PhysGrabObject_DestroyPhysGrabObject { public static void Postfix(PhysGrabObject __instance) { if ((Object)(object)__instance == (Object)null) { return; } try { CosmeticWorldObject val = ((Component)__instance).GetComponent<CosmeticWorldObject>(); if ((Object)(object)val == (Object)null) { val = ((Component)__instance).GetComponentInParent<CosmeticWorldObject>(); } if (!((Object)(object)val != (Object)null)) { return; } foreach (CosmeticsRadarPlugin.CosmeticLEDInfo ledInfo in CosmeticsRadarPlugin.ledInfos) { if ((Object)(object)ledInfo.cosmeticWorldObject == (Object)(object)val) { ledInfo.isDestroyed = true; break; } } } catch (Exception) { } } } [HarmonyPatch(typeof(PlayerAvatar), "ChatMessageSend")] public static class Patch_PlayerAvatar_ChatMessageSend { public static bool Prefix(PlayerAvatar __instance, string _message) { if (string.IsNullOrEmpty(_message)) { return true; } string text = _message.Trim().ToLowerInvariant(); switch (text) { default: if (!(text == "/level refresh")) { if (text == "/random" || text == "/level random") { CosmeticsRadarPlugin.QuickRerollLevel(newTheme: true); return false; } return true; } goto case "/reroll"; case "/reroll": case "/restart": case "/rr": case "/refresh": CosmeticsRadarPlugin.QuickRerollLevel(newTheme: false); return false; } } }