Decompiled source of BombadiroCrocodilo v1.1.1

BombadiroCrocodilo.dll

Decompiled 3 weeks ago
using System;
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.Logging;
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 = ".NET Standard 2.1")]
[assembly: AssemblyCompany("BombadiroCrocodilo")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("BombadiroCrocodiloMod")]
[assembly: AssemblyTitle("BombadiroCrocodilo")]
[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 BombadiroCrocodilo
{
	[BepInPlugin("BombadiroCrocodilo", "BombadiroCrocodiloMod", "1.0.0")]
	[BepInProcess("REPO.exe")]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Logger;

		internal static GameObject BombadiroGameObj;

		internal static AudioClip BombadiroChaseSound;

		private void TryGetBombadiroAssets()
		{
			string text = Path.Combine(Paths.PluginPath, "Randz0-BombadiroCrocodilo/bombadiro");
			Logger.LogInfo((object)("Getting Assets From: " + text));
			AssetBundle val = AssetBundle.LoadFromFile(text);
			if ((Object)(object)val == (Object)null)
			{
				throw new Exception("asset bundle is missing");
			}
			BombadiroGameObj = val.LoadAsset<GameObject>("bombadiroModel");
			BombadiroChaseSound = val.LoadAsset<AudioClip>("bombadiroSFX");
			if ((Object)(object)BombadiroGameObj == (Object)null || (Object)(object)BombadiroChaseSound == (Object)null)
			{
				throw new Exception("Could not find model/SFX in assets");
			}
		}

		private void InitializeLogger()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			Logger.LogInfo((object)"Plugin BombadiroCrocodilo is loading!");
		}

		private void Awake()
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Expected O, but got Unknown
			InitializeLogger();
			try
			{
				TryGetBombadiroAssets();
			}
			catch (Exception ex)
			{
				Logger.LogFatal((object)("Could not load bombadiro, will not load mod \n Error Msg : " + ex.Message));
				return;
			}
			Logger.LogInfo((object)"Bombadiro Was Sucessfully loaded.");
			Harmony val = new Harmony("BombadiroCrocodilo");
			val.PatchAll();
		}
	}
	[HarmonyPatch(typeof(EnemyParent), "Awake")]
	public class ReplaceEnemyHeadWithBombadiro
	{
		public static void ReplaceChaseSFX(ref EnemyParent instance)
		{
			EnemyHeadAnimationSystem componentInChildren = ((Component)instance).GetComponentInChildren<EnemyHeadAnimationSystem>(true);
			componentInChildren.ChaseBegin.Sounds[0] = Plugin.BombadiroChaseSound;
			componentInChildren.ChaseBegin.Volume = 1f;
		}

		public static void ReplaceModel(ref EnemyParent instance)
		{
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			MeshRenderer[] componentsInChildren = ((Component)instance).GetComponentsInChildren<MeshRenderer>(true);
			SkinnedMeshRenderer[] componentsInChildren2 = ((Component)instance).GetComponentsInChildren<SkinnedMeshRenderer>(true);
			MeshRenderer[] array = componentsInChildren;
			foreach (MeshRenderer val in array)
			{
				((Renderer)val).enabled = false;
			}
			SkinnedMeshRenderer[] array2 = componentsInChildren2;
			foreach (SkinnedMeshRenderer val2 in array2)
			{
				((Renderer)val2).enabled = false;
			}
			Transform child = ((Component)instance).transform.GetChild(((Component)instance).transform.childCount - 1);
			child = child.GetChild(child.childCount - 1);
			Transform transform = Object.Instantiate<GameObject>(Plugin.BombadiroGameObj, ((Component)child).transform.position, Quaternion.identity, child).transform;
			transform.localRotation = Quaternion.Euler(0f, -90f, 0f);
		}

		public static void Postfix(ref EnemyParent __instance)
		{
			Plugin.Logger.LogInfo((object)__instance.enemyName);
			if (!(__instance.enemyName != "Headman"))
			{
				ReplaceModel(ref __instance);
				ReplaceChaseSFX(ref __instance);
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "BombadiroCrocodilo";

		public const string PLUGIN_NAME = "BombadiroCrocodiloMod";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}