Decompiled source of UltraReprise v1.0.1

UltraReprise.dll

Decompiled 5 hours ago
using System;
using System.Collections;
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 BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using PluginConfig.API;
using PluginConfig.API.Decorators;
using PluginConfig.API.Fields;
using ULTRAKILL.Cheats;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.AddressableAssets;
using UnityEngine.Events;
using UnityEngine.ResourceManagement.AsyncOperations;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("UltraReprise")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("UltraReprise")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("d24676a8-4da0-4d43-a77a-48484b462e5c")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace UltraReprise;

public static class F_Utils
{
	public class AddresableObject<TObject>
	{
		[CompilerGenerated]
		private sealed class <Long_Load>d__5 : IEnumerator<object>, IDisposable, IEnumerator
		{
			private int <>1__state;

			private object <>2__current;

			public AddresableObject<TObject> <>4__this;

			private AsyncOperationHandle<TObject> <handle>5__1;

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

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

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

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				<handle>5__1 = default(AsyncOperationHandle<TObject>);
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0046: Unknown result type (might be due to invalid IL or missing references)
				//IL_004b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0052: Unknown result type (might be due to invalid IL or missing references)
				//IL_0077: Unknown result type (might be due to invalid IL or missing references)
				//IL_007d: Invalid comparison between Unknown and I4
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					if (<>4__this.obj != null)
					{
						return false;
					}
					<handle>5__1 = Addressables.LoadAssetAsync<TObject>((object)<>4__this.path);
					<>2__current = <handle>5__1;
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					if ((int)<handle>5__1.Status == 1)
					{
						<>4__this.fast_load = false;
						<>4__this.obj = <handle>5__1.Result;
					}
					return false;
				}
			}

			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 bool fast_load;

		public string path;

		public TObject obj;

		public TObject Object
		{
			get
			{
				//IL_0022: Unknown result type (might be due to invalid IL or missing references)
				//IL_0027: Unknown result type (might be due to invalid IL or missing references)
				if (obj == null)
				{
					fast_load = true;
					obj = Addressables.LoadAssetAsync<TObject>((object)path).WaitForCompletion();
				}
				return obj;
			}
		}

		public Transform[] childs => null;

		public Transform transform
		{
			get
			{
				if ((Object)(object)gameObject != (Object)null)
				{
					return gameObject.transform;
				}
				return null;
			}
		}

		public GameObject gameObject
		{
			get
			{
				object obj = Object;
				return (GameObject)((obj is GameObject) ? obj : null);
			}
		}

