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 AggresiveMaterialFix v1.0.3
AggresiveMaterialFix.dll
Decompiled 2 years 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 DunGen; using LethalLevelLoader; using LethalLib.Modules; using Microsoft.CodeAnalysis; using On; using UnityEngine; using UnityEngine.Events; 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("AmazingAssets.TerrainToMesh")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: IgnoresAccessChecksTo("ClientNetworkTransform")] [assembly: IgnoresAccessChecksTo("DissonanceVoip")] [assembly: IgnoresAccessChecksTo("Facepunch Transport for Netcode for GameObjects")] [assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")] [assembly: IgnoresAccessChecksTo("Newtonsoft.Json")] [assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")] [assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging")] [assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging.DocCodeExamples")] [assembly: IgnoresAccessChecksTo("Unity.Burst")] [assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")] [assembly: IgnoresAccessChecksTo("Unity.Collections")] [assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")] [assembly: IgnoresAccessChecksTo("Unity.Jobs")] [assembly: IgnoresAccessChecksTo("Unity.Mathematics")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.Common")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.MetricTypes")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStats")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Component")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Configuration")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Implementation")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsReporting")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkProfiler.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkSolutionInterface")] [assembly: IgnoresAccessChecksTo("Unity.Netcode.Components")] [assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.Networking.Transport")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Csg")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.KdTree")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Poly2Tri")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Stl")] [assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Config.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")] [assembly: IgnoresAccessChecksTo("Unity.Services.Authentication")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Analytics")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Configuration")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Device")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments.Internal")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Internal")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Networking")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Registration")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Scheduler")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Telemetry")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Threading")] [assembly: IgnoresAccessChecksTo("Unity.Services.QoS")] [assembly: IgnoresAccessChecksTo("Unity.Services.Relay")] [assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")] [assembly: IgnoresAccessChecksTo("Unity.Timeline")] [assembly: IgnoresAccessChecksTo("Unity.VisualEffectGraph.Runtime")] [assembly: IgnoresAccessChecksTo("UnityEngine.AccessibilityModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.AIModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.AndroidJNIModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.AnimationModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.AssetBundleModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.AudioModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.ClothModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.ClusterInputModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.ClusterRendererModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.ContentLoadModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.CoreModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.CrashReportingModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.DirectorModule")] [assembly: IgnoresAccessChecksTo("UnityEngine")] [assembly: IgnoresAccessChecksTo("UnityEngine.DSPGraphModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.GameCenterModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.GIModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.GridModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.HotReloadModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.ImageConversionModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.IMGUIModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.InputLegacyModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.InputModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.JSONSerializeModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.LocalizationModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.ParticleSystemModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.PerformanceReportingModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.Physics2DModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.PhysicsModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.ProfilerModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.PropertiesModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.RuntimeInitializeOnLoadManagerInitializerModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.ScreenCaptureModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.SharedInternalsModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.SpriteMaskModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.SpriteShapeModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.StreamingModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.SubstanceModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.SubsystemsModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.TerrainModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.TerrainPhysicsModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.TextCoreFontEngineModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.TextCoreTextEngineModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.TextRenderingModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.TilemapModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.TLSModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.UI")] [assembly: IgnoresAccessChecksTo("UnityEngine.UIElementsModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.UIModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.UmbraModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.UnityAnalyticsCommonModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.UnityAnalyticsModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.UnityConnectModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.UnityCurlModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.UnityTestProtocolModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.UnityWebRequestAssetBundleModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.UnityWebRequestAudioModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.UnityWebRequestModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.UnityWebRequestTextureModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.UnityWebRequestWWWModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.VehiclesModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.VFXModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.VideoModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.VirtualTexturingModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.VRModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.WindModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.XRModule")] [assembly: AssemblyCompany("Noosh")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.3.0")] [assembly: AssemblyInformationalVersion("1.0.3")] [assembly: AssemblyProduct("AggresiveMaterialFix")] [assembly: AssemblyTitle("AggresiveMaterialFix")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.3.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 AggresiveMaterialFix { public static class MaterialFix { [CompilerGenerated] private static class <>O { public static hook_Start <0>__RoundManager_Start; public static UnityAction<Scene, LoadSceneMode> <1>__FixCurrentLevel; } public static bool doLog = false; public static Dictionary<string, Shader> shaders = new Dictionary<string, Shader>(); public static Dictionary<int, Shader> oldShaders = new Dictionary<int, Shader>(); public static string logPrefix = ""; internal static void TestPatch() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown doLog = P.logMaterials.Value; object obj = <>O.<0>__RoundManager_Start; if (obj == null) { hook_Start val = RoundManager_Start; <>O.<0>__RoundManager_Start = val; obj = (object)val; } RoundManager.Start += (hook_Start)obj; } private static void RoundManager_Start(orig_Start orig, RoundManager self) { orig.Invoke(self); FixAllCustomPrefabs(); SceneManager.sceneLoaded += FixCurrentLevel; } public static void FixRenderer(Component obj) { Renderer[] componentsInChildren = obj.GetComponentsInChildren<Renderer>(); foreach (Renderer val in componentsInChildren) { Material[] sharedMaterials = val.sharedMaterials; foreach (Material val2 in sharedMaterials) { if (!Object.op_Implicit((Object)(object)val2)) { continue; } if (doLog && !oldShaders.ContainsKey(((object)val2.shader).GetHashCode())) { oldShaders[((object)val2.shader).GetHashCode()] = val2.shader; } if (val2.IsKeywordEnabled("_MAPPING_TRIPLANAR") || val2.IsKeywordEnabled("_MAPPING_PLANAR")) { if (doLog) { P.Log($"{logPrefix}/{((Object)((Component)val).gameObject).name}/{((Object)val2).name}/{((Object)val2.shader).name} * {((object)val2.shader).GetHashCode()} : SKIPPED", (LogLevel)8); P.Log(string.Join(", ", val2.shaderKeywords), (LogLevel)8); } continue; } int renderQueue = val2.renderQueue; if (!shaders.TryGetValue(((Object)val2.shader).name, out Shader value)) { shaders[((Object)val2.shader).name] = Shader.Find(((Object)val2.shader).name); } if (!Object.op_Implicit((Object)(object)value)) { if (doLog) { P.Log($"{logPrefix}/{((Object)((Component)val).gameObject).name}/{((Object)val2).name}/{((Object)val2.shader).name} * {((object)val2.shader).GetHashCode()} : NO REPLACEMENT", (LogLevel)8); P.Log(string.Join(", ", val2.shaderKeywords), (LogLevel)8); } continue; } val2.shader = value; val2.renderQueue = renderQueue; if (doLog) { P.Log($"{logPrefix}/{((Object)((Component)val).gameObject).name}/{((Object)val2).name}/{((Object)value).name} * {((object)val2.shader).GetHashCode()} - {renderQueue}", (LogLevel)8); P.Log(string.Join(", ", val2.shaderKeywords), (LogLevel)8); } } } } public static void FixCurrentLevel(Scene _, LoadSceneMode __) { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)LevelManager.CurrentExtendedLevel != (Object)null) || !LevelManager.CurrentExtendedLevel.IsLevelLoaded) { return; } if (doLog) { P.Log("--- LEVEL ---", (LogLevel)8); } Scene sceneByName = SceneManager.GetSceneByName(LevelManager.CurrentExtendedLevel.SelectableLevel.sceneName); GameObject[] rootGameObjects = ((Scene)(ref sceneByName)).GetRootGameObjects(); foreach (GameObject val in rootGameObjects) { if (doLog) { logPrefix = LevelManager.CurrentExtendedLevel.SelectableLevel.sceneName + "/" + ((Object)val).name; } FixRenderer((Component)(object)val.transform); } } public static void FixAllCustomPrefabs() { if (doLog) { P.Log("--- DUNGEONS ---", (LogLevel)8); } foreach (ExtendedDungeonFlow customExtendedDungeonFlow in PatchedContent.CustomExtendedDungeonFlows) { foreach (Tile tile in Extensions.GetTiles(customExtendedDungeonFlow.DungeonFlow)) { if (doLog) { logPrefix = ((Object)customExtendedDungeonFlow).name + "/" + ((Object)tile).name; } FixRenderer((Component)(object)tile); } } if (doLog) { P.Log("--- ITEMS ---", (LogLevel)8); } foreach (ExtendedItem customExtendedItem in PatchedContent.CustomExtendedItems) { if (doLog) { logPrefix = ((Object)customExtendedItem.Item).name; } FixRenderer((Component)(object)customExtendedItem.Item.spawnPrefab.transform); } if (doLog) { P.Log("--- ITEMS (LethalLib) ---", (LogLevel)8); } foreach (ScrapItem scrapItem in Items.scrapItems) { if (doLog) { logPrefix = ((Object)scrapItem.item).name; } FixRenderer((Component)(object)scrapItem.item.spawnPrefab.transform); } foreach (ShopItem shopItem in Items.shopItems) { if (doLog) { logPrefix = ((Object)shopItem.item).name; } FixRenderer((Component)(object)shopItem.item.spawnPrefab.transform); } foreach (PlainItem plainItem in Items.plainItems) { if (doLog) { logPrefix = ((Object)plainItem.item).name; } FixRenderer((Component)(object)plainItem.item.spawnPrefab.transform); } if (doLog) { P.Log("--- ENEMIES ---", (LogLevel)8); } foreach (ExtendedEnemyType customExtendedEnemyType in PatchedContent.CustomExtendedEnemyTypes) { if (doLog) { logPrefix = ((Object)customExtendedEnemyType.EnemyType).name; } FixRenderer((Component)(object)customExtendedEnemyType.EnemyType.enemyPrefab.transform); if (Object.op_Implicit((Object)(object)customExtendedEnemyType.EnemyType.nestSpawnPrefab)) { if (doLog) { logPrefix = ((Object)customExtendedEnemyType.EnemyType).name + "/" + ((Object)customExtendedEnemyType.EnemyType.nestSpawnPrefab).name; } FixRenderer((Component)(object)customExtendedEnemyType.EnemyType.nestSpawnPrefab.transform); } } if (doLog) { P.Log("--- ENEMIES (LethalLib) ---", (LogLevel)8); } foreach (SpawnableEnemy spawnableEnemy in Enemies.spawnableEnemies) { if (doLog) { logPrefix = ((Object)spawnableEnemy.enemy).name; } FixRenderer((Component)(object)spawnableEnemy.enemy.enemyPrefab.transform); if (Object.op_Implicit((Object)(object)spawnableEnemy.enemy.nestSpawnPrefab)) { if (doLog) { logPrefix = ((Object)spawnableEnemy.enemy).name + "/" + ((Object)spawnableEnemy.enemy.nestSpawnPrefab).name; } FixRenderer((Component)(object)spawnableEnemy.enemy.nestSpawnPrefab.transform); } } if (doLog) { P.Log("--- car ---", (LogLevel)8); } foreach (ExtendedBuyableVehicle customExtendedBuyableVehicle in PatchedContent.CustomExtendedBuyableVehicles) { if (doLog) { logPrefix = customExtendedBuyableVehicle.BuyableVehicle.vehicleDisplayName; } FixRenderer((Component)(object)customExtendedBuyableVehicle.BuyableVehicle.vehiclePrefab.transform); if (Object.op_Implicit((Object)(object)customExtendedBuyableVehicle.BuyableVehicle.secondaryPrefab)) { if (doLog) { logPrefix = customExtendedBuyableVehicle.BuyableVehicle.vehicleDisplayName + "/" + ((Object)customExtendedBuyableVehicle.BuyableVehicle.secondaryPrefab).name; } FixRenderer((Component)(object)customExtendedBuyableVehicle.BuyableVehicle.secondaryPrefab.transform); } } if (doLog) { P.Log("Shaders fixed: " + string.Join(", ", shaders.Keys), (LogLevel)8); } } } [BepInPlugin("AggresiveMaterialFix", "AggresiveMaterialFix", "1.0.3")] public class P : BaseUnityPlugin { public static P Instance; internal static ConfigEntry<bool> logMaterials; private void Awake() { Instance = this; logMaterials = ((BaseUnityPlugin)this).Config.Bind<bool>("Logging", "Log Fixed Materials", true, "Set true to recieve log of all fixed materials in console."); MaterialFix.TestPatch(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"AggresiveMaterialFix [1.0.3] loaded"); } [MethodImpl(MethodImplOptions.NoInlining)] public static void Log(object data, LogLevel lvl = 8) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) ((BaseUnityPlugin)Instance).Logger.Log(lvl, data); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "AggresiveMaterialFix"; public const string PLUGIN_NAME = "AggresiveMaterialFix"; public const string PLUGIN_VERSION = "1.0.3"; } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }