Decompiled source of HoldoutHavoc v1.0.1

HoldoutHavoc.dll

Decompiled 4 months ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using IL.RoR2;
using Microsoft.CodeAnalysis;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using On.RoR2;
using RoR2;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("HoldoutHavoc")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("HoldoutHavoc")]
[assembly: AssemblyTitle("HoldoutHavoc")]
[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 HoldoutHavoc
{
	[BepInPlugin("com.Nuxlar.HoldoutHavoc", "HoldoutHavoc", "1.0.1")]
	public class HoldoutHavoc : BaseUnityPlugin
	{
		public void Awake()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			CombatDirector.Awake += new hook_Awake(CombatDirector_Awake);
			HoldoutZoneController.FixedUpdate += new Manipulator(RemoveE2);
		}

		private void CombatDirector_Awake(orig_Awake orig, CombatDirector self)
		{
			if (Object.op_Implicit((Object)(object)Run.instance) && (((Object)Run.instance).name == "ClassicRun(Clone)" || ((Object)Run.instance).name == "EclipseRun(Clone)") && ((Object)self).name.Contains("Teleporter"))
			{
				GameObject gameObject = ((Component)((Component)self).gameObject.GetComponent<HoldoutZoneController>().radiusIndicator).gameObject;
				if ((Object)(object)gameObject.GetComponent<ReverseNormals>() == (Object)null)
				{
					gameObject.AddComponent<ReverseNormals>();
				}
				if ((Object)(object)gameObject.GetComponent<MeshCollider>() == (Object)null)
				{
					gameObject.AddComponent<MeshCollider>();
				}
				float num = (float)(1.0 + 0.5 / (double)(Run.instance.stageClearCount + 2));
				self.creditMultiplier *= num;
			}
			orig.Invoke(self);
		}

		private void RemoveE2(ILContext il)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			ILCursor val = new ILCursor(il);
			if (val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdcR4(x, 0.5f)
			}))
			{
				val.Next.Operand = 1f;
			}
			else
			{
				Debug.LogError((object)"HoldoutHavoc: Failed to remove E2");
			}
		}
	}
	[RequireComponent(typeof(MeshFilter))]
	public class ReverseNormals : MonoBehaviour
	{
		private void Start()
		{
			//IL_0038: 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_0042: Unknown result type (might be due to invalid IL or missing references)
			Component component = ((Component)this).GetComponent(typeof(MeshFilter));
			MeshFilter val = (MeshFilter)(object)((component is MeshFilter) ? component : null);
			if ((Object)(object)val != (Object)null)
			{
				Mesh mesh = val.mesh;
				Vector3[] normals = mesh.normals;
				for (int i = 0; i < normals.Length; i++)
				{
					normals[i] = -normals[i];
				}
				mesh.normals = normals;
				for (int j = 0; j < mesh.subMeshCount; j++)
				{
					int[] triangles = mesh.GetTriangles(j);
					for (int k = 0; k < triangles.Length; k += 3)
					{
						ref int reference = ref triangles[k + 1];
						ref int reference2 = ref triangles[k];
						int num = triangles[k];
						int num2 = triangles[k + 1];
						reference = num;
						reference2 = num2;
					}
					mesh.SetTriangles(triangles, j);
				}
			}
			((Component)this).GetComponent<MeshCollider>().sharedMesh = val.mesh;
		}
	}
}