		[IteratorStateMachine(typeof(AddresableObject<>.<Long_Load>d__5))]
		public IEnumerator Long_Load()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <Long_Load>d__5(0)
			{
				<>4__this = this
			};
		}

		public T GetComponent<T>()
		{
			if ((Object)(object)gameObject != (Object)null)
			{
				return gameObject.GetComponent<T>();
			}
			return default(T);
		}

		public Transform GetChild(int id)
		{
			if ((Object)(object)transform != (Object)null)
			{
				return transform.GetChild(id);
			}
			return null;
		}

		public AddresableObject(string path)
		{
			this.path = path;
			fast_load = false;
		}

		public static implicit operator AddresableObject<TObject>(string path)
		{
			return new AddresableObject<TObject>(path);
		}

		public override string ToString()
		{
			return path;
		}
	}

	public class Keep_Obj_NearOffset_ThisEnemy : MonoBehaviour
	{
		private EnemyIdentifier Eid;

		public GameObject Obj_ToKeep;

		public Vector3 Offset = Vector3.zero;

		public void Start()
		{
			Eid = ((Component)this).GetComponent<EnemyIdentifier>();
			if ((Object)(object)Eid == (Object)null)
			{
				Eid = ((Component)this).GetComponentInParent<EnemyIdentifier>();
			}
			if ((Object)(object)Eid == (Object)null)
			{
				Eid = ((Component)this).GetComponent<EnemyIdentifierIdentifier>().eid;
			}
			if ((Object)(object)Eid == (Object)null)
			{
				Eid = ((Component)this).GetComponentInParent<EnemyIdentifierIdentifier>().eid;
			}
			if ((Object)(object)Eid == (Object)null)
			{
				Eid = ((Component)((Component)this).transform.parent).GetComponent<EnemyIdentifierIdentifier>().eid;
			}
			if ((Object)(object)Eid == (Object)null)
			{
				Eid = ((Component)((Component)this).transform.parent).GetComponentInParent<EnemyIdentifierIdentifier>().eid;
			}
		}

		public void Update()
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)Obj_ToKeep != (Object)null && (Object)(object)Eid != (Object)null && !Eid.Dead)
			{
				Obj_ToKeep.transform.position = ((Component)this).transform.TransformPoint(Offset);
			}
		}
	}

	public class ActivateWith : MonoBehaviour
	{
		public EnemyIdentifier idol;

		public void Start()
		{
			if (Object.op_Implicit((Object)(object)idol))
			{
				((Component)idol).gameObject.SetActive(true);
			}
		}
	}

	public class DestroyWith : MonoBehaviour
	{
		public EnemyIdentifier eid;

		public EnemyIdentifier idol;

		public void Start()
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Expected O, but got Unknown
			eid = ((Component)this).GetComponent<EnemyIdentifier>();
			if (!Object.op_Implicit((Object)(object)eid) || !Object.op_Implicit((Object)(object)idol))
			{
				return;
			}
			eid.onDeath.AddListener((UnityAction)delegate
			{
				if ((Object)(object)idol != (Object)null)
				{
					Object.Destroy((Object)(object)idol);
				}
			});
		}
	}

	public enum DetectebleEnemies
	{
		Idol
	}

	public static Dictionary<DetectebleEnemies, EnemyIdentifier> AllEnemiesEids = new Dictionary<DetectebleEnemies, EnemyIdentifier>();

	public static Dictionary<DetectebleEnemies, AddresableObject<GameObject>> AllEnemiesPrefabs = new Dictionary<DetectebleEnemies, AddresableObject<GameObject>> { [DetectebleEnemies.Idol] = new AddresableObject<GameObject>("Assets/Prefabs/Enemies/Idol.prefab") };

	public static bool UltraCheck(EnemyIdentifier eid)
	{
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_002f: Invalid comparison between Unknown and I4
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: Invalid comparison between Unknown and I4
		if (!UltraReprise_Settings.Mod_Enabled || (InvincibleEnemies.Enabled && eid.blessed) || eid.dead || eid.puppet || (int)eid.enemyType == 21 || (int)eid.enemyType == 39)
		{
			return true;
		}
		return false;
	}

	public static void UltraMethod(EnemyIdentifier eid)
	{
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_004f: Unknown result type (might be due to invalid IL or missing references)
		((Component)eid).gameObject.AddComponent<UltraRepriseMarker>();
		Enemy val = default(Enemy);
		if (((Component)eid).TryGetComponent<Enemy>(ref val))
		{
			Enemy obj = val;
			obj.health += 1f;
		}
		EnemyIdentifier val2 = eid.Make_IdolMerged(enableIdol: true);
		val2.dontCountAsKills = true;
		Transform transform = ((Component)val2).transform;
		transform.localScale *= 0.4f;
		if (UltraReprise_Settings.Sandify_Idols)
		{
			val2.Sandify(false);
		}
	}

	public static float CalculateDamage(float multiplier, float critMultiplier)
	{
		return multiplier + multiplier * 1f * critMultiplier;
	}

	public static bool Try_GetFrom_Config(BoolField boolField, bool regular = false)
	{
		try
		{
			if (boolField != null)
			{
				return boolField.value;
			}
		}
		catch
		{
		}
		return regular;
	}

	public static void DissableColliders(this Transform trf, Transform trc, bool ignore = true)
	{
		Collider[] componentsInChildren = ((Component)trf).GetComponentsInChildren<Collider>();
		Collider[] componentsInChildren2 = ((Component)trc).GetComponentsInChildren<Collider>();
		Collider[] array = componentsInChildren;
		foreach (Collider val in array)
		{
			Collider[] array2 = componentsInChildren2;
			foreach (Collider val2 in array2)
			{
				Physics.IgnoreCollision(val, val2, ignore);
			}
		}
	}

	public static EnemyIdentifier FindEnemyByType(DetectebleEnemies enemy)
	{
		EnemyIdentifier value = null;
		if (AllEnemiesEids.TryGetValue(enemy, out value) && (Object)(object)value != (Object)null)
		{
			return value;
		}
		if (AllEnemiesPrefabs.TryGetValue(enemy, out var value2))
		{
			value = value2.GetComponent<EnemyIdentifier>();
			if ((Object)(object)value != (Object)null)
			{
				AllEnemiesEids.Add(enemy, value);
				return value;
			}
			value = value2.gameObject.GetComponentInChildren<EnemyIdentifier>(true);
			if ((Object)(object)value != (Object)null)
			{
				AllEnemiesEids.Add(enemy, value);
				return value;
			}
			value = value2.gameObject.GetComponentInParent<EnemyIdentifier>(true);
			if ((Object)(object)value != (Object)null)
			{
				AllEnemiesEids.Add(enemy, value);
				return value;
			}
		}
		return null;
	}

	public static EnemyIdentifier Integrate_Enemy(DetectebleEnemies enemy, Transform Parent, bool active, Vector3 Pos = default(Vector3), Quaternion Quart = default(Quaternion))
	{
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_004a: Unknown result type (might be due to invalid IL or missing references)
		EnemyIdentifier val = FindEnemyByType(enemy);
		EnemyIdentifier val2 = null;
		GameObject val3 = null;
		val3 = Object.Instantiate<GameObject>(((Component)((Component)val).transform.root).gameObject, Pos, Quart);
		val3.transform.root.parent = Parent;
		val3.transform.position = Pos;
		val3.transform.rotation = Quart;
		val3.SetActive(active);
		KeepInBounds val4 = default(KeepInBounds);
		if (val3.TryGetComponent<KeepInBounds>(ref val4))
		{
			Object.Destroy((Object)(object)val4);
		}
		NavMeshAgent val5 = default(NavMeshAgent);
		if (val3.TryGetComponent<NavMeshAgent>(ref val5))
		{
			((Behaviour)val5).enabled = true;
		}
		return val3.GetComponent<EnemyIdentifier>();
	}

	public static EnemyIdentifier Make_IdolMerged(this EnemyIdentifier eid, bool enableIdol, bool keepNear = true, bool activateWith = false)
	{
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		EnemyIdentifier val = Integrate_Enemy(DetectebleEnemies.Idol, ((Component)eid).transform.parent, enableIdol, ((Component)eid).transform.position, ((Component)eid).transform.rotation);
		val.idol.overrideTarget = eid;
		((Component)val).transform.DissableColliders(((Component)eid).transform);
		if (keepNear)
		{
			Keep_Obj_NearOffset_ThisEnemy orAddComponent = GameObjectExtensions.GetOrAddComponent<Keep_Obj_NearOffset_ThisEnemy>(((Component)eid).gameObject);
			orAddComponent.Obj_ToKeep = ((Component)val).gameObject;
			ComponentExtensions.GetOrAddComponent<DestroyWith>((Component)(object)eid).idol = val;
		}
		if (activateWith)
		{
			ComponentExtensions.GetOrAddComponent<ActivateWith>((Component)(object)eid).idol = val;
		}
		return val;
	}
}
public static class UltraReprise_Settings
{
	public static BoolField V__Varb_Mod_Enabled;

