Decompiled source of ExtraGorePlugin v1.1.0

ExtraGorePlugin.dll

Decompiled a month ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using Bounce.Singletons;
using HarmonyLib;
using TMPro;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("ExtraGorePlugin")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ExtraGorePlugin")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("ExtraGorePlugin")]
[assembly: ComVisible(false)]
[assembly: Guid("c303405d-e66c-4316-9cdb-4e3ca15c6360")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.1.0.0")]
namespace LordAshes;

[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("org.lordashes.plugins.extragore", "Extra Gore Plug-In", "1.1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class ExtraGorePlugin : BaseUnityPlugin
{
	[HarmonyPatch(typeof(CreatureBoardAsset), "AttackTargetCreature", new Type[] { typeof(Vector3) })]
	public static class AttackTargetCreaturePatch
	{
		public static bool Prefix(Vector3 impactDir)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			CreatureBoardAsset val = default(CreatureBoardAsset);
			CreaturePresenter.TryGetAsset(LocalClient.SelectedCreatureId, ref val);
			if ((Object)(object)val != (Object)null)
			{
				Debug.Log((object)"Extra Gore Plugin: Applying Gore");
				((MonoBehaviour)self).StartCoroutine("ApplyGore", (object)val);
			}
			else
			{
				Debug.Log((object)"Extra Gore Plugin: Invalid Target");
			}
			return true;
		}
	}

	public static class Utility
	{
		public static void PostOnMainPage(MemberInfo plugin)
		{
			SceneManager.sceneLoaded += delegate(Scene scene, LoadSceneMode mode)
			{
				//IL_0072: Unknown result type (might be due to invalid IL or missing references)
				//IL_0079: Expected O, but got Unknown
				try
				{
					if (((Scene)(ref scene)).name == "UI")
					{
						TextMeshProUGUI uITextByName = GetUITextByName("BETA");
						if (Object.op_Implicit((Object)(object)uITextByName))
						{
							((TMP_Text)uITextByName).text = "INJECTED BUILD - unstable mods";
						}
					}
					else
					{
						TextMeshProUGUI uITextByName2 = GetUITextByName("TextMeshPro Text");
						if (Object.op_Implicit((Object)(object)uITextByName2))
						{
							BepInPlugin val = (BepInPlugin)Attribute.GetCustomAttribute(plugin, typeof(BepInPlugin));
							if (((TMP_Text)uITextByName2).text.EndsWith("</size>"))
							{
								((TMP_Text)uITextByName2).text = ((TMP_Text)uITextByName2).text + "\n\nMods Currently Installed:\n";
							}
							TextMeshProUGUI val2 = uITextByName2;
							((TMP_Text)val2).text = ((TMP_Text)val2).text + "\nLord Ashes' " + val.Name + " - " + val.Version;
						}
					}
				}
				catch (Exception ex)
				{
					Debug.Log((object)ex);
				}
			};
		}

		public static bool isBoardLoaded()
		{
			return SimpleSingletonBehaviour<CameraController>.HasInstance && SingletonStateMBehaviour<BoardSessionManager, State<BoardSessionManager>>.HasInstance && !BoardSessionManager.IsLoading;
		}

		public static bool StrictKeyCheck(KeyboardShortcut check)
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			if (!((KeyboardShortcut)(ref check)).IsUp())
			{
				return false;
			}
			KeyCode[] array = new KeyCode[6];
			RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			KeyCode[] array2 = (KeyCode[])(object)array;
			foreach (KeyCode val in array2)
			{
				if (Input.GetKey(val) != ((KeyboardShortcut)(ref check)).Modifiers.Contains(val))
				{
					return false;
				}
			}
			return true;
		}

		private static TextMeshProUGUI GetUITextByName(string name)
		{
			TextMeshProUGUI[] array = Object.FindObjectsOfType<TextMeshProUGUI>();
			for (int i = 0; i < array.Length; i++)
			{
				if (((Object)array[i]).name == name)
				{
					return array[i];
				}
			}
			return null;
		}
	}

	[CompilerGenerated]
	private sealed class <ApplyGore>d__1 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public CreatureBoardAsset asset;

		public ExtraGorePlugin <>4__this;

		private GameObject <instance>5__1;

		private Camera <cam>5__2;

		private Renderer[] <>s__3;

		private int <>s__4;

		private Renderer <rend>5__5;

		private Shader <shader>5__6;

		private Vector3 <positionInFront>5__7;

		private Quaternion <facing>5__8;

		private float <i>5__9;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <ApplyGore>d__1(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<instance>5__1 = null;
			<cam>5__2 = null;
			<>s__3 = null;
			<rend>5__5 = null;
			<shader>5__6 = null;
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Expected O, but got Unknown
			//IL_03b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03dc: Expected O, but got Unknown
			//IL_043a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0444: Expected O, but got Unknown
			//IL_035b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0206: Unknown result type (might be due to invalid IL or missing references)
			//IL_0216: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_0225: Unknown result type (might be due to invalid IL or missing references)
			//IL_022a: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0252: Unknown result type (might be due to invalid IL or missing references)
			//IL_0257: Unknown result type (might be due to invalid IL or missing references)
			//IL_025c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0261: Unknown result type (might be due to invalid IL or missing references)
			//IL_027c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0281: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0309: Unknown result type (might be due to invalid IL or missing references)
			//IL_031f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0329: Unknown result type (might be due to invalid IL or missing references)
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>2__current = (object)new WaitForEndOfFrame();
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				Debug.Log((object)"Extra Gore Plugin: Creating Blood Splatter");
				<instance>5__1 = Object.Instantiate<GameObject>(<>4__this.prefab);
				((Object)<instance>5__1).name = ((Object)<>4__this.prefab).name;
				Debug.Log((object)"Extra Gore Plugin: Getting Renderer");
				<>s__3 = <instance>5__1.GetComponentsInChildren<Renderer>();
				for (<>s__4 = 0; <>s__4 < <>s__3.Length; <>s__4++)
				{
					<rend>5__5 = <>s__3[<>s__4];
					Debug.Log((object)"Extra Gore Plugin: Setting Material To Render Mode Fade");
					if ((Object)(object)<rend>5__5.material != (Object)null)
					{
						<shader>5__6 = Shader.Find("Standard");
						<rend>5__5.material.shader = <shader>5__6;
						Debug.Log((object)("Extra Gore Plugin: Shader = " + ((Object)<rend>5__5.material.shader).name));
						Debug.Log((object)("Extra Gore Plugin: Shader Mode = " + <rend>5__5.material.GetFloat("_Mode")));
						Debug.Log((object)("Extra Gore Plugin: Material = " + ((Object)<rend>5__5.material).name));
						<shader>5__6 = null;
					}
					else
					{
						Debug.Log((object)"Extra Gore Plugin: Material Is Null");
					}
					<rend>5__5 = null;
				}
				<>s__3 = null;
				<cam>5__2 = Camera.main;
				if ((Object)(object)<cam>5__2 != (Object)null)
				{
					Debug.Log((object)"Extra Gore Plugin: Aligning Splatter With Camera");
					<positionInFront>5__7 = ((Component)<cam>5__2).transform.position + ((Component)<cam>5__2).transform.forward * 5f;
					<instance>5__1.transform.position = <positionInFront>5__7;
					<facing>5__8 = Quaternion.LookRotation(-((Component)<cam>5__2).transform.forward);
					Debug.Log((object)("Extra Gore Plugin: " + ((Quaternion)(ref <facing>5__8)).eulerAngles.x + "," + (((Quaternion)(ref <facing>5__8)).eulerAngles.y - 180f) + "," + ((Quaternion)(ref <facing>5__8)).eulerAngles.z));
					<instance>5__1.transform.rotation = Quaternion.Euler(((Quaternion)(ref <facing>5__8)).eulerAngles.x, ((Quaternion)(ref <facing>5__8)).eulerAngles.y - 180f, ((Quaternion)(ref <facing>5__8)).eulerAngles.z);
				}
				TS_CameraShaker.CallShakeWithNoise(<>4__this.shakeDuration, <>4__this.shakeMagnitude, ((Component)((MovableBoardAsset)asset).Rotator).transform.position, <>4__this.shakeFrequency);
				<i>5__9 = 0.01f;
				goto IL_0405;
			case 2:
				<>1__state = -1;
				<i>5__9 += <>4__this.displaySpeed;
				goto IL_0405;
			case 3:
				{
					<>1__state = -1;
					Debug.Log((object)"Extra Gore Plugin: Removing Splatter");
					Object.Destroy((Object)(object)<instance>5__1);
					return false;
				}
				IL_0405:
				if ((double)<i>5__9 <= 1.5)
				{
					<instance>5__1.transform.localScale = 0.0125f * new Vector3(1.6f * <i>5__9, 0.01f * <i>5__9, 0.9f * <i>5__9);
					<>2__current = (object)new WaitForSeconds(<>4__this.displayStepHold);
					<>1__state = 2;
					return true;
				}
				Debug.Log((object)"Extra Gore Plugin: Holding Splatter");
				<>2__current = (object)new WaitForSeconds(<>4__this.displayTime);
				<>1__state = 3;
				return true;
			}
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	public const string Name = "Extra Gore Plug-In";

	public const string Guid = "org.lordashes.plugins.extragore";

	public const string Version = "1.1.0.0";

	private static ExtraGorePlugin self;

	private AssetBundle bundle = null;

	private GameObject prefab = null;

	private float displaySpeed;

	private float displayStepHold;

	private float displayTime;

	private float shakeDuration;

	private float shakeMagnitude;

	private float shakeFrequency;

	[IteratorStateMachine(typeof(<ApplyGore>d__1))]
	private IEnumerator ApplyGore(CreatureBoardAsset asset)
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <ApplyGore>d__1(0)
		{
			<>4__this = this,
			asset = asset
		};
	}

	private void Awake()
	{
		//IL_012d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0133: Expected O, but got Unknown
		self = this;
		Debug.Log((object)"Extra Gore Plugin: Active.");
		displaySpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Settings", "Throw Steps At Which Gore Is Thrown", 0.1f, (ConfigDescription)null).Value;
		displayStepHold = ((BaseUnityPlugin)this).Config.Bind<float>("Settings", "Throw Hold  At Which Gore Is Thrown", 0.05f, (ConfigDescription)null).Value;
		displayTime = ((BaseUnityPlugin)this).Config.Bind<float>("Settings", "Length In Seconds That Gore Is Displayed", 3f, (ConfigDescription)null).Value;
		shakeDuration = ((BaseUnityPlugin)this).Config.Bind<float>("Settings", "Length In Seconds Of Shake", 1f, (ConfigDescription)null).Value;
		shakeMagnitude = ((BaseUnityPlugin)this).Config.Bind<float>("Settings", "Magnitude In Tiles Of Shake", 0.25f, (ConfigDescription)null).Value;
		shakeFrequency = ((BaseUnityPlugin)this).Config.Bind<float>("Settings", "Frequency Of Shake", 1.3f, (ConfigDescription)null).Value;
		bundle = AssetBundle.LoadFromFile(File.Find("laextragory01", (CacheType)999)[0]);
		prefab = bundle.LoadAsset<GameObject>("laextragory01");
		Harmony val = new Harmony("org.lordashes.plugins.extragore");
		val.PatchAll();
		Utility.PostOnMainPage(((object)this).GetType());
	}
}