Decompiled source of MetalCompany v1.0.0

MetalCompany.dll

Decompiled a day 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 MetalCompany.Patches;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("MetalCompany")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MetalCompany")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("2f300945-55e0-43c2-a7e9-19825cd77899")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace MetalCompany
{
	[BepInPlugin("Kahvinkeitin34.MetalCompany", "Metal Company", "1.0.0.0")]
	public class MetalCompanyBase : BaseUnityPlugin
	{
		private const string modGUID = "Kahvinkeitin34.MetalCompany";

		private const string modName = "Metal Company";

		private const string modVersion = "1.0.0.0";

		private readonly Harmony harmony = new Harmony("Kahvinkeitin34.MetalCompany");

		private static MetalCompanyBase Instance;

		internal ManualLogSource mls;

		internal static AudioClip[] Clips;

		internal static AssetBundle Bundle;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls = Logger.CreateLogSource("Kahvinkeitin34.MetalCompany");
			mls.LogInfo((object)"Metal Company mod enabled.");
			harmony.PatchAll(typeof(MetalCompanyBase));
			harmony.PatchAll(typeof(BoomboxItemPatch));
			mls = ((BaseUnityPlugin)this).Logger;
			string text = ((BaseUnityPlugin)Instance).Info.Location.TrimEnd("MetalCompany.dll".ToCharArray());
			Bundle = AssetBundle.LoadFromFile(text + "metalcompanybundle");
			if ((Object)(object)Bundle != (Object)null)
			{
				mls.LogInfo((object)"Successfully loaded asset bundle");
				Clips = Bundle.LoadAllAssets<AudioClip>();
			}
			else
			{
				mls.LogError((object)"Failed to load asset bundle");
			}
		}
	}
}
namespace MetalCompany.Patches
{
	[HarmonyPatch(typeof(BoomboxItem))]
	internal class BoomboxItemPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void StartPatch(BoomboxItem __instance)
		{
			__instance.musicAudios = MetalCompanyBase.Clips;
			((GrabbableObject)__instance).itemProperties.requiresBattery = false;
			__instance.boomboxAudio.maxDistance = 50f;
		}

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void UpdatePatch(BoomboxItem __instance)
		{
			if ((Object)(object)((GrabbableObject)__instance).playerHeldBy != (Object)null)
			{
				Debug.Log((object)((Object)((GrabbableObject)__instance).playerHeldBy).name);
				if (((GrabbableObject)__instance).playerHeldBy.carryWeight > 1f)
				{
					((GrabbableObject)__instance).playerHeldBy.carryWeight = 1f;
				}
				if (((GrabbableObject)__instance).playerHeldBy.sprintMeter < 1f)
				{
					((GrabbableObject)__instance).playerHeldBy.sprintMeter = 1f;
				}
			}
		}
	}
}