	public static BoolField V__Varb_Sandify_Idols;

	public static bool Mod_Enabled => F_Utils.Try_GetFrom_Config(V__Varb_Mod_Enabled, regular: true);

	public static bool Sandify_Idols => F_Utils.Try_GetFrom_Config(V__Varb_Sandify_Idols);
}
[BepInPlugin("com.enragedone.ultrareprise", "UltraReprise", "1.0.1")]
public class UltraReprise_Loader : BaseUnityPlugin
{
	public const string GUID = "com.enragedone.ultrareprise";

	public const string Name = "UltraReprise";

	public const string Version = "1.0.1";

	public const string Set_Guid = "com.enragedone.ultrareprise.settings";

	public PluginConfigurator config;

	public bool Confing_Loaded = false;

	internal Harmony _Harmony = new Harmony("com.enragedone.fentokill.levelpatches");

	public static ManualLogSource _Logger;

	public static UltraReprise_Loader _Instance;

	public void Awake()
	{
		//IL_0087: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cd: Expected O, but got Unknown
		//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ed: Expected O, but got Unknown
		_Instance = this;
		_Logger = ((BaseUnityPlugin)this).Logger;
		_Logger.LogInfo((object)"UltraReprise_Loader v1.0.1 has started.");
		try
		{
			config = PluginConfigurator.Create("UltraReprise", "com.enragedone.ultrareprise.settings");
			string directoryName = Path.GetDirectoryName(typeof(UltraReprise_Loader).Assembly.Location);
			string text = Path.Combine(directoryName, "icon.png");
			config.SetIconWithURL("file://" + text);
			new ConfigHeader(config.rootPanel, "Main / Global Settings", 24).textColor = Color32.op_Implicit(new Color32((byte)105, (byte)172, byte.MaxValue, byte.MaxValue));
			UltraReprise_Settings.V__Varb_Mod_Enabled = new BoolField(config.rootPanel, "Mod Enabled", "com.enragedone.ultrareprise.settings.V__Varb_Mod_Enabled", true);
			UltraReprise_Settings.V__Varb_Sandify_Idols = new BoolField(config.rootPanel, "Sandify Idols", "com.enragedone.ultrareprise.settings.V__Varb_Sandify_Idols", false);
			_Logger.LogInfo((object)"Config v1.0.1 loaded successfully");
			Confing_Loaded = true;
		}
		catch
		{
			_Logger.LogError((object)"UltraReprise_Loader v1.0.1 !!!---!!! ERROR With PluginConfigurator Init");
		}
		_Harmony.PatchAll(typeof(Base_Patches));
		_Logger.LogInfo((object)"UltraReprise_Loader v1.0.1 loaded successfully without error.");
	}
}
public static class Base_Patches
{
	[HarmonyPatch(typeof(Enemy), "GetHurt")]
	[HarmonyPrefix]
	public static bool Enemy_GetHurt(Vector3 force, float multiplier, float critMultiplier, EnemyIdentifier ___eid, Enemy __instance)
	{
		if (F_Utils.UltraCheck(___eid))
		{
			return true;
		}
		UltraRepriseMarker ultraRepriseMarker = default(UltraRepriseMarker);
		if (__instance.health - F_Utils.CalculateDamage(multiplier, critMultiplier) < 0.15f && !((Component)__instance).TryGetComponent<UltraRepriseMarker>(ref ultraRepriseMarker))
		{
			F_Utils.UltraMethod(___eid);
			return false;
		}
		return true;
	}

