Decompiled source of Baguette v1.1.0

BepInEx/plugins/Baguette.dll

Decompiled 9 months ago
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
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("Baguette")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Baguette")]
[assembly: AssemblyTitle("Baguette")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Baguette
{
	public class HarmonyPatches
	{
		private static Harmony instance;

		public const string InstanceId = "Graze.baguette";

		public static bool IsPatched { get; private set; }

		internal static void ApplyHarmonyPatches()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			if (!IsPatched)
			{
				if (instance == null)
				{
					instance = new Harmony("Graze.baguette");
				}
				instance.PatchAll(Assembly.GetExecutingAssembly());
				IsPatched = true;
			}
		}

		internal static void RemoveHarmonyPatches()
		{
			if (instance != null && IsPatched)
			{
				instance.UnpatchSelf();
				IsPatched = false;
			}
		}
	}
	[BepInPlugin("Graze.baguette", "Baguette", "1.1.0")]
	public class Plugin : BaseUnityPlugin
	{
		private Plugin()
		{
			HarmonyPatches.ApplyHarmonyPatches();
			Store.Instance = new Store();
		}
	}
	internal class Store
	{
		public static Store Instance;

		private static Stream manifestResourceStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("Baguette.Assets.baguette");

		private static AssetBundle assetBundle = AssetBundle.LoadFromStream(manifestResourceStream);

		public static GameObject assetStore = assetBundle.LoadAsset<GameObject>("Baguette_01");

		public static string EasterEgg = "76561198039840398";
	}
	internal class EasterEgg : MonoBehaviour
	{
		public GrabbableObject me;

		private void Update()
		{
			if (me.isHeld || me.heldByPlayerOnServer)
			{
				if (me.playerHeldBy.playerSteamId.ToString() == Store.EasterEgg)
				{
					((Component)((Component)this).transform.Find("Baguette_01(Clone)").GetChild(0)).gameObject.SetActive(true);
				}
			}
			else
			{
				((Component)((Component)this).transform.Find("Baguette_01(Clone)").GetChild(0)).gameObject.SetActive(false);
			}
		}
	}
	internal class PluginInfo
	{
		public const string GUID = "Graze.baguette";

		public const string Name = "Baguette";

		public const string Version = "1.1.0";
	}
}
namespace Baguette.Patches
{
	[HarmonyPatch(typeof(GrabbableObject))]
	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	internal class ShovelPatch
	{
		private static void Postfix(Shovel __instance)
		{
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			if (((object)__instance).GetType() == typeof(Shovel))
			{
				if (((Object)__instance).name == "YieldSign(Clone)" || ((Object)__instance).name == "StopSign(Clone)")
				{
					((Renderer)((Component)__instance).GetComponent<MeshRenderer>()).forceRenderingOff = true;
				}
				else
				{
					((Renderer)((Component)((Component)__instance).transform.GetChild(0)).GetComponent<MeshRenderer>()).forceRenderingOff = true;
				}
				GameObject val = Object.Instantiate<GameObject>(Store.assetStore, ((Component)__instance).transform);
				val.transform.localPosition = new Vector3(0f, 0f, 0.3f);
				val.transform.localScale = new Vector3(2f, 2f, 2f);
				((Component)__instance).gameObject.AddComponent<EasterEgg>().me = (GrabbableObject)(object)__instance;
			}
		}
	}
}