Decompiled source of MetalPipeShovel v1.0.1

MetalPipeShovelMod.dll

Decompiled 3 months ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using LCSoundTool;
using MetalPipeMod.Patches;
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("MetalPipeShovelMod")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("MELALPIEDOTMP4")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("MetalPipeShovelMod")]
[assembly: AssemblyTitle("MetalPipeShovelMod")]
[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 MetalPipeMod
{
	[BepInPlugin("Eyasu.MetalPipeShovelMod", "Metal Pipe Shovel Mod", "1.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class MetalPipeModBase : BaseUnityPlugin
	{
		private const string modGUID = "Eyasu.MetalPipeShovelMod";

		private const string modName = "Metal Pipe Shovel Mod";

		private const string modVersion = "1.0";

		private readonly Harmony harmony = new Harmony("Eyasu.MetalPipeShovelMod");

		private static MetalPipeModBase Instance;

		internal ManualLogSource mls;

		public static Mesh newModel;

		public static Material newMaterial;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls = Logger.CreateLogSource("Eyasu.MetalPipeShovelMod");
			mls.LogInfo((object)"Enabling Metal Pipe Shovel Mod...");
			string location = ((BaseUnityPlugin)this).Info.Location;
			string text = "MetalPipeShovelMod.dll";
			string text2 = location.TrimEnd(text.ToCharArray());
			string text3 = text2 + "metalpipe";
			AssetBundle val = AssetBundle.LoadFromFile(text3);
			newModel = val.LoadAssetWithSubAssets<Mesh>("metalpipe.obj")[0];
			newMaterial = val.LoadAsset<Material>("Metalpipe.001");
			AudioClip audioClip = SoundTool.GetAudioClip(text2.TrimEnd('\\'), "sounds", "metalpipehit.mp3");
			SoundTool.ReplaceAudioClip("ShovelHitDefault", audioClip);
			SoundTool.ReplaceAudioClip("ShovelHitDefault2", audioClip);
			harmony.PatchAll(typeof(ShovelPatch));
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "MetalPipeShovelMod";

		public const string PLUGIN_NAME = "MetalPipeShovelMod";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace MetalPipeMod.Patches
{
	[HarmonyPatch(typeof(GrabbableObject), "Start")]
	internal class ShovelPatch
	{
		public static void Prefix(GrabbableObject __instance)
		{
			if (((object)__instance).GetType() == typeof(Shovel) && (Object)(object)((Component)__instance).gameObject.GetComponentInChildren<ScanNodeProperties>() == (Object)null)
			{
				MeshFilter componentInChildren = ((Component)__instance).gameObject.GetComponentInChildren<MeshFilter>();
				componentInChildren.mesh = MetalPipeModBase.newModel;
				Renderer componentInChildren2 = (Renderer)(object)((Component)__instance).gameObject.GetComponentInChildren<MeshRenderer>();
				componentInChildren2.material = MetalPipeModBase.newMaterial;
			}
		}
	}
}