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 PointCloud Dots Shader v1.0.0
DotsDotsDots.dll
Decompiled 8 months agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; 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 HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.Rendering; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: IgnoresAccessChecksTo("")] [assembly: AssemblyCompany("Omniscye")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("DotsDotsDots")] [assembly: AssemblyTitle("DotsDotsDots")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.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] [Microsoft.CodeAnalysis.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] [Microsoft.CodeAnalysis.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 Empress.OmniDots { [BepInPlugin("com.empress.omnidots", "OmniDots: Material Overwrite (No UI)", "1.3.0")] public sealed class OmniDotsPlugin : BaseUnityPlugin { private Harmony _harmony; private ConfigEntry<string> _bundleName; private ConfigEntry<string> _materialName; private ConfigEntry<string> _prefabName; private ConfigEntry<bool> _includeAllRenderers; private ConfigEntry<bool> _includeMap; private ConfigEntry<bool> _includeEnemies; private ConfigEntry<bool> _includeValuables; private ConfigEntry<bool> _includePhysObjects; private ConfigEntry<bool> _includeParticles; private ConfigEntry<bool> _includeSprites; private ConfigEntry<bool> _excludePlayers; private ConfigEntry<bool> _subdivideLargeTris; private ConfigEntry<int> _subdividePasses; private ConfigEntry<int> _vertexCountThreshold; private ConfigEntry<float> _minWorldExtent; private ConfigEntry<int> _maxVerticesAfter; private ConfigEntry<string> _dotColor; private ConfigEntry<string> _dotColorProperty; private ConfigEntry<bool> _enableHotkey; private ConfigEntry<string> _hotkey; private ConfigEntry<string> _cyclePalette; private KeyCode _cycleKey = (KeyCode)120; private void Awake() { //IL_0488: Unknown result type (might be due to invalid IL or missing references) //IL_0492: Expected O, but got Unknown //IL_04ab: Unknown result type (might be due to invalid IL or missing references) _bundleName = ((BaseUnityPlugin)this).Config.Bind<string>("OmniDotsAsset", "BundleFileName", "omnidots", "AssetBundle filename without extension (e.g., 'omnidots' or 'omnidots.bundle')."); _materialName = ((BaseUnityPlugin)this).Config.Bind<string>("OmniDotsAsset", "MaterialName", "CatFart", "Material name inside the bundle."); _prefabName = ((BaseUnityPlugin)this).Config.Bind<string>("OmniDotsAsset", "PrefabName", "CatFart", "Optional prefab that has a Renderer using the material (fallback)."); _includeAllRenderers = ((BaseUnityPlugin)this).Config.Bind<bool>("Targets", "IncludeAllRenderers", true, "Sweep ALL Renderers in the active scene (fast one-shot). Honors UI/overlay/player exclusions."); _includeMap = ((BaseUnityPlugin)this).Config.Bind<bool>("Targets", "IncludeMap", true, "Override LevelGenerator.LevelParent (walls/floors). Useful if the map lives under LevelParent."); _includeEnemies = ((BaseUnityPlugin)this).Config.Bind<bool>("Targets", "IncludeEnemies", true, "Override Enemy renderers."); _includeValuables = ((BaseUnityPlugin)this).Config.Bind<bool>("Targets", "IncludeValuables", true, "Override ValuableObject renderers."); _includePhysObjects = ((BaseUnityPlugin)this).Config.Bind<bool>("Targets", "IncludePhysObjects", true, "Override PhysGrabObject renderers."); _includeParticles = ((BaseUnityPlugin)this).Config.Bind<bool>("Filters", "IncludeParticles", false, "Also replace ParticleSystemRenderer materials."); _includeSprites = ((BaseUnityPlugin)this).Config.Bind<bool>("Filters", "IncludeSprites", false, "Also replace SpriteRenderer materials."); _excludePlayers = ((BaseUnityPlugin)this).Config.Bind<bool>("Filters", "ExcludePlayers", true, "Never touch player visuals and cameras."); _subdivideLargeTris = ((BaseUnityPlugin)this).Config.Bind<bool>("Subdivision", "Enable", true, "If a mesh is big but has very few vertices (eg. map floors/walls planes), clone and subdivide its visual mesh so dot shader has density."); _subdividePasses = ((BaseUnityPlugin)this).Config.Bind<int>("Subdivision", "Passes", 1, "Uniform midpoint subdivision passes (1..3). Each pass splits every triangle into 4."); _vertexCountThreshold = ((BaseUnityPlugin)this).Config.Bind<int>("Subdivision", "VertexThreshold", 500, "Only subdivide meshes with fewer than this many vertices."); _minWorldExtent = ((BaseUnityPlugin)this).Config.Bind<float>("Subdivision", "MinWorldExtent", 6f, "Only subdivide if object's world-space bounds' largest extent exceeds this (meters)."); _maxVerticesAfter = ((BaseUnityPlugin)this).Config.Bind<int>("Subdivision", "MaxVerticesAfter", 120000, "Safety cap to avoid blowing up memory."); _dotColor = ((BaseUnityPlugin)this).Config.Bind<string>("Appearance", "DotColor", "#FFFFFFFF", "Initial dot color. Accepts #RRGGBB[A] or r,g,b[,a] (0-255 or 0-1)."); _dotColorProperty = ((BaseUnityPlugin)this).Config.Bind<string>("Appearance", "DotColorProperty", "", "Exact shader property name to set (leave blank to auto-guess: _DotColor, _BaseColor, _Color, _Tint)."); _enableHotkey = ((BaseUnityPlugin)this).Config.Bind<bool>("Appearance", "EnableHotkey", true, "Enable runtime color cycling hotkey."); _hotkey = ((BaseUnityPlugin)this).Config.Bind<string>("Appearance", "Hotkey", "X", "Key to cycle dot color (KeyCode name or single char)."); _cyclePalette = ((BaseUnityPlugin)this).Config.Bind<string>("Appearance", "CyclePalette", "red,green,orange,pink,white", "Comma list of colors to cycle."); string source; Material val = LoadTargetMaterial(out source); if ((Object)(object)val == (Object)null) { ((BaseUnityPlugin)this).Logger.LogError((object)("OmniDots material not found. Provide a bundle with a Material named '" + _materialName.Value + "'.")); return; } if ((Object)(object)val.shader == (Object)null || !val.shader.isSupported) { ((BaseUnityPlugin)this).Logger.LogError((object)"OmniDots material's shader unsupported on this platform."); return; } OmniCore.Log = ((BaseUnityPlugin)this).Logger; OmniCore.TargetMat = val; SelectColorProperty(val); InitPaletteAndSetInitialColor(); ParseHotkey(); OmniCore.IncludeParticles = _includeParticles.Value; OmniCore.IncludeSprites = _includeSprites.Value; OmniCore.ExcludePlayers = _excludePlayers.Value; OmniCore.IncludeAllRenderers = _includeAllRenderers.Value; OmniCore.IncludeMap = _includeMap.Value; OmniCore.IncludeEnemies = _includeEnemies.Value; OmniCore.IncludeValuables = _includeValuables.Value; OmniCore.IncludePhysObjects = _includePhysObjects.Value; OmniCore.SubdivideLargeTris = _subdivideLargeTris.Value; OmniCore.SubdividePasses = Mathf.Clamp(_subdividePasses.Value, 0, 3); OmniCore.VertexCountThreshold = Mathf.Max(0, _vertexCountThreshold.Value); OmniCore.MinWorldExtent = Mathf.Max(0f, _minWorldExtent.Value); OmniCore.MaxVerticesAfter = Mathf.Max(65535, _maxVerticesAfter.Value); SceneManager.sceneLoaded += OnSceneLoaded; _harmony = new Harmony("com.empress.omnidots.harmony"); _harmony.PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)string.Format("OmniDots initialized. Source: {0}; Hotkey={1} Palette=[{2}]", source, _cycleKey, string.Join(",", OmniCore.CycleNames))); } private void Update() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0068: 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) //IL_006e: Unknown result type (might be due to invalid IL or missing references) if (_enableHotkey.Value && Input.GetKeyDown(_cycleKey) && OmniCore.CycleColors != null && OmniCore.CycleColors.Count > 0) { OmniCore.CycleIndex = (OmniCore.CycleIndex + 1) % OmniCore.CycleColors.Count; Color dotColor = OmniCore.CycleColors[OmniCore.CycleIndex]; OmniCore.SetDotColor(dotColor); ((BaseUnityPlugin)this).Logger.LogInfo((object)$"[OmniDots] Color -> {OmniCore.CycleNames[OmniCore.CycleIndex]} ({OmniCore.CycleIndex + 1}/{OmniCore.CycleColors.Count})"); } } private void OnDestroy() { try { Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } catch { } SceneManager.sceneLoaded -= OnSceneLoaded; } private void OnSceneLoaded(Scene s, LoadSceneMode m) { OmniCore.ResetProcessed(); OmniCore.ComputeOverlayMasks(); try { LevelGenerator instance = LevelGenerator.Instance; if ((Object)(object)instance != (Object)null && instance.Generated) { OmniCore.RunOneShotPass(); } } catch { } } private void SelectColorProperty(Material mat) { //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) string[] array = ((!string.IsNullOrWhiteSpace(_dotColorProperty.Value)) ? new string[1] { _dotColorProperty.Value } : new string[4] { "_DotColor", "_BaseColor", "_Color", "_Tint" }); string[] array2 = array; foreach (string text in array2) { int num = Shader.PropertyToID(text); try { if (mat.HasProperty(num)) { OmniCore.ColorPropId = num; ((BaseUnityPlugin)this).Logger.LogInfo((object)$"[OmniDots] Using color property '{text}' (id={num})."); return; } } catch { } } try { Color color = mat.color; OmniCore.UseMatColorFallback = true; ((BaseUnityPlugin)this).Logger.LogInfo((object)"[OmniDots] Using material.color fallback."); } catch { } } private void InitPaletteAndSetInitialColor() { //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: 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) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) OmniCore.CycleColors = new List<Color>(); OmniCore.CycleNames = new List<string>(); string[] array = (_cyclePalette.Value ?? "").Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries); string[] array2 = array; foreach (string text in array2) { string text2 = text.Trim(); if (TryParseAnyColor(text2, out var c)) { OmniCore.CycleColors.Add(c); OmniCore.CycleNames.Add(text2); } } if (OmniCore.CycleColors.Count == 0) { AddColorToPalette("red", Color.red); AddColorToPalette("green", Color.green); AddColorToPalette("orange", new Color(1f, 0.5f, 0f, 1f)); AddColorToPalette("pink", new Color(1f, 0.4f, 0.7f, 1f)); AddColorToPalette("white", Color.white); } if (TryParseAnyColor(_dotColor.Value, out var c2)) { OmniCore.SetDotColor(c2); OmniCore.CycleIndex = 0; } else { Color dotColor = OmniCore.CycleColors[0]; OmniCore.SetDotColor(dotColor); OmniCore.CycleIndex = 0; } } private void AddColorToPalette(string name, Color c) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) OmniCore.CycleColors.Add(c); OmniCore.CycleNames.Add(name); } private void ParseHotkey() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) string text = _hotkey.Value?.Trim(); if (string.IsNullOrEmpty(text)) { _cycleKey = (KeyCode)120; return; } if (text.Length == 1) { char c = char.ToUpperInvariant(text[0]); if (c >= 'A' && c <= 'Z') { _cycleKey = (KeyCode)Enum.Parse(typeof(KeyCode), c.ToString(), ignoreCase: true); return; } if (c >= '0' && c <= '9') { _cycleKey = (KeyCode)Enum.Parse(typeof(KeyCode), "Alpha" + c, ignoreCase: true); return; } } if (Enum.TryParse<KeyCode>(text, ignoreCase: true, out KeyCode result)) { _cycleKey = result; } else { _cycleKey = (KeyCode)120; } } private bool TryParseAnyColor(string token, out Color c) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) c = Color.white; if (string.IsNullOrWhiteSpace(token)) { return false; } if (TryNamed(token, out c)) { return true; } if (token[0] != '#' && ColorUtility.TryParseHtmlString("#" + token, ref c)) { return true; } if (ColorUtility.TryParseHtmlString(token, ref c)) { return true; } try { string[] array = token.Split(','); if (array.Length >= 3) { float[] array2 = new float[4] { 1f, 1f, 1f, 1f }; bool flag = false; for (int i = 0; i < array.Length && i < 4; i++) { if (float.TryParse(array[i].Trim(), NumberStyles.Float, CultureInfo.InvariantCulture, out var result)) { array2[i] = result; if (result > 1.001f) { flag = true; } } } if (flag) { for (int j = 0; j < 4; j++) { array2[j] = Mathf.Clamp01(array2[j] / 255f); } } c = new Color(array2[0], array2[1], array2[2], (array.Length >= 4) ? array2[3] : 1f); return true; } } catch { } return false; } private bool TryNamed(string n, out Color c) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Unknown result type (might be due to invalid IL or missing references) //IL_02fc: Unknown result type (might be due to invalid IL or missing references) //IL_0301: 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_0397: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_028f: Unknown result type (might be due to invalid IL or missing references) //IL_02e9: Unknown result type (might be due to invalid IL or missing references) //IL_02ee: Unknown result type (might be due to invalid IL or missing references) //IL_0323: 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_034a: Unknown result type (might be due to invalid IL or missing references) //IL_034f: Unknown result type (might be due to invalid IL or missing references) //IL_02c3: Unknown result type (might be due to invalid IL or missing references) //IL_02c8: Unknown result type (might be due to invalid IL or missing references) //IL_02d6: Unknown result type (might be due to invalid IL or missing references) //IL_02db: Unknown result type (might be due to invalid IL or missing references) //IL_036e: Unknown result type (might be due to invalid IL or missing references) //IL_0373: Unknown result type (might be due to invalid IL or missing references) //IL_02b0: Unknown result type (might be due to invalid IL or missing references) //IL_02b5: Unknown result type (might be due to invalid IL or missing references) //IL_029d: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_03b6: Unknown result type (might be due to invalid IL or missing references) //IL_03bb: Unknown result type (might be due to invalid IL or missing references) c = Color.white; switch (n.Trim().ToLowerInvariant()) { case "red": c = Color.red; return true; case "green": c = Color.green; return true; case "blue": c = Color.blue; return true; case "cyan": c = Color.cyan; return true; case "magenta": c = Color.magenta; return true; case "yellow": c = Color.yellow; return true; case "white": c = Color.white; return true; case "black": c = Color.black; return true; case "gray": case "grey": c = Color.gray; return true; case "orange": c = new Color(1f, 0.5f, 0f, 1f); return true; case "pink": c = new Color(1f, 0.4f, 0.7f, 1f); return true; case "purple": c = new Color(0.5f, 0.1f, 0.7f, 1f); return true; case "teal": c = new Color(0f, 0.5f, 0.5f, 1f); return true; case "lime": c = new Color(0.6f, 1f, 0f, 1f); return true; default: return false; } } private Material LoadTargetMaterial(out string source) { source = "<none>"; try { string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location); List<string> list = new List<string>(); if (!string.IsNullOrEmpty(directoryName)) { list.Add(Path.Combine(directoryName, _bundleName.Value)); list.Add(Path.Combine(directoryName, _bundleName.Value + ".bundle")); list.Add(Path.Combine(directoryName, _bundleName.Value + ".assets")); } list.Add(Path.Combine(Paths.PluginPath, _bundleName.Value)); list.Add(Path.Combine(Paths.PluginPath, _bundleName.Value + ".bundle")); list.Add(Path.Combine(Paths.PluginPath, _bundleName.Value + ".assets")); list.Add(Path.Combine(Paths.GameRootPath, _bundleName.Value)); list.Add(Path.Combine(Paths.GameRootPath, _bundleName.Value + ".bundle")); list.Add(Path.Combine(Paths.GameRootPath, _bundleName.Value + ".assets")); string text = list.FirstOrDefault(File.Exists); if (string.IsNullOrEmpty(text)) { return null; } AssetBundle val = AssetBundle.LoadFromFile(text); if ((Object)(object)val == (Object)null) { return null; } Material val2 = val.LoadAsset<Material>(_materialName.Value); if ((Object)(object)val2 != (Object)null) { source = "Material '" + _materialName.Value + "'"; return val2; } GameObject val3 = val.LoadAsset<GameObject>(_prefabName.Value); if ((Object)(object)val3 != (Object)null) { Renderer componentInChildren = val3.GetComponentInChildren<Renderer>(true); if ((Object)(object)componentInChildren != (Object)null) { if ((Object)(object)componentInChildren.sharedMaterial != (Object)null) { source = "Prefab renderer material"; return componentInChildren.sharedMaterial; } if (componentInChildren.sharedMaterials != null && componentInChildren.sharedMaterials.Length != 0) { source = "Prefab first sharedMaterial"; return componentInChildren.sharedMaterials[0]; } } } string[] allAssetNames = val.GetAllAssetNames(); foreach (string text2 in allAssetNames) { if (text2.EndsWith(".mat", StringComparison.OrdinalIgnoreCase) && text2.IndexOf(_materialName.Value, StringComparison.OrdinalIgnoreCase) >= 0) { Material val4 = val.LoadAsset<Material>(text2); if ((Object)(object)val4 != (Object)null) { source = "Material '" + text2 + "'"; return val4; } } } return null; } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("Material load failed: " + ex)); return null; } } } internal static class OmniCore { private struct EdgeKey : IEquatable<EdgeKey> { public int A; public int B; public EdgeKey(int a, int b) { if (a < b) { A = a; B = b; } else { A = b; B = a; } } public bool Equals(EdgeKey other) { return A == other.A && B == other.B; } public override bool Equals(object obj) { return obj is EdgeKey other && Equals(other); } public override int GetHashCode() { return (A * 73856093) ^ (B * 19349663); } } public static ManualLogSource Log; public static Material TargetMat; public static bool IncludeParticles; public static bool IncludeSprites; public static bool ExcludePlayers; public static bool IncludeAllRenderers; public static bool IncludeMap; public static bool IncludeEnemies; public static bool IncludeValuables; public static bool IncludePhysObjects; public static bool SubdivideLargeTris; public static int SubdividePasses; public static int VertexCountThreshold; public static float MinWorldExtent; public static int MaxVerticesAfter; public static int ColorPropId = -1; public static bool UseMatColorFallback = false; public static List<Color> CycleColors = new List<Color>(); public static List<string> CycleNames = new List<string>(); public static int CycleIndex = 0; private static readonly HashSet<int> done = new HashSet<int>(); private static readonly HashSet<int> subdividedMeshes = new HashSet<int>(); private static int overlayOnlyMask = 0; private static int baseMask = -1; public static void ResetProcessed() { done.Clear(); } public static void SetDotColor(Color c) { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) try { if (!((Object)(object)TargetMat == (Object)null)) { if (ColorPropId >= 0 && TargetMat.HasProperty(ColorPropId)) { TargetMat.SetColor(ColorPropId, c); } else if (UseMatColorFallback) { Color color = TargetMat.color; TargetMat.color = c; } } } catch (Exception ex) { ManualLogSource log = Log; if (log != null) { log.LogInfo((object)("SetDotColor failed: " + ex.Message)); } } } public static void ComputeOverlayMasks() { overlayOnlyMask = 0; baseMask = -1; try { Camera[] allCameras = Camera.allCameras; if (allCameras == null || allCameras.Length == 0) { return; } Camera val = null; float num = float.PositiveInfinity; Camera[] array = allCameras; foreach (Camera val2 in array) { if (!((Object)(object)val2 == (Object)null) && ((Behaviour)val2).enabled && val2.depth < num) { num = val2.depth; val = val2; } } if ((Object)(object)val == (Object)null) { return; } baseMask = val.cullingMask; int num2 = 0; Camera[] array2 = allCameras; foreach (Camera val3 in array2) { if (!((Object)(object)val3 == (Object)null) && ((Behaviour)val3).enabled && !((Object)(object)val3 == (Object)(object)val) && val3.depth >= val.depth) { num2 |= val3.cullingMask; } } overlayOnlyMask = num2 & ~baseMask; ManualLogSource log = Log; if (log != null) { log.LogInfo((object)$"OverlayOnlyMask=0x{overlayOnlyMask:X}"); } } catch (Exception ex) { ManualLogSource log2 = Log; if (log2 != null) { log2.LogInfo((object)("ComputeOverlayMasks failed: " + ex.Message)); } } } public static void RunOneShotPass() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)TargetMat == (Object)null) { return; } try { Scene activeScene = SceneManager.GetActiveScene(); if (!((Scene)(ref activeScene)).IsValid() || !((Scene)(ref activeScene)).isLoaded) { return; } if (IncludeAllRenderers) { GameObject[] rootGameObjects = ((Scene)(ref activeScene)).GetRootGameObjects(); foreach (GameObject val in rootGameObjects) { if ((Object)(object)val == (Object)null) { continue; } try { if (IsLikelyUIRoot(val)) { continue; } } catch { } OmniDotsUnder(val); } } if (IncludeMap) { GameObject val2 = TryGetLevelParent(); if ((Object)(object)val2 != (Object)null) { OmniDotsUnder(val2); } } if (IncludeEnemies) { Enemy[] array = Object.FindObjectsOfType<Enemy>(true); foreach (Enemy val3 in array) { if (!((Object)(object)val3 == (Object)null) && !(((Component)val3).gameObject.scene != activeScene)) { OmniDotsUnder(((Component)val3).gameObject); } } } if (IncludeValuables) { ValuableObject[] array2 = Object.FindObjectsOfType<ValuableObject>(true); foreach (ValuableObject val4 in array2) { if (!((Object)(object)val4 == (Object)null) && !(((Component)val4).gameObject.scene != activeScene)) { OmniDotsUnder(((Component)val4).gameObject); } } } if (!IncludePhysObjects) { return; } PhysGrabObject[] array3 = Object.FindObjectsOfType<PhysGrabObject>(true); foreach (PhysGrabObject val5 in array3) { if (!((Object)(object)val5 == (Object)null) && !(((Component)val5).gameObject.scene != activeScene)) { OmniDotsUnder(((Component)val5).gameObject); } } } catch (Exception ex) { ManualLogSource log = Log; if (log != null) { log.LogError((object)("One-shot pass failed: " + ex)); } } } private static GameObject TryGetLevelParent() { try { LevelGenerator instance = LevelGenerator.Instance; if ((Object)(object)instance != (Object)null && (Object)(object)instance.LevelParent != (Object)null) { return instance.LevelParent; } } catch { } return null; } public static void OmniDotsUnder(GameObject root) { if (!((Object)(object)TargetMat == (Object)null) && !((Object)(object)root == (Object)null)) { Renderer[] componentsInChildren = root.GetComponentsInChildren<Renderer>(true); for (int i = 0; i < componentsInChildren.Length; i++) { Apply(componentsInChildren[i]); } } } public static void Apply(Renderer r) { if ((Object)(object)r == (Object)null || (Object)(object)TargetMat == (Object)null || (!IncludeParticles && r is ParticleSystemRenderer) || (!IncludeSprites && r is SpriteRenderer) || (ExcludePlayers && IsPlayerRelated(r)) || IsOverlayRelated(r) || IsUI(r)) { return; } try { int num = 1 << ((Component)r).gameObject.layer; if ((overlayOnlyMask & num) != 0) { return; } } catch { } if (SubdivideLargeTris) { MeshRenderer val = (MeshRenderer)(object)((r is MeshRenderer) ? r : null); if (val != null) { TrySubdivideVisualMesh(val); } } int instanceID = ((Object)r).GetInstanceID(); if (done.Contains(instanceID)) { return; } try { Material[] sharedMaterials = r.sharedMaterials; if (sharedMaterials == null || sharedMaterials.Length == 0) { r.sharedMaterial = TargetMat; } else { for (int i = 0; i < sharedMaterials.Length; i++) { sharedMaterials[i] = TargetMat; } r.sharedMaterials = sharedMaterials; } done.Add(instanceID); } catch (Exception ex) { ManualLogSource log = Log; if (log != null) { log.LogInfo((object)("Skip '" + ((Object)r).name + "' (" + ((object)r).GetType().Name + "): " + ex.Message)); } } } private static void TrySubdivideVisualMesh(MeshRenderer mr) { //IL_0056: Unknown result type (might be due to invalid IL or missing references) try { MeshFilter component = ((Component)mr).GetComponent<MeshFilter>(); if ((Object)(object)component == (Object)null) { return; } Mesh sharedMesh = component.sharedMesh; if ((Object)(object)sharedMesh == (Object)null || subdividedMeshes.Contains(((Object)sharedMesh).GetInstanceID())) { return; } float maxWorldExtent = GetMaxWorldExtent(((Component)mr).transform, sharedMesh.bounds); if (sharedMesh.vertexCount >= VertexCountThreshold || maxWorldExtent < MinWorldExtent) { return; } if (!sharedMesh.isReadable) { ManualLogSource log = Log; if (log != null) { log.LogInfo((object)("[OmniDots] '" + ((Object)mr).name + "' mesh not readable; cannot subdivide. Consider enabling Read/Write on level meshes.")); } return; } Mesh val = Object.Instantiate<Mesh>(sharedMesh); int num = Mathf.Clamp(SubdividePasses, 0, 3); if (num > 0) { if (!UniformSubdivideInPlace(val, num, MaxVerticesAfter)) { val.Clear(); Object.Destroy((Object)(object)val); } else { component.sharedMesh = val; subdividedMeshes.Add(((Object)val).GetInstanceID()); } } } catch (Exception ex) { ManualLogSource log2 = Log; if (log2 != null) { log2.LogInfo((object)("Subdivide failed on '" + ((Object)mr).name + "': " + ex.Message)); } } } private static float GetMaxWorldExtent(Transform t, Bounds b) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) Vector3 lossyScale = t.lossyScale; Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(((Bounds)(ref b)).size.x * Mathf.Abs(lossyScale.x), ((Bounds)(ref b)).size.y * Mathf.Abs(lossyScale.y), ((Bounds)(ref b)).size.z * Mathf.Abs(lossyScale.z)); return Mathf.Max(val.x, Mathf.Max(val.y, val.z)); } private static bool UniformSubdivideInPlace(Mesh m, int passes, int maxVerts) { //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Invalid comparison between Unknown and I4 List<Vector3> v = new List<Vector3>(); List<Vector3> n = new List<Vector3>(); List<Vector4> t = new List<Vector4>(); List<Vector2> uv = new List<Vector2>(); List<Color> c = new List<Color>(); m.GetVertices(v); m.GetNormals(n); m.GetTangents(t); m.GetUVs(0, uv); m.GetColors(c); bool flag = n != null && n.Count == v.Count; bool flag2 = t != null && t.Count == v.Count; bool flag3 = uv != null && uv.Count == v.Count; bool flag4 = c != null && c.Count == v.Count; if (v.Count > 65535) { m.indexFormat = (IndexFormat)1; } int subMeshCount = m.subMeshCount; List<int>[] array = new List<int>[subMeshCount]; for (int i = 0; i < subMeshCount; i++) { array[i] = new List<int>(); } for (int j = 0; j < passes; j++) { Dictionary<EdgeKey, int> cache = new Dictionary<EdgeKey, int>(1024); for (int k = 0; k < subMeshCount; k++) { MeshTopology topology = m.GetTopology(k); if ((int)topology <= 0) { int[] triangles = m.GetTriangles(k); array[k].Clear(); for (int l = 0; l < triangles.Length; l += 3) { int num = triangles[l]; int num2 = triangles[l + 1]; int num3 = triangles[l + 2]; int mid = GetMid(num, num2, ref v, ref n, ref t, ref uv, ref c, flag, flag2, flag3, flag4, cache); int mid2 = GetMid(num2, num3, ref v, ref n, ref t, ref uv, ref c, flag, flag2, flag3, flag4, cache); int mid3 = GetMid(num3, num, ref v, ref n, ref t, ref uv, ref c, flag, flag2, flag3, flag4, cache); array[k].Add(num); array[k].Add(mid); array[k].Add(mid3); array[k].Add(mid); array[k].Add(num2); array[k].Add(mid2); array[k].Add(mid3); array[k].Add(mid2); array[k].Add(num3); array[k].Add(mid); array[k].Add(mid2); array[k].Add(mid3); } } } if (v.Count > maxVerts) { return false; } m.SetVertices(v); if (flag) { m.SetNormals(n); } if (flag2) { m.SetTangents(t); } if (flag3) { m.SetUVs(0, uv); } if (flag4) { m.SetColors(c); } if (v.Count > 65535) { m.indexFormat = (IndexFormat)1; } for (int num4 = 0; num4 < subMeshCount; num4++) { m.SetTriangles(array[num4], num4, true); } } m.RecalculateBounds(); if (!flag) { try { m.RecalculateNormals(); } catch { } } return true; } private static int GetMid(int a, int b, ref List<Vector3> v, ref List<Vector3> n, ref List<Vector4> t, ref List<Vector2> uv, ref List<Color> c, bool hasN, bool hasT, bool hasUV, bool hasC, Dictionary<EdgeKey, int> cache) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: 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_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0091: 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) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: 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_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) EdgeKey key = new EdgeKey(a, b); if (cache.TryGetValue(key, out var value)) { return value; } Vector3 val = v[a]; Vector3 val2 = v[b]; int count = v.Count; v.Add((val + val2) * 0.5f); if (hasN) { List<Vector3> obj = n; Vector3 val3 = n[a] + n[b]; obj.Add(((Vector3)(ref val3)).normalized); } if (hasT) { Vector4 val4 = t[a]; Vector4 val5 = t[b]; Vector4 item = (val4 + val5) * 0.5f; item.w = val4.w; t.Add(item); } if (hasUV) { uv.Add((uv[a] + uv[b]) * 0.5f); } if (hasC) { c.Add((c[a] + c[b]) * 0.5f); } cache[key] = count; return count; } private static bool IsLikelyUIRoot(GameObject go) { if ((Object)(object)go == (Object)null) { return false; } try { if (go.layer == LayerMask.NameToLayer("UI")) { return true; } } catch { } try { if ((Object)(object)go.GetComponentInChildren<Canvas>(true) != (Object)null) { return true; } } catch { } return false; } private static bool IsUI(Renderer r) { try { if ((Object)(object)((Component)r).GetComponentInParent<Canvas>(true) != (Object)null) { return true; } } catch { } try { if (((Component)r).gameObject.layer == LayerMask.NameToLayer("UI")) { return true; } } catch { } return false; } private static bool IsOverlayRelated(Renderer r) { GameObject gameObject = ((Component)r).gameObject; if ((Object)(object)gameObject.GetComponentInParent<Camera>(true) != (Object)null) { return true; } if ((Object)(object)gameObject.GetComponentInParent<CameraOverlay>(true) != (Object)null) { return true; } if ((Object)(object)gameObject.GetComponentInParent<CameraTopFade>(true) != (Object)null) { return true; } if ((Object)(object)gameObject.GetComponentInParent<SpiralOnScreen>(true) != (Object)null) { return true; } return false; } private static bool IsPlayerRelated(Renderer r) { GameObject gameObject = ((Component)r).gameObject; try { if (gameObject.CompareTag("Player")) { return true; } } catch { } try { if (gameObject.layer == LayerMask.NameToLayer("Player")) { return true; } } catch { } if ((Object)(object)gameObject.GetComponentInParent<PlayerAvatarVisuals>(true) != (Object)null) { return true; } if ((Object)(object)gameObject.GetComponentInParent<PlayerAvatar>(true) != (Object)null) { return true; } if ((Object)(object)gameObject.GetComponentInParent<PlayerHealth>(true) != (Object)null) { return true; } if ((Object)(object)gameObject.GetComponentInParent<PlayerEyes>(true) != (Object)null) { return true; } if ((Object)(object)gameObject.GetComponentInParent<PlayerAvatarRightArm>(true) != (Object)null) { return true; } if ((Object)(object)gameObject.GetComponentInParent<PlayerAvatarLeftArm>(true) != (Object)null) { return true; } if ((Object)(object)gameObject.GetComponentInParent<PlayerAvatarEyelids>(true) != (Object)null) { return true; } if ((Object)(object)gameObject.GetComponentInParent<PlayerAvatarOverchargeVisuals>(true) != (Object)null) { return true; } return false; } } [HarmonyPatch] internal static class Patches { [HarmonyPostfix] [HarmonyPatch(typeof(LevelGenerator), "GenerateDone")] private static void LevelGenDone_Postfix() { OmniCore.ComputeOverlayMasks(); OmniCore.RunOneShotPass(); } [HarmonyPostfix] [HarmonyPatch(typeof(Enemy), "Awake")] private static void Enemy_Awake_Postfix(Enemy __instance) { if (!((Object)(object)__instance == (Object)null) && OmniCore.IncludeEnemies) { OmniCore.OmniDotsUnder(((Component)__instance).gameObject); } } [HarmonyPostfix] [HarmonyPatch(typeof(ValuableObject), "Awake")] private static void Valuable_Awake_Postfix(ValuableObject __instance) { if (!((Object)(object)__instance == (Object)null) && OmniCore.IncludeValuables) { OmniCore.OmniDotsUnder(((Component)__instance).gameObject); } } [HarmonyPostfix] [HarmonyPatch(typeof(PhysGrabObject), "Awake")] private static void Phys_Awake_Postfix(PhysGrabObject __instance) { if (!((Object)(object)__instance == (Object)null) && OmniCore.IncludePhysObjects) { OmniCore.OmniDotsUnder(((Component)__instance).gameObject); } } } } namespace DotsDotsDots { [BepInPlugin("Omniscye.DotsDotsDots", "DotsDotsDots", "1.0")] public class DotsDotsDots : BaseUnityPlugin { internal static DotsDotsDots Instance { get; private set; } internal static ManualLogSource Logger => Instance._logger; private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger; internal Harmony? Harmony { get; set; } private void Awake() { Instance = this; ((Component)this).gameObject.transform.parent = null; ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; Patch(); Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!"); } internal void Patch() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown //IL_0026: Expected O, but got Unknown if (Harmony == null) { Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID); Harmony val2 = val; Harmony = val; } Harmony.PatchAll(); } internal void Unpatch() { Harmony? harmony = Harmony; if (harmony != null) { harmony.UnpatchSelf(); } } private void Update() { } } }