Decompiled source of CBEYThumper v1.0.1

cbey_thumper/CBEY_thumper.dll

Decompiled 6 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using CBEY_thumper.patches;
using HarmonyLib;
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 = "")]
[assembly: AssemblyCompany("CBEY_thumper")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("komar edition")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("CBEY_thumper")]
[assembly: AssemblyTitle("CBEY_thumper")]
[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 CBEY_thumper
{
	[BepInPlugin("CBEY_thumper", "CBEY_thumper", "1.0.0")]
	public class CBEY_thumperBase : BaseUnityPlugin
	{
		private static CBEY_thumperBase instance;

		public static string uPath;

		public static AudioClip[] newRoar;

		public static AudioClip[] newCloseHorn;

		public static AudioClip[] newFarHorn;

		public static Dictionary<string, AudioClip> newStompSFX = new Dictionary<string, AudioClip>();

		public static GameObject visuals;

		public static AssetBundle bundle;

		public static readonly Harmony harmony = new Harmony("ironkrendel.CBEY_thumper");

		public static ManualLogSource mls;

		private void Awake()
		{
			if ((Object)(object)instance == (Object)null)
			{
				instance = this;
			}
			mls = ((BaseUnityPlugin)this).Logger;
			uPath = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
			bundle = AssetBundle.LoadFromFile(uPath + "\\komar");
			if ((Object)(object)bundle == (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)"Error loading assets from bundles!!!");
				return;
			}
			newStompSFX["Stomp1"] = bundle.LoadAssetWithSubAssets<AudioClip>("komar_step_1")[0];
			newStompSFX["Stomp2"] = bundle.LoadAssetWithSubAssets<AudioClip>("komar_step_2")[0];
			newStompSFX["Stomp3"] = bundle.LoadAssetWithSubAssets<AudioClip>("komar_step_3")[0];
			newRoar = bundle.LoadAssetWithSubAssets<AudioClip>("CBEY_thumper_wa");
			newCloseHorn = bundle.LoadAssetWithSubAssets<AudioClip>("reserve_alarm_close");
			newFarHorn = bundle.LoadAssetWithSubAssets<AudioClip>("reserve_alarm_far");
			visuals = bundle.LoadAssetWithSubAssets<GameObject>("komar.prefab")[0];
			harmony.PatchAll(typeof(CBEY_thumperBase));
			harmony.PatchAll(typeof(ThumperPatch));
			harmony.PatchAll(typeof(ThumperStompPatch));
			harmony.PatchAll(typeof(BigHornPatch));
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin CBEY_thumper is loaded!");
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "CBEY_thumper";

		public const string PLUGIN_NAME = "CBEY_thumper";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace CBEY_thumper.patches
{
	[HarmonyPatch(typeof(CrawlerAI))]
	internal class ThumperPatch
	{
		private static float timeFromLastSound;

		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		public static void ThumperSFXPatch(CrawlerAI __instance)
		{
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			__instance.shortRoar = CBEY_thumperBase.newRoar[0];
			__instance.longRoarSFX = CBEY_thumperBase.newRoar;
			Transform transform = ((Component)__instance).transform;
			Renderer[] componentsInChildren = ((Component)transform).GetComponentsInChildren<Renderer>();
			Renderer[] array = componentsInChildren;
			Renderer[] array2 = array;
			foreach (Renderer val in array2)
			{
				val.enabled = false;
			}
			GameObject val2 = Object.Instantiate<GameObject>(CBEY_thumperBase.visuals);
			val2.transform.SetParent(transform);
			val2.transform.localPosition = new Vector3(0f, 1f, -2.25f);
			val2.transform.localRotation = Quaternion.identity;
			val2.transform.localScale = new Vector3(2f, 2f, 2f);
			((Renderer)val2.GetComponentInChildren<MeshRenderer>()).enabled = true;
		}

		[HarmonyPatch("KillEnemy")]
		[HarmonyPostfix]
		public static void DeathPatch(CrawlerAI __instance)
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			CrawlerAI[] array = Object.FindObjectsOfType<CrawlerAI>();
			for (int i = 0; i < array.Length; i++)
			{
				if (!((EnemyAI)array[i]).isEnemyDead)
				{
					continue;
				}
				((Component)array[i]).transform.localRotation = new Quaternion(180f, 0f, 180f, 0f);
				Component[] componentsInChildren = ((Component)array[i]).GetComponentsInChildren<Component>();
				for (int j = 0; j < componentsInChildren.Length; j++)
				{
					if (((Object)componentsInChildren[j]).name == "komar_model")
					{
						componentsInChildren[j].transform.localPosition = new Vector3(0f, -1f, 0f);
						break;
					}
				}
			}
		}
	}
	[HarmonyPatch(typeof(AudioSource))]
	internal class ThumperStompPatch
	{
		private static string[] stompNames = new string[3] { "Stomp1", "Stomp2", "Stomp3" };

		[HarmonyPatch("PlayOneShot", new Type[]
		{
			typeof(AudioClip),
			typeof(float)
		})]
		[HarmonyPrefix]
		public static void test(ref AudioClip clip, float volumeScale)
		{
			if ((Object)(object)clip != (Object)null && stompNames.Contains(((Object)clip).name))
			{
				clip = CBEY_thumperBase.newStompSFX[((Object)clip).name];
			}
		}
	}
	[HarmonyPatch(typeof(ShipAlarmCord))]
	internal class BigHornPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		public static void BigHornSFXPatch(ShipAlarmCord __instance)
		{
			__instance.hornClose.clip = CBEY_thumperBase.newCloseHorn[0];
			__instance.hornFar.clip = CBEY_thumperBase.newFarHorn[0];
		}

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		public static void BigHornUpdatePatch(ShipAlarmCord __instance)
		{
			__instance.hornFar.pitch = 1f;
			__instance.hornClose.pitch = 1f;
		}
	}
}