Decompiled source of NoPhase4Skip v1.0.1

NoPhase4Skip.dll

Decompiled 3 months ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using EntityStates;
using EntityStates.BrotherMonster;
using On.EntityStates.BrotherMonster;
using On.RoR2;
using RoR2;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Networking;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("NoPhase4Skip")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("NoPhase4Skip")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("3f82056c-d761-44d6-8c44-452d6202d81f")]
[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 NoPhase4Skip
{
	[BepInPlugin("com.Moffein.NoPhase4Skip", "NoPhase4Skip", "1.0.1")]
	public class NoPhase4Skip : BaseUnityPlugin
	{
		private static BodyIndex brotherHurtIndex;

		private void Awake()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: 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)
			//IL_004c: Expected O, but got Unknown
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Expected O, but got Unknown
			GameObject val = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Brother/BrotherHurtBody.prefab").WaitForCompletion();
			val.AddComponent<Phase4ImmuneComponent>();
			RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(OnLoad));
			HealthComponent.TakeDamage += new hook_TakeDamage(HealthComponent_TakeDamage);
			SpellBaseState.OnExit += new hook_OnExit(SpellBaseState_OnExit);
		}

		private void SpellBaseState_OnExit(orig_OnExit orig, SpellBaseState self)
		{
			Phase4ImmuneComponent component = ((EntityState)self).GetComponent<Phase4ImmuneComponent>();
			if (Object.op_Implicit((Object)(object)component) && component.spawnImmuneDuration > 0.1f)
			{
				component.spawnImmuneDuration = 0.1f;
			}
			orig.Invoke(self);
		}

		private void HealthComponent_TakeDamage(orig_TakeDamage orig, HealthComponent self, DamageInfo damageInfo)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			if (NetworkServer.active && self.body.bodyIndex == brotherHurtIndex && Object.op_Implicit((Object)(object)((Component)self).GetComponent<Phase4ImmuneComponent>()))
			{
				damageInfo.rejected = true;
			}
			orig.Invoke(self, damageInfo);
		}

		private void OnLoad()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			brotherHurtIndex = BodyCatalog.FindBodyIndex("BrotherHurtBody");
		}
	}
	public class Phase4ImmuneComponent : MonoBehaviour
	{
		public float spawnImmuneDuration = 10f;

		private void Awake()
		{
			if (!NetworkServer.active)
			{
				Object.Destroy((Object)(object)this);
			}
		}

		private void FixedUpdate()
		{
			spawnImmuneDuration -= Time.fixedDeltaTime;
			if (spawnImmuneDuration <= 0f)
			{
				Object.Destroy((Object)(object)this);
			}
		}
	}
}
namespace R2API.Utils
{
	[AttributeUsage(AttributeTargets.Assembly)]
	public class ManualNetworkRegistrationAttribute : Attribute
	{
	}
}