Decompiled source of Accurate Gabriel v0.0.1

plugins/AccurateGabriel.dll

Decompiled 5 days ago
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using AccurateGabriel.Patching;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using ProjectProphet.Behaviours.Wares;
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("ProjectProphet")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ProjectProphet")]
[assembly: AssemblyCopyright("Copyright ©  2022")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("dfa813c9-c407-48f5-b20f-615a3c8fdbe3")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace AccurateGabriel
{
	public static class Paths
	{
		private static string _bundleProjectPath;

		private static string _packedPath;

		public static string PackedPath
		{
			get
			{
				if (string.IsNullOrEmpty(_packedPath))
				{
					_packedPath = Path.Combine(ModPath() ?? "", "bundles");
				}
				return _packedPath;
			}
		}

		private static string ModPath()
		{
			return Assembly.GetExecutingAssembly().Location.Substring(0, Assembly.GetExecutingAssembly().Location.LastIndexOf("\\"));
		}
	}
	public static class Singletons
	{
		public static StyleHUD shud => MonoSingleton<StyleHUD>.Instance;

		public static GunControl gc => MonoSingleton<GunControl>.Instance;

		public static WeaponCharges wc => MonoSingleton<WeaponCharges>.Instance;

		public static TimeController timeController => MonoSingleton<TimeController>.Instance;
	}
	[BepInPlugin("herwordskill_accurategabriel", "Accurate Gabriel", "1.0.0")]
	public class AccurateGabriel : BaseUnityPlugin
	{
		public const string DISCLAIMER = "AN ORIGINAL MOD by HER WORDS [[Ultra]] KILL. BROUGHT TO YOU BY THE MELTED GORE OF THE SINNERS CRUSHED BENEATH MY DIVINE BLADE";

		public static Harmony harmony;

		private static ManualLogSource src;

		private void Start()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			harmony = new Harmony("herwordskill_accurategabriel");
			harmony.PatchAll(typeof(MovementPatches));
			harmony.PatchAll(typeof(VoicePatches));
			src = Logger.CreateLogSource("accurategabriel");
		}

		private void Update()
		{
		}

		public static void Log(string lol)
		{
			src.Log((LogLevel)16, (object)lol);
		}
	}
}
namespace AccurateGabriel.Patching
{
	public static class VoicePatches
	{
		public static AudioSource voiceSource;

		public static AudioSource dashSource;

		public static AudioClip[] goodVoices;

		public static AudioClip[] badVoices;

		public static AudioClip dashClip;

		public static GameObject dashEffect;

		public static GameObject weaponBreakPrefab;

		public static void PlayDash(Vector3 before, Vector3 after)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			dashSource.Play();
			if ((Object)(object)weaponBreakPrefab != (Object)null)
			{
				Object.Instantiate<GameObject>(weaponBreakPrefab, before, Quaternion.identity);
			}
			else
			{
				AccurateGabriel.Log("No weapon break found");
			}
			if ((Object)(object)dashEffect != (Object)null)
			{
				float num = 10f;
				for (int i = 0; (float)i < num; i++)
				{
					Vector3 val = Vector3.Lerp(before, after, (float)i / num);
					Object.Instantiate<GameObject>(dashEffect, val, Quaternion.identity);
				}
			}
			else
			{
				AccurateGabriel.Log("No dash effect found");
			}
		}

		[HarmonyPatch(typeof(NewMovement), "Start")]
		[HarmonyPrefix]
		private static void CreateVoice(NewMovement __instance)
		{
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			if (goodVoices == null)
			{
				List<AudioClip> list = new List<AudioClip>();
				List<AudioClip> list2 = new List<AudioClip>();
				AudioClip[] array = Resources.FindObjectsOfTypeAll<AudioClip>();
				AudioClip[] array2 = array;
				foreach (AudioClip val in array2)
				{
					if (((Object)val).name.ToLower().Contains("gab"))
					{
						if (((Object)val).name.ToLower().Contains("hurt"))
						{
							list2.Add(val);
						}
						if (((Object)val).name.ToLower().Contains("taunt"))
						{
							list.Add(val);
						}
						if (((Object)val).name.ToLower() == "gabrielweaponspawn")
						{
							dashClip = val;
						}
					}
				}
				goodVoices = list.ToArray();
				badVoices = list2.ToArray();
				GameObject[] array3 = Resources.FindObjectsOfTypeAll<GameObject>();
				GameObject[] array4 = array3;
				foreach (GameObject val2 in array4)
				{
					if (((Object)val2).name.Contains("GabrielWeaponBreak"))
					{
						weaponBreakPrefab = val2;
						((Object)weaponBreakPrefab).hideFlags = (HideFlags)32;
					}
					if (((Object)val2).name == "Decoy Gabriel")
					{
						dashEffect = val2;
						((Object)dashEffect).hideFlags = (HideFlags)32;
					}
				}
			}
			if (!((Object)(object)voiceSource != (Object)null))
			{
				voiceSource = new GameObject("Gabriel Voice").AddComponent<AudioSource>();
				dashSource = new GameObject("Gabriel Dash Sound").AddComponent<AudioSource>();
				dashSource.clip = dashClip;
			}
		}

