Decompiled source of AraRevive v1.2.1

plugins/AraRevive.dll

Decompiled a day ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("AraRevive")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.2.1.0")]
[assembly: AssemblyInformationalVersion("1.2.1")]
[assembly: AssemblyProduct("AraRevive")]
[assembly: AssemblyTitle("AraRevive")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.2.1.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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[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;
		}
	}
}
[BepInPlugin("AraRevive", "AraRevive", "0.1")]
public class TeamResurrectorPlugin : BaseUnityPlugin
{
	public class SpawnposTarget
	{
		private float lowestClimbed = float.MaxValue;

		public Character? LowestCharacter;

		public void RegisterCharacter(Character character, CharacterData characterData)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)character == (Object)null) && character.Center.y < lowestClimbed && !characterData.fullyPassedOut && !characterData._dead)
			{
				lowestClimbed = character.Center.y;
				LowestCharacter = character;
			}
		}
	}

	[HarmonyPatch(typeof(Character), "RPCA_Die")]
	public static class DiePatch
	{
		public static void Postfix(Character __instance)
		{
			if (IsModEnabled.Value && PhotonNetwork.IsMasterClient && !((Object)(object)__instance == (Object)null))
			{
				StaticCoroutine.Execute(ResurrectRoutine(__instance));
			}
		}
	}

	[HarmonyPatch(typeof(Character), "RPCA_Zombify")]
	public static class ZombifyPatch
	{
		public static void Postfix(Character __instance)
		{
			if (IsModEnabled.Value && PhotonNetwork.IsMasterClient && !((Object)(object)__instance == (Object)null))
			{
				StaticCoroutine.Execute(ResurrectRoutine(__instance));
			}
		}
	}

	[HarmonyPatch(typeof(Character), "RPCA_SetDead")]
	public static class ReconnectPatch
	{
		public static void Postfix(Character __instance)
		{
			if (IsModEnabled.Value && PhotonNetwork.IsMasterClient && !((Object)(object)__instance == (Object)null))
			{
				StaticCoroutine.Execute(ResurrectRoutine(__instance));
			}
		}
	}

	[CompilerGenerated]
	private sealed class <ResurrectRoutine>d__6 : IEnumerator<object>, IEnumerator, IDisposable
	{
		private int <>1__state;

		private object <>2__current;

		public Character deadChar;

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

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

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

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: 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_0118: Unknown result type (might be due to invalid IL or missing references)
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>2__current = (object)new WaitForSeconds(ReviveWaittime.Value);
				<>1__state = 1;
				return true;
			case 1:
			{
				<>1__state = -1;
				SpawnposTarget spawnposTarget = PopulateSpawnData(deadChar);
				if ((Object)(object)deadChar == (Object)null || (Object)(object)((MonoBehaviourPun)deadChar).photonView == (Object)null)
				{
					return false;
				}
				if ((Object)(object)spawnposTarget.LowestCharacter == (Object)null)
				{
					Debug.LogWarning((object)("[AraRevive] Reviving " + ((Object)deadChar).name + " is canceled: No valid surviving teammates."));
					return false;
				}
				if (!deadChar.data._dead && !deadChar.data._zombified)
				{
					Debug.LogWarning((object)("[AraRevive] Reviving " + ((Object)deadChar).name + " is canceled: Character is not dead anymore."));
					return false;
				}
				Vector3 val = spawnposTarget.LowestCharacter.Center + Vector3.up * 3f;
				((MonoBehaviourPun)deadChar).photonView.RPC("RPCA_ReviveAtPosition", (RpcTarget)0, new object[3] { val, ReviveWithMalus.Value, -1 });
				Debug.Log((object)("[AraRevive] " + ((Object)deadChar).name + " Revived at: " + ((Object)spawnposTarget.LowestCharacter).name + "'s position."));
				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 static ConfigEntry<bool> IsModEnabled;

	public static ConfigEntry<bool> ReviveWithMalus;

	public static ConfigEntry<float> ReviveWaittime;

	private void Awake()
	{
		//IL_0069: Unknown result type (might be due to invalid IL or missing references)
		//IL_006f: Expected O, but got Unknown
		IsModEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "모드 활성화 여부");
		ReviveWithMalus = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ReviveWithMalus", true, "부활 시 디버프(Malus) 적용 여부");
		ReviveWaittime = ((BaseUnityPlugin)this).Config.Bind<float>("General", "ReviveWaittime", 5f, "부활 대기 시간");
		Harmony val = new Harmony("AraRevive");
		val.PatchAll();
		((BaseUnityPlugin)this).Logger.LogInfo((object)"[AraRevive] Loaded.");
	}

	private static SpawnposTarget PopulateSpawnData(Character deadchar)
	{
		SpawnposTarget spawnposTarget = new SpawnposTarget();
		foreach (Character allCharacter in Character.AllCharacters)
		{
			if (!((Object)(object)allCharacter == (Object)null) && !((Object)(object)allCharacter.data == (Object)null))
			{
				spawnposTarget.RegisterCharacter(allCharacter, allCharacter.data);
			}
		}
		return spawnposTarget;
	}

	[IteratorStateMachine(typeof(<ResurrectRoutine>d__6))]
	private static IEnumerator ResurrectRoutine(Character deadChar)
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <ResurrectRoutine>d__6(0)
		{
			deadChar = deadChar
		};
	}
}
public class StaticCoroutine : MonoBehaviour
{
	private static StaticCoroutine _instance;

	private static StaticCoroutine Instance
	{
		get
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Expected O, but got Unknown
			if ((Object)(object)_instance == (Object)null)
			{
				_instance = Object.FindObjectOfType<StaticCoroutine>();
				if ((Object)(object)_instance == (Object)null)
				{
					GameObject val = new GameObject("ResurrectionRunner");
					_instance = val.AddComponent<StaticCoroutine>();
					Object.DontDestroyOnLoad((Object)(object)val);
				}
			}
			return _instance;
		}
	}

	public static void Execute(IEnumerator routine)
	{
		if (routine != null)
		{
			((MonoBehaviour)Instance).StartCoroutine(routine);
		}
	}
}
namespace BepInEx
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class BepInAutoPluginAttribute : Attribute
	{
		public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace BepInEx.Preloader.Core.Patching
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class PatcherAutoPluginAttribute : Attribute
	{
		public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}