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 ShowAllPossibleNewtLocations v1.0.0
ShowAllPossibleNewtLocations.dll
Decompiled 12 hours agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using Microsoft.CodeAnalysis; using RoR2; using RoR2.UI; using UnityEngine; using UnityEngine.SceneManagement; [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("ShowAllPossibleNewtLocations")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("ShowAllPossibleNewtLocations")] [assembly: AssemblyTitle("ShowAllPossibleNewtLocations")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [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 NewtRoutes { internal static class CandidateCollector { internal static bool IsAltarModel(string name) { if (!string.Equals(name, "mdlNewtStatue", StringComparison.OrdinalIgnoreCase) && !string.Equals(name, "mdlNewtStatue(Clone)", StringComparison.OrdinalIgnoreCase)) { return name?.StartsWith("mdlNewtStatue (", StringComparison.OrdinalIgnoreCase) ?? false; } return true; } internal static List<Vector3> Collect(Scene scene) { //IL_004c: Unknown result type (might be due to invalid IL or missing references) List<Vector3> list = new List<Vector3>(); if (!((Scene)(ref scene)).IsValid() || !((Scene)(ref scene)).isLoaded) { return list; } GameObject[] rootGameObjects = ((Scene)(ref scene)).GetRootGameObjects(); for (int i = 0; i < rootGameObjects.Length; i++) { Transform[] componentsInChildren = rootGameObjects[i].GetComponentsInChildren<Transform>(true); foreach (Transform val in componentsInChildren) { if (IsAltarModel(((Object)val).name)) { AddUnique(list, val.position); } } } return list; } internal static bool AddUnique(List<Vector3> points, Vector3 point) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0041: 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) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) if (float.IsNaN(point.x) || float.IsNaN(point.y) || float.IsNaN(point.z) || float.IsInfinity(point.x) || float.IsInfinity(point.y) || float.IsInfinity(point.z)) { return false; } foreach (Vector3 point2 in points) { Vector3 val = point2 - point; if (((Vector3)(ref val)).sqrMagnitude < 0.25f) { return false; } } points.Add(point); return true; } } [BepInPlugin("com.slapprt.newtroutes", "ShowAllPossibleNewtLocations", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class NewtRoutesPlugin : BaseUnityPlugin { public const string Guid = "com.slapprt.newtroutes"; public const string Version = "1.0.0"; private const string LocateNewtGuid = "com.yourname.NewtAltarBeacon"; private const string IndicatorPath = "Prefabs/PositionIndicators/TeleporterChargingPositionIndicator"; private readonly Dictionary<int, List<Vector3>> candidatesByScene = new Dictionary<int, List<Vector3>>(); private readonly List<GameObject> markers = new List<GameObject>(); private ConfigEntry<float> iconScale; private Coroutine refreshCoroutine; private Action<Stage> originalLocateNewtHandler; private BaseUnityPlugin originalLocateNewt; private void Awake() { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown iconScale = ((BaseUnityPlugin)this).Config.Bind<float>("Markers", "IconScale", 0.5f, new ConfigDescription("Icon width and height relative to LocateNewt/vanilla. 0.5 = 50% smaller.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 2f), Array.Empty<object>())); iconScale.SettingChanged += OnScaleChanged; SuppressOriginalLocator(); SceneManager.sceneLoaded += OnSceneLoaded; SceneManager.sceneUnloaded += OnSceneUnloaded; Stage.onStageStartGlobal += OnStageStart; Run.onRunDestroyGlobal += OnRunDestroyed; ((BaseUnityPlugin)this).Logger.LogInfo((object)("ShowAllPossibleNewtLocations 1.0.0: todos os pontos possíveis, sem revelar o altar sorteado. Escala: " + iconScale.Value)); } private void OnDestroy() { SceneManager.sceneLoaded -= OnSceneLoaded; SceneManager.sceneUnloaded -= OnSceneUnloaded; Stage.onStageStartGlobal -= OnStageStart; Run.onRunDestroyGlobal -= OnRunDestroyed; if (iconScale != null) { iconScale.SettingChanged -= OnScaleChanged; } OnRunDestroyed(null); if ((Object)(object)originalLocateNewt != (Object)null && originalLocateNewtHandler != null) { Stage.onStageStartGlobal += originalLocateNewtHandler; } } private void SuppressOriginalLocator() { if (!Chainloader.PluginInfos.TryGetValue("com.yourname.NewtAltarBeacon", out var value)) { return; } try { BaseUnityPlugin instance = value.Instance; MethodInfo method = ((object)instance).GetType().GetMethod("OnStageStart", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[1] { typeof(Stage) }, null); if (method == null) { throw new MissingMethodException("LocateNewt.OnStageStart"); } Action<Stage> action = (Action<Stage>)Delegate.CreateDelegate(typeof(Action<Stage>), instance, method); Stage.onStageStartGlobal -= action; originalLocateNewt = instance; originalLocateNewtHandler = action; object? obj = ((object)instance).GetType().GetField("altarIndicator", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(instance); Component val = (Component)((obj is Component) ? obj : null); if ((Object)(object)val != (Object)null) { Object.Destroy((Object)(object)val.gameObject); } ((BaseUnityPlugin)this).Logger.LogInfo((object)"Marcador do LocateNewt original suprimido nesta sessão; DLL original preservada."); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("Não foi possível suprimir esta versão do LocateNewt. Desative-o no gerenciador para não revelar o altar real. " + ex.Message)); } } private void OnSceneLoaded(Scene scene, LoadSceneMode mode) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) candidatesByScene[((Scene)(ref scene)).handle] = CandidateCollector.Collect(scene); } private void OnSceneUnloaded(Scene scene) { candidatesByScene.Remove(((Scene)(ref scene)).handle); ClearMarkers(); if (CanShowForStage(Stage.instance)) { BuildMarkers(); } } private void OnStageStart(Stage stage) { ClearMarkers(); if (refreshCoroutine != null) { ((MonoBehaviour)this).StopCoroutine(refreshCoroutine); } refreshCoroutine = ((MonoBehaviour)this).StartCoroutine(RefreshStage(stage)); } private IEnumerator RefreshStage(Stage stage) { yield return null; if (!CanShowForStage(stage)) { refreshCoroutine = null; yield break; } ScanLoadedScenes(); BuildMarkers(); yield return (object)new WaitForSecondsRealtime(1f); if (CanShowForStage(stage)) { int count = GetCandidatePoints().Count; ScanLoadedScenes(); if (GetCandidatePoints().Count != count) { BuildMarkers(); } ((BaseUnityPlugin)this).Logger.LogInfo((object)$"{stage.sceneDef.baseSceneName}: {markers.Count} locais possíveis marcados."); } refreshCoroutine = null; } private static bool CanShowForStage(Stage stage) { if ((Object)(object)Run.instance != (Object)null && (Object)(object)stage != (Object)null && (Object)(object)Stage.instance == (Object)(object)stage && (Object)(object)stage.sceneDef != (Object)null) { return !string.Equals(stage.sceneDef.baseSceneName, "bazaar", StringComparison.OrdinalIgnoreCase); } return false; } private void ScanLoadedScenes() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < SceneManager.sceneCount; i++) { Scene sceneAt = SceneManager.GetSceneAt(i); if (!((Scene)(ref sceneAt)).IsValid() || !((Scene)(ref sceneAt)).isLoaded) { continue; } if (!candidatesByScene.TryGetValue(((Scene)(ref sceneAt)).handle, out var value)) { candidatesByScene.Add(((Scene)(ref sceneAt)).handle, value = new List<Vector3>()); } foreach (Vector3 item in CandidateCollector.Collect(sceneAt)) { CandidateCollector.AddUnique(value, item); } } } private List<Vector3> GetCandidatePoints() { //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_0031: Unknown result type (might be due to invalid IL or missing references) List<Vector3> list = new List<Vector3>(); foreach (List<Vector3> value in candidatesByScene.Values) { foreach (Vector3 item in value) { CandidateCollector.AddUnique(list, item); } } return list; } private void BuildMarkers() { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) ClearMarkers(); GameObject val = LegacyResourcesAPI.Load<GameObject>("Prefabs/PositionIndicators/TeleporterChargingPositionIndicator"); if ((Object)(object)val == (Object)null) { ((BaseUnityPlugin)this).Logger.LogError((object)"Indicador nativo indisponível."); return; } Sprite val2 = LegacyResourcesAPI.Load<Sprite>("Textures/MiscIcons/texShopPortalIcon"); foreach (Vector3 candidatePoint in GetCandidatePoints()) { GameObject val3 = Object.Instantiate<GameObject>(val, candidatePoint + Vector3.up * 2f, Quaternion.identity); ((Object)val3).name = "NewtRoutes_Candidate"; markers.Add(val3); PositionIndicator component = val3.GetComponent<PositionIndicator>(); if ((Object)(object)component == (Object)null) { Object.Destroy((Object)(object)val3); continue; } component.targetTransform = null; Transform transform = val3.transform; transform.localScale *= iconScale.Value; ChargeIndicatorController[] componentsInChildren = val3.GetComponentsInChildren<ChargeIndicatorController>(true); SpriteRenderer[] iconSprites; foreach (ChargeIndicatorController val4 in componentsInChildren) { ((Behaviour)val4).enabled = false; if ((Object)(object)val4.chargingText != (Object)null) { ((Component)val4.chargingText).gameObject.SetActive(false); } if (!((Object)(object)val2 != (Object)null) || val4.iconSprites == null) { continue; } iconSprites = val4.iconSprites; foreach (SpriteRenderer val5 in iconSprites) { if ((Object)(object)val5 != (Object)null) { val5.sprite = val2; } } } iconSprites = val3.GetComponentsInChildren<SpriteRenderer>(true); for (int i = 0; i < iconSprites.Length; i++) { iconSprites[i].color = Color.cyan; } } } private void OnScaleChanged(object sender, EventArgs args) { if (CanShowForStage(Stage.instance)) { BuildMarkers(); } } private void ClearMarkers() { foreach (GameObject marker in markers) { if ((Object)(object)marker != (Object)null) { Object.Destroy((Object)(object)marker); } } markers.Clear(); } private void OnRunDestroyed(Run run) { if (refreshCoroutine != null) { ((MonoBehaviour)this).StopCoroutine(refreshCoroutine); } refreshCoroutine = null; ClearMarkers(); candidatesByScene.Clear(); } } }