		public static void Say(AudioClip[] bank)
		{
			if (!voiceSource.isPlaying)
			{
				AudioClip clip = bank[Random.Range(0, bank.Length - 1)];
				voiceSource.clip = clip;
				voiceSource.Play();
			}
		}

		[HarmonyPatch(typeof(StyleHUD), "AddPoints")]
		[HarmonyPrefix]
		private static void InitRanks(StyleHUD __instance, int points, string pointID, GameObject sourceWeapon = null, EnemyIdentifier eid = null, int count = -1, string prefix = "", string postfix = "")
		{
			if (pointID.Contains("kill"))
			{
				Say(goodVoices);
			}
		}

		[HarmonyPatch(typeof(NewMovement), "GetHurt")]
		[HarmonyPrefix]
		private static void InitRanks(NewMovement __instance)
		{
			Say(badVoices);
		}
	}
	public static class MovementPatches
	{
		private const float teleportDistance = 25f;

		[HarmonyPatch(typeof(NewMovement), "Dodge")]
		[HarmonyPrefix]
		private static bool NoDodge(NewMovement __instance)
		{
			return false;
		}

		[HarmonyPatch(typeof(NewMovement), "Update")]
		[HarmonyPrefix]
		private static void Teleport(NewMovement __instance)
		{
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: 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)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			__instance.boost = false;
			__instance.boostLeft = 0f;
			if (!MonoSingleton<InputManager>.Instance.InputSource.Dodge.WasPerformedThisFrame || !__instance.activated || __instance.slowMode || GameStateManager.Instance.PlayerInputLocked)
			{
				return;
			}
			if (__instance.boostCharge < 100f)
			{
				Object.Instantiate<GameObject>(__instance.staminaFailSound);
				return;
			}
			Vector3 position = ((Component)MonoSingleton<NewMovement>.Instance).transform.position;
			Vector3 movementDirection = __instance.movementDirection;
			__instance.boostCharge += 50f;
			RaycastHit val = default(RaycastHit);
			if (Physics.Raycast(((Component)MonoSingleton<CameraController>.Instance).transform.position, movementDirection, ref val, 25f, LayerMask.op_Implicit(LayerMaskDefaults.Get((LMD)1)), (QueryTriggerInteraction)1))
			{
				((Component)MonoSingleton<NewMovement>.Instance).transform.position = ((RaycastHit)(ref val)).point;
			}
			else
			{
				Transform transform = ((Component)MonoSingleton<NewMovement>.Instance).transform;
				transform.position += movementDirection * 25f;
			}
			VoicePatches.PlayDash(position, ((Component)MonoSingleton<NewMovement>.Instance).transform.position);
			MonoSingleton<NewMovement>.Instance.rb.velocity = Vector3.zero;
		}

		[HarmonyPatch(typeof(Wings), "FixedUpdate")]
		[HarmonyPrefix]
		private static void Fly(Wings __instance)
		{
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			if (!__instance.mov.activated)
			{
				((Component)((Component)__instance.bar).transform.parent).gameObject.SetActive(false);
				__instance.sys.Stop(true, (ParticleSystemStopBehavior)1);
				__instance.flyLoop.mute = true;
				return;
			}
			((Component)((Component)__instance.bar).transform.parent).gameObject.SetActive(true);
			__instance.charge = __instance.chargeMax;
			if (__instance.mov.gc.onGround && __instance.charge != __instance.chargeMax)
			{
				__instance.charge = __instance.chargeMax;
			}
			else if (__instance.refreshCooldown > 0f)
			{
				__instance.refreshCooldown -= Time.fixedDeltaTime;
			}
			else
			{
				__instance.charge += Time.fixedDeltaTime / 3f;
			}
			if (__instance.charge > 0f && __instance.input.Jump.IsPressed && ((Behaviour)__instance.mov).enabled)
			{
				__instance.wingFlapTimer -= Time.deltaTime;
				if (__instance.wingFlapTimer < 0f)
				{
					__instance.wingFlapTimer = 0.6f;
					__instance.src.pitch = Random.Range(0.95f, 1.1f);
					__instance.src.Play();
				}
				__instance.refreshCooldown = 0.25f;
				__instance.charge -= Time.fixedDeltaTime;
				Vector3 velocity = __instance.mov.rb.velocity;
				velocity.y = 20f;
				__instance.mov.rb.velocity = velocity;
				__instance.mov.rb.useGravity = false;
				__instance.flySound = Mathf.MoveTowards(__instance.flySound, 1f, Time.deltaTime * 2f);
				if (!__instance.sys.isPlaying)
				{
					__instance.sys.Play();
				}
			}
			else
			{
				__instance.mov.rb.useGravity = true;
				__instance.sys.Stop(true, (ParticleSystemStopBehavior)1);
				__instance.flySound = Mathf.MoveTowards(__instance.flySound, 0f, Time.deltaTime * 2f);
			}
			if (__instance.flySound == 0f)
			{
				__instance.flyLoop.mute = true;
				return;
			}
			__instance.flyLoop.mute = false;
			__instance.flyLoop.pitch = __instance.flySound * 0.3f;
		}
	}
}