Decompiled source of TheGrogCan v1.0.5

BepInEx/plugins/TheGrogCan_by_Tomini.dll

Decompiled 9 months ago
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using System.Resources;
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 TheGrogCan.Properties;
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("TheGrogCan_by_Tomini")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Replaces the red soda can with a Grog cans from Cold Ones")]
[assembly: AssemblyFileVersion("1.0.5.0")]
[assembly: AssemblyInformationalVersion("1.0.5")]
[assembly: AssemblyProduct("TheGrogCan_by_Tomini")]
[assembly: AssemblyTitle("TheGrogCan_by_Tomini")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.5.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;
		}
	}
}
public static class PluginInfo
{
	public const string PLUGIN_GUID = "TheGrogCan_by_Tomini";

	public const string PLUGIN_NAME = "TheGrogCan_by_Tomini";

	public const string PLUGIN_VERSION = "1.0.5";
}
namespace TheGrogCan
{
	internal class Patches
	{
		[HarmonyPatch(typeof(GrabbableObject), "SetScrapValue")]
		[HarmonyPostfix]
		private static void SetScrapValuePatch(GrabbableObject __instance)
		{
			if (__instance.itemProperties.itemName == "Red soda" && (Object)(object)__instance.mainObjectRenderer != (Object)null)
			{
				Material[] materials = ((Renderer)__instance.mainObjectRenderer).materials;
				foreach (Material val in materials)
				{
					val.mainTexture = (Texture)(object)Plugin.texture;
				}
			}
		}
	}
	[BepInPlugin("TheGrogCan_by_Tomini", "TheGrogCan_by_Tomini", "1.0.5")]
	public class Plugin : BaseUnityPlugin
	{
		private static ConfigEntry<int> textureChoice;

		public static AssetBundle MainAssets;

		public static Texture2D texture;

		public static ManualLogSource StaticLogger;

		private void Awake()
		{
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			StaticLogger = ((BaseUnityPlugin)this).Logger;
			TryLoadAssets();
			textureChoice = ((BaseUnityPlugin)this).Config.Bind<int>("General", "TextureChoice", 0, "0: Random, 1: Grog Grape, 2: Grog Peach, 3: Grog Lemon");
			LogTextureChoice();
			List<Texture2D> list = new List<Texture2D>
			{
				MainAssets.LoadAsset<Texture2D>("grog_grape"),
				MainAssets.LoadAsset<Texture2D>("grog_peach"),
				MainAssets.LoadAsset<Texture2D>("grog_lemon")
			};
			int num = Mathf.Clamp(textureChoice.Value, 0, list.Count - 1);
			if (num == 0)
			{
				num = Random.Range(0, list.Count);
			}
			texture = list[num];
			LogSelectedTexture(((Object)list[num]).name);
			new Harmony("TheGrogCan_by_Tomini").PatchAll(typeof(Patches));
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin TheGrogCan_by_Tomini is loaded!");
		}

		private void TryLoadAssets()
		{
			if ((Object)(object)MainAssets == (Object)null)
			{
				MainAssets = AssetBundle.LoadFromMemory(Resources.grogcan);
				if (!((Object)(object)MainAssets != (Object)null))
				{
					throw new Exception("Failed to load the asset bundle!");
				}
				StaticLogger.LogInfo((object)"Loaded asset bundle");
			}
		}

		private void LogTextureChoice()
		{
			string text;
			if (textureChoice.Value == 0)
			{
				text = "Random";
			}
			else
			{
				int value = textureChoice.Value;
				if (1 == 0)
				{
				}
				string text2 = value switch
				{
					1 => "Grog Grape", 
					2 => "Grog Peach", 
					3 => "Grog Lemon", 
					_ => "Unknown", 
				};
				if (1 == 0)
				{
				}
				text = text2;
			}
			string text3 = text;
			StaticLogger.LogInfo((object)("Configuration: " + text3));
		}

		private void LogSelectedTexture(string textureName)
		{
			StaticLogger.LogInfo((object)("Selected texture: " + textureName));
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "TheGrogCan_by_Tomini";

		public const string PLUGIN_NAME = "TheGrogCan_by_Tomini";

		public const string PLUGIN_VERSION = "1.0.5";
	}
}
namespace TheGrogCan.Properties
{
	[GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
	[DebuggerNonUserCode]
	[CompilerGenerated]
	internal class Resources
	{
		private static ResourceManager resourceMan;

		private static CultureInfo resourceCulture;

		[EditorBrowsable(EditorBrowsableState.Advanced)]
		internal static ResourceManager ResourceManager
		{
			get
			{
				if (resourceMan == null)
				{
					ResourceManager resourceManager = new ResourceManager("TheGrogCan.Properties.Resources", typeof(Resources).Assembly);
					resourceMan = resourceManager;
				}
				return resourceMan;
			}
		}

		[EditorBrowsable(EditorBrowsableState.Advanced)]
		internal static CultureInfo Culture
		{
			get
			{
				return resourceCulture;
			}
			set
			{
				resourceCulture = value;
			}
		}

		internal static byte[] grogcan
		{
			get
			{
				object @object = ResourceManager.GetObject("grogcan", resourceCulture);
				return (byte[])@object;
			}
		}

		internal Resources()
		{
		}
	}
}