Decompiled source of Scrapmire v1.0.3

Scrapmire/Scrapmire.dll

Decompiled 10 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
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 LethalLib.Modules;
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("Scrapmire")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("A mod that adds Quagmire's... whatever the hell that is? as scrap")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Scrapmire")]
[assembly: AssemblyTitle("Scrapmire")]
[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 Scrapmire
{
	[BepInPlugin("Scrapmire", "Scrapmire", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(GrabbableObject))]
		private class GrabbableObject_PlayDropSFX_Patch
		{
			[HarmonyPatch("Start")]
			[HarmonyPrefix]
			private static void Start(GrabbableObject __instance)
			{
				if (__instance.itemProperties.itemName.Equals("Scrapmire") && audioClips != null && audioClips.Item1.Count > 0)
				{
					AudioClip grabSFX = audioClips.Item1[Random.Range(0, audioClips.Item1.Count)];
					__instance.itemProperties.grabSFX = grabSFX;
				}
			}

			[HarmonyPatch("PlayDropSFX")]
			[HarmonyPrefix]
			private static void Prefix(GrabbableObject __instance)
			{
				if (__instance.itemProperties.itemName.Equals("Scrapmire") && audioClips != null && audioClips.Item1.Count > 0 && audioClips.Item2.Count > 0)
				{
					AudioClip dropSFX = audioClips.Item2[Random.Range(0, audioClips.Item2.Count)];
					__instance.itemProperties.dropSFX = dropSFX;
					dropSFX = audioClips.Item1[Random.Range(0, audioClips.Item1.Count)];
					__instance.itemProperties.grabSFX = dropSFX;
				}
			}
		}

		public static AssetBundle Assets;

		public static ConfigFile config;

		internal ManualLogSource mls;

		private static Tuple<List<AudioClip>, List<AudioClip>> audioClips;

		private Harmony harmony = new Harmony("Scrapmire");

		private void Awake()
		{
			string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
			Assets = AssetBundle.LoadFromFile(Path.Combine(directoryName, "QuagmireModAssets"));
			if ((Object)(object)Assets == (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)"Failed to load custom assets.");
				return;
			}
			mls = Logger.CreateLogSource("Scrapmire");
			audioClips = Tuple.Create(new List<AudioClip>(), new List<AudioClip>());
			loadSounds();
			int num = 35;
			Item val = Assets.LoadAsset<Item>("Assets/QuagmireFaceAssets/QuagmireFaceItem.asset");
			Utilities.FixMixerGroups(val.spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(val.spawnPrefab);
			Items.RegisterScrap(val, num, (LevelTypes)(-1));
			GrabbableObject val2 = Object.FindObjectOfType<GrabbableObject>();
			mls.LogMessage((object)"Scrapmire mod loaded!");
			harmony.PatchAll();
		}

		private void loadSounds()
		{
			string value = "assets/quagmirefaceassets/sounds/grabsfx";
			string value2 = "assets/quagmirefaceassets/sounds/dropsfx";
			string[] allAssetNames = Assets.GetAllAssetNames();
			string[] array = allAssetNames;
			foreach (string text in array)
			{
				if (text.StartsWith(value))
				{
					audioClips.Item1.Add(Assets.LoadAsset<AudioClip>(text));
				}
				else if (text.StartsWith(value2))
				{
					audioClips.Item2.Add(Assets.LoadAsset<AudioClip>(text));
				}
			}
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "Scrapmire";

		public const string PLUGIN_NAME = "Scrapmire";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}