Decompiled source of TZPBluntReplacer v1.3.5

Weedmod.dll

Decompiled 5 months ago
using System.Diagnostics;
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 Weedmod.Patches;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("Weedmod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Weedmod")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("406a17be-0104-4301-86b6-65ea1d15f38f")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Weedmod
{
	[BepInPlugin("Ex.WeedMod", "Ex TZP to Weed Mod", "1.2.0")]
	public class WeedmodBase : BaseUnityPlugin
	{
		private const string modGUID = "Ex.WeedMod";

		private const string modName = "Ex TZP to Weed Mod";

		private const string modVersion = "1.2.0";

		private readonly Harmony harmony = new Harmony("Ex.WeedMod");

		private static WeedmodBase Instance;

		internal ManualLogSource mls;

		public static GameObject newWeedModel;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls = Logger.CreateLogSource("Ex.WeedMod");
			mls.LogInfo((object)"Weed mod has initiated");
			string location = ((BaseUnityPlugin)Instance).Info.Location;
			string text = "Weedmod.dll";
			string text2 = location.TrimEnd(text.ToCharArray());
			string text3 = text2 + "weedmodassets";
			AssetBundle val = AssetBundle.LoadFromFile(text3);
			if ((Object)(object)val == (Object)null)
			{
				mls.LogError((object)"Failed to load assets!");
				return;
			}
			newWeedModel = val.LoadAsset<GameObject>("Assets/Blunt1.prefab");
			harmony.PatchAll(typeof(WeedmodBase));
			harmony.PatchAll(typeof(TZPInhalePatch));
			mls.LogInfo((object)"TZP weed replacer mod has loaded.");
		}
	}
}
namespace Weedmod.Patches
{
	[HarmonyPatch(typeof(GrabbableObject))]
	internal class TZPInhalePatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		public static void TZPInhaleMPatch(GrabbableObject __instance)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			if (__instance is TetraChemicalItem)
			{
				Transform child = ((Component)__instance).transform.GetChild(0);
				((Renderer)((Component)__instance).GetComponent<MeshRenderer>()).enabled = false;
				GameObject val = Object.Instantiate<GameObject>(WeedmodBase.newWeedModel);
				val.transform.SetParent(child);
				val.transform.localPosition = Vector3.zero;
				val.transform.localRotation = Quaternion.identity;
				val.transform.localScale = Vector3.one;
				Quaternion localRotation = child.localRotation;
				((Quaternion)(ref localRotation)).Set(45f, -90f, 90f, 0f);
				child.localRotation = localRotation;
				Vector3 localScale = child.localScale;
				((Vector3)(ref localScale)).Set(0.5f, 0.5f, 0.5f);
				child.localScale = localScale;
			}
		}

		[HarmonyPatch(typeof(TetraChemicalItem), "Update")]
		[HarmonyPostfix]
		public static void TZPMeshRemove(TetraChemicalItem __instance, ref float ___fuel)
		{
			((Renderer)((Component)__instance).GetComponent<MeshRenderer>()).enabled = false;
			___fuel = 1f;
		}
	}
}