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 StinkyPaintingReplacement v1.1.0
paintingReplacement.dll
Decompiled a year agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using HarmonyLib; using UnityEngine; 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: AssemblyTitle("paintingReplacement")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("paintingReplacement")] [assembly: AssemblyCopyright("Copyright © 2025")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("9f5c247c-6f44-414e-b174-883360725c74")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.0.0.0")] namespace StinkyPaintingReplacement; [BepInPlugin("LandoZor.PaintingReplacement", "Painting Replacement", "1.1.0")] public class StinkyPaintingReplacementBase : BaseUnityPlugin { [HarmonyPatch(typeof(LoadingUI), "LevelAnimationComplete")] public class LevelGenerator_PlayerSpawn_Patch { private static readonly HashSet<string> RandomizedMaterials = new HashSet<string> { "Painting_H_Landscape", "Painting_V_Furman", "painting teacher02", "Painting_S_Tree" }; [HarmonyPostfix] private static void Postfix() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) Instance.logger.LogInfo((object)"Start Postfix"); List<GameObject> list = new List<GameObject>(); Scene activeScene = SceneManager.GetActiveScene(); GameObject[] rootGameObjects = ((Scene)(ref activeScene)).GetRootGameObjects(); foreach (GameObject item in rootGameObjects) { list.Add(item); } Random random = new Random(); foreach (GameObject item2 in list) { MeshRenderer[] componentsInChildren = item2.GetComponentsInChildren<MeshRenderer>(); MeshRenderer[] array = componentsInChildren; foreach (MeshRenderer val in array) { Material[] sharedMaterials = ((Renderer)val).sharedMaterials; for (int k = 0; k < sharedMaterials.Length; k++) { Material val2 = sharedMaterials[k]; if (!((Object)(object)val2 != (Object)null)) { continue; } string name = ((Object)val2).name; string key = name; if (RandomizedMaterials.Contains(name)) { switch (random.Next(3)) { case 1: key = name + "1"; break; case 2: key = name + "2"; break; } } if (ReplacementMaterials.ContainsKey(key)) { sharedMaterials[k] = ReplacementMaterials[key]; } } ((Renderer)val).sharedMaterials = sharedMaterials; } } } } private const string modUID = "LandoZor.PaintingReplacement"; private const string modName = "Painting Replacement"; private const string modVersion = "1.1.0"; internal ManualLogSource logger; private readonly Harmony harmony = new Harmony("LandoZor.PaintingReplacement"); public static Dictionary<string, Material> ReplacementMaterials = new Dictionary<string, Material>(StringComparer.OrdinalIgnoreCase); public static StinkyPaintingReplacementBase Instance { get; private set; } private void Awake() { Instance = this; logger = ((BaseUnityPlugin)this).Logger; logger.LogInfo((object)"Loading Stinky Painting Replacement mod..."); Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject); LoadMaterials(); ApplyPatches(); logger.LogInfo((object)"Successfully loaded assets for Stinky Painting Replacement mod!"); } private void ApplyPatches() { harmony.PatchAll(Assembly.GetExecutingAssembly()); } private void LoadMaterials() { string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "stinky_paintings"); AssetBundle val = AssetBundle.LoadFromFile(text); if ((Object)(object)val == (Object)null) { logger.LogError((object)"Failed to load Material AssetBundle!"); return; } Material[] array = val.LoadAllAssets<Material>(); Material[] array2 = array; foreach (Material val2 in array2) { ReplacementMaterials[((Object)val2).name] = val2; } logger.LogInfo((object)$"Loaded {ReplacementMaterials.Count} materials."); } }