using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using Microsoft.CodeAnalysis; using UnityEngine; [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: AssemblyCompany("ShirtTextureMod")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("ShirtTextureMod")] [assembly: AssemblyTitle("ShirtTextureMod")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] 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; } } } namespace ShirtTextureMod { [BepInPlugin("com.bune.bune_shirts", "Bun-E Shirts", "1.0.0")] public class Plugin : BaseUnityPlugin { [CompilerGenerated] private sealed class d__9 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public Plugin <>4__this; private Renderer[] 5__1; private Renderer[] <>s__2; private int <>s__3; private Renderer 5__4; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__9(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__1 = null; <>s__2 = null; 5__4 = null; <>1__state = -2; } private bool MoveNext() { //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; break; case 1: <>1__state = -1; 5__1 = null; break; } 5__1 = Object.FindObjectsByType((FindObjectsSortMode)0); <>s__2 = 5__1; for (<>s__3 = 0; <>s__3 < <>s__2.Length; <>s__3++) { 5__4 = <>s__2[<>s__3]; ApplyTextures(5__4); 5__4 = null; } <>s__2 = null; <>2__current = (object)new WaitForSeconds(0.1f); <>1__state = 1; return true; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } internal static ManualLogSource? Log; private const string SHIRT_ONE_MATERIAL = "M_TopOversize_Texture04"; private const string SHIRT_TWO_MATERIAL = "M_TopOversize_Texture05"; private const string SHIRT_ONE_TEXTURE_FILE = "Got_Carrots_Shirt.PNG"; private const string SHIRT_TWO_TEXTURE_FILE = "Bun-E_Logo_Shirt.PNG"; private static string? TextureFolder; private static Texture2D? shirtOneTexture; private static Texture2D? shirtTwoTexture; private void Awake() { Log = ((BaseUnityPlugin)this).Logger; TextureFolder = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location); shirtOneTexture = LoadTexture(Path.Combine(TextureFolder, "Got_Carrots_Shirt.PNG")); shirtTwoTexture = LoadTexture(Path.Combine(TextureFolder, "Bun-E_Logo_Shirt.PNG")); if ((Object)(object)shirtOneTexture == (Object)null && (Object)(object)shirtTwoTexture == (Object)null) { Log.LogError((object)"No texture files found. Make sure the PNGs are in the same folder as the DLL."); return; } ((MonoBehaviour)this).StartCoroutine(ScanLoop()); Log.LogInfo((object)"Bun-E Shirts mod loaded — scanning for shirt materials..."); } [IteratorStateMachine(typeof(d__9))] private IEnumerator ScanLoop() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__9(0) { <>4__this = this }; } private static void ApplyTextures(Renderer renderer) { if ((Object)(object)renderer == (Object)null) { return; } Material[] sharedMaterials = renderer.sharedMaterials; foreach (Material val in sharedMaterials) { if (!((Object)(object)val == (Object)null)) { string text = ((Object)val).name.Replace(" (Instance)", "").Trim(); if (text == "M_TopOversize_Texture04" && (Object)(object)shirtOneTexture != (Object)null) { SetMainTexture(renderer, ((Object)val).name, shirtOneTexture); } else if (text == "M_TopOversize_Texture05" && (Object)(object)shirtTwoTexture != (Object)null) { SetMainTexture(renderer, ((Object)val).name, shirtTwoTexture); } } } } private static void SetMainTexture(Renderer renderer, string originalMatName, Texture2D tex) { Material[] materials = renderer.materials; for (int i = 0; i < materials.Length; i++) { if (!((Object)(object)materials[i] == (Object)null) && ((Object)materials[i]).name.Replace(" (Instance)", "").Trim() == originalMatName.Replace(" (Instance)", "").Trim()) { materials[i].mainTexture = (Texture)(object)tex; } } renderer.materials = materials; } private static Texture2D? LoadTexture(string path) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown if (!File.Exists(path)) { ManualLogSource? log = Log; if (log != null) { log.LogWarning((object)("Texture file not found: " + path)); } return null; } byte[] array = File.ReadAllBytes(path); Texture2D val = new Texture2D(2, 2); ImageConversion.LoadImage(val, array); ((Object)val).name = Path.GetFileNameWithoutExtension(path); val.Apply(); ManualLogSource? log2 = Log; if (log2 != null) { log2.LogInfo((object)$"Loaded texture: {path} ({((Texture)val).width}x{((Texture)val).height})"); } return val; } } internal static class PluginInfo { public const string PLUGIN_GUID = "com.bune.bune_shirts"; public const string PLUGIN_NAME = "Bun-E Shirts"; public const string PLUGIN_VERSION = "1.0.0"; } }