	[HarmonyPatch(typeof(Enemy), "HandleParrying")]
	[HarmonyPostfix]
	public static void Enemy_HandleParrying(ref DamageData data, EnemyIdentifier ___eid, Enemy __instance)
	{
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		UltraRepriseMarker ultraRepriseMarker = default(UltraRepriseMarker);
		if (!F_Utils.UltraCheck(___eid) && (__instance.health <= 0.1f || __instance.parryable) && !((Component)__instance).TryGetComponent<UltraRepriseMarker>(ref ultraRepriseMarker))
		{
			__instance.health = Mathf.Max(__instance.health, 1f);
			data.damage = 0f;
			data.force = Vector3.zero;
			data.cancel = true;
			F_Utils.UltraMethod(___eid);
		}
	}

	[HarmonyPatch(typeof(EnemyScript), "OnParry")]
	[HarmonyPrefix]
	public static bool EnemyScript_OnParry(EnemyScript __instance)
	{
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_001f: Invalid comparison between Unknown and I4
		EnemyIdentifier component = ((Component)__instance).GetComponent<EnemyIdentifier>();
		if (!Object.op_Implicit((Object)(object)component) || F_Utils.UltraCheck(component) || (int)component.enemyType == 6)
		{
			return true;
		}
		UltraRepriseMarker ultraRepriseMarker = default(UltraRepriseMarker);
		if (!((Component)__instance).TryGetComponent<UltraRepriseMarker>(ref ultraRepriseMarker))
		{
			F_Utils.UltraMethod(component);
			return false;
		}
		return true;
	}

