Decompiled source of Respawn For Mithrix HostOnly v1.0.0

RespawnForBoss.dll

Decompiled a month 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 EntityStates.MeridianEvent;
using EntityStates.Missions.BrotherEncounter;
using Microsoft.CodeAnalysis;
using On.EntityStates.MeridianEvent;
using On.EntityStates.Missions.BrotherEncounter;
using RoR2;
using UnityEngine;
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: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("RespawnForBoss")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+d7b601910e88ceb35c7209690147b23afaaefbe9")]
[assembly: AssemblyProduct("RespawnForBoss")]
[assembly: AssemblyTitle("RespawnForBoss")]
[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 RespawnForBoss
{
	[BepInPlugin("OakPrime.Respawn_For_Mithrix_HostOnly", "Respawn For Mithrix HostOnly", "1.0.0")]
	public class RespawnForBoss : BaseUnityPlugin
	{
		public const string PluginGUID = "OakPrime.Respawn_For_Mithrix_HostOnly";

		public const string PluginAuthor = "OakPrime";

		public const string PluginName = "Respawn For Mithrix HostOnly";

		public const string PluginVersion = "1.0.0";

		public void Awake()
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Expected O, but got Unknown
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			try
			{
				PreEncounter.OnEnter += (hook_OnEnter)delegate(orig_OnEnter orig, PreEncounter self)
				{
					orig.Invoke(self);
					RespawnDeadPlayersAtFriendsPosition();
				};
				MeridianEventStart.OnEnter += (hook_OnEnter)delegate(orig_OnEnter orig, MeridianEventStart self)
				{
					orig.Invoke(self);
					RespawnDeadPlayersAtFriendsPosition();
				};
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)(ex.Message + " - " + ex.StackTrace));
			}
		}

		public void RespawnDeadPlayersAtFriendsPosition()
		{
			//IL_00a4: 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_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Invalid comparison between Unknown and I4
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			((BaseUnityPlugin)this).Logger.LogDebug((object)"Attempting revive");
			if (!NetworkServer.active)
			{
				return;
			}
			CharacterBody val = null;
			foreach (PlayerCharacterMasterController item in PlayerCharacterMasterController._instancesReadOnly)
			{
				if ((Object)(object)item.master != (Object)null && !item.master.IsDeadAndOutOfLivesServer() && (Object)(object)item.body != (Object)null)
				{
					val = item.body;
				}
			}
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			Vector3 footPosition = val.footPosition;
			foreach (CharacterMaster readOnlyInstances in CharacterMaster.readOnlyInstancesList)
			{
				if (readOnlyInstances.IsDeadAndOutOfLivesServer() && (int)readOnlyInstances.teamIndex == 1)
				{
					readOnlyInstances.Respawn(footPosition, Quaternion.Euler(0f, Random.Range(0f, 360f), 0f), true);
					readOnlyInstances.GetBody().AddTimedBuff(Buffs.Immune, 3f);
					if (!Object.op_Implicit((Object)(object)readOnlyInstances.bodyInstanceObject))
					{
						break;
					}
					EntityStateMachine[] components = readOnlyInstances.bodyInstanceObject.GetComponents<EntityStateMachine>();
					foreach (EntityStateMachine val2 in components)
					{
						val2.initialStateType = val2.mainStateType;
					}
				}
			}
		}
	}
}