Decompiled source of BlueGutterTank v1.0.0

doomahreal.ultrakill.blueguttertank/BlueGutterTank.dll

Decompiled 2 months ago
using System;
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 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.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("BlueGutterTank")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("My first plugin")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("BlueGutterTank")]
[assembly: AssemblyTitle("BlueGutterTank")]
[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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace BlueGutterTank
{
	[BepInPlugin("doomahreal.ultrakill.blueguttertank", "Blue Gutter Tank", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		private AssetBundle cachedBundle;

		private HashSet<Material> replacedMaterials = new HashSet<Material>();

		private void Update()
		{
			ReplaceGutterTankTexture();
		}

		private void ReplaceGutterTankTexture()
		{
			Material[] array = Resources.FindObjectsOfTypeAll<Material>();
			Material[] array2 = array;
			foreach (Material val in array2)
			{
				if (((Object)val).name == "Guttertank (Instance)" && !replacedMaterials.Contains(val))
				{
					Texture2D val2 = LoadTextureFromBundle("blueguyidk.png");
					if ((Object)(object)val2 != (Object)null)
					{
						val.mainTexture = (Texture)(object)val2;
						replacedMaterials.Add(val);
						Debug.Log((object)"GutterTank texture replaced successfully.");
					}
					else
					{
						Debug.LogError((object)"Failed to load blue texture!");
					}
				}
			}
		}

		private Texture2D LoadTextureFromBundle(string textureName)
		{
			if ((Object)(object)cachedBundle == (Object)null)
			{
				byte[] array = LoadEmbeddedResource("BlueGutterTank.blueguttertank.bundle");
				if (array == null)
				{
					Debug.LogError((object)"Failed to load embedded resource!");
					return null;
				}
				cachedBundle = AssetBundle.LoadFromMemory(array);
				if ((Object)(object)cachedBundle == (Object)null)
				{
					Debug.LogError((object)"Failed to load asset bundle!");
					return null;
				}
			}
			return cachedBundle.LoadAsset<Texture2D>(textureName);
		}

		private byte[] LoadEmbeddedResource(string resourceName)
		{
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			using (Stream stream = executingAssembly.GetManifestResourceStream(resourceName))
			{
				if (stream != null)
				{
					using MemoryStream memoryStream = new MemoryStream();
					stream.CopyTo(memoryStream);
					return memoryStream.ToArray();
				}
				Debug.LogError((object)"Failed to load embedded resource stream!");
			}
			return null;
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "BlueGutterTank";

		public const string PLUGIN_NAME = "BlueGutterTank";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}