	[HarmonyPatch(typeof(Streetcleaner), "HandleCanisterHit")]
	[HarmonyPrefix]
	public static bool Streetcleaner_HandleCanisterHit(EnemyIdentifier ___eid, Streetcleaner __instance)
	{
		if (F_Utils.UltraCheck(___eid))
		{
			return true;
		}
		UltraRepriseMarker ultraRepriseMarker = default(UltraRepriseMarker);
		if (!((Component)__instance).TryGetComponent<UltraRepriseMarker>(ref ultraRepriseMarker))
		{
			F_Utils.UltraMethod(___eid);
			return false;
		}
		return true;
	}

	[HarmonyPatch(typeof(EnemyIdentifier), "DeliverDamage")]
	[HarmonyPrefix]
	public static bool EnemyIdentifier_DeliverDamage(Vector3 force, float multiplier, int ___difficulty, EnemyIdentifier __instance)
	{
		if (F_Utils.UltraCheck(__instance))
		{
			return true;
		}
		multiplier *= __instance.totalDamageTakenMultiplier;
		multiplier /= __instance.totalHealthModifier;
		if (__instance.isBoss && ___difficulty >= 4)
		{
			multiplier = ((___difficulty != 5) ? (multiplier / 1.5f) : (multiplier / 2f));
		}
		if (__instance.weaknesses.Length != 0)
		{
			for (int i = 0; i < __instance.weaknesses.Length; i++)
			{
				if (__instance.hitter == __instance.weaknesses[i] || (__instance.hitterAttributes.Contains((HitterAttribute)2) && __instance.weaknesses[i] == "electricity"))
				{
					multiplier *= __instance.weaknessMultipliers[i];
				}
			}
		}
		UltraRepriseMarker ultraRepriseMarker = default(UltraRepriseMarker);
		if (__instance.health - multiplier < 0.15f && !((Component)__instance).TryGetComponent<UltraRepriseMarker>(ref ultraRepriseMarker))
		{
			F_Utils.UltraMethod(__instance);
			return false;
		}
		return true;
	}

	[HarmonyPatch(typeof(EnemyIdentifier), "Splatter")]
	[HarmonyPrefix]
	public static bool EnemyIdentifier_Splatter(EnemyIdentifier __instance)
	{
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Invalid comparison between Unknown and I4
		if (F_Utils.UltraCheck(__instance) || (int)__instance.enemyType == 6)
		{
			return true;
		}
		UltraRepriseMarker ultraRepriseMarker = default(UltraRepriseMarker);
		if (!((Component)__instance).TryGetComponent<UltraRepriseMarker>(ref ultraRepriseMarker))
		{
			F_Utils.UltraMethod(__instance);
			return false;
		}
		return true;
	}

	[HarmonyPatch(typeof(EnemyIdentifier), "Explode")]
	[HarmonyPrefix]
	public static bool EnemyIdentifier_Explode(EnemyIdentifier __instance)
	{
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Invalid comparison between Unknown and I4
		if (F_Utils.UltraCheck(__instance) || (int)__instance.enemyType == 6)
		{
			return true;
		}
		UltraRepriseMarker ultraRepriseMarker = default(UltraRepriseMarker);
		if (!((Component)__instance).TryGetComponent<UltraRepriseMarker>(ref ultraRepriseMarker))
		{
			F_Utils.UltraMethod(__instance);
			return false;
		}
		return true;
	}

	[HarmonyPatch(typeof(EnemyIdentifier), "ProcessDeath")]
	[HarmonyPrefix]
	public static bool EnemyIdentifier_ProcessDeath(EnemyIdentifier __instance)
	{
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Invalid comparison between Unknown and I4
		if (F_Utils.UltraCheck(__instance) || (int)__instance.enemyType == 6)
		{
			return true;
		}
		UltraRepriseMarker ultraRepriseMarker = default(UltraRepriseMarker);
		if (!((Component)__instance).TryGetComponent<UltraRepriseMarker>(ref ultraRepriseMarker))
		{
			F_Utils.UltraMethod(__instance);
			return false;
		}
		return true;
	}
}
public class UltraRepriseMarker : MonoBehaviour
{
}