Decompiled source of EnemyBeamer Possession v1.0.0

RepoEnemyMod.dll

Decompiled 4 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using Photon.Pun;
using UnityEngine;
using UnityEngine.AI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("RepoEnemyMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("RepoEnemyMod")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("d0c7a948-e542-43c0-8441-e4a6d60402ff")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace RepoEnemyBeamerMod;

[BepInPlugin("com.modder.repo.enemypossession.beamer", "EnemyBeamer Possession Mod", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
	private Harmony harmony;

	private void Awake()
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Expected O, but got Unknown
		harmony = new Harmony("com.modder.repo.enemypossession.beamer");
		harmony.PatchAll();
		((Component)this).gameObject.AddComponent<PossessionMonitor>();
		((BaseUnityPlugin)this).Logger.LogInfo((object)"【RepoMod】EnemyBeamer ing!");
	}
}
public static class PossessionManager
{
	public static bool IsPossessed = false;

	public static EnemyBeamer CurrentControlledAnimal = null;

	public static GameObject localPlayerObject = null;

	public static Vector3 originalPlayerPos;

	public static Quaternion originalPlayerRot;

	public static Camera mainCamera = null;

	public static Transform originalCamParent = null;

	public static Vector3 originalCamLocalPos;

	public static Quaternion originalCamLocalRot;

	public static AudioListener currentAudioListener = null;

	public static Transform originalAudioListenerParent = null;

	public static Vector3 originalAudioListenerLocalPos;

	public static Quaternion originalAudioListenerLocalRot;

	public static List<Behaviour> disabledPlayerBehaviours = new List<Behaviour>();

	public static float cameraYaw = 0f;

	public static float cameraPitch = 20f;

	public const float CameraRadius = 3.5f;

	public static bool isAttackingWindup = false;

	public static float attackWindupTimer = 0f;

	public static Dictionary<string, object> nativeStates = new Dictionary<string, object>();
}
[DefaultExecutionOrder(10000)]
public class PossessionMonitor : MonoBehaviour
{
	private void Update()
	{
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_006b: 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)
		if (PossessionManager.IsPossessed && (Object)(object)PossessionManager.localPlayerObject != (Object)null)
		{
			PossessionManager.localPlayerObject.transform.position = PossessionManager.originalPlayerPos;
			PossessionManager.localPlayerObject.transform.rotation = PossessionManager.originalPlayerRot;
			Rigidbody component = PossessionManager.localPlayerObject.GetComponent<Rigidbody>();
			if ((Object)(object)component != (Object)null && !component.isKinematic)
			{
				component.velocity = Vector3.zero;
				component.angularVelocity = Vector3.zero;
			}
		}
		if (Input.GetKeyDown((KeyCode)286))
		{
			if (PossessionManager.IsPossessed)
			{
				EnemyPossessionPatch.ExitPossession(PossessionManager.CurrentControlledAnimal);
			}
			else
			{
				EnemyBeamer val = FindNearestEnemyBeamer();
				if ((Object)(object)val != (Object)null)
				{
					EnemyPossessionPatch.EnterPossession(val);
				}
			}
		}
		if (PossessionManager.IsPossessed)
		{
			EnemyBeamer currentControlledAnimal = PossessionManager.CurrentControlledAnimal;
			if ((Object)(object)currentControlledAnimal == (Object)null || (Object)(object)((Component)currentControlledAnimal).gameObject == (Object)null || !((Component)currentControlledAnimal).gameObject.activeInHierarchy)
			{
				EnemyPossessionPatch.ExitPossession(null);
			}
			else
			{
				HandleBeamerControl(currentControlledAnimal);
			}
		}
	}

	private void LateUpdate()
	{
		//IL_002c: 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_00c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0100: Unknown result type (might be due to invalid IL or missing references)
		//IL_0134: Unknown result type (might be due to invalid IL or missing references)
		//IL_0167: Unknown result type (might be due to invalid IL or missing references)
		//IL_016c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0176: Unknown result type (might be due to invalid IL or missing references)
		//IL_017b: Unknown result type (might be due to invalid IL or missing references)
		//IL_018e: Unknown result type (might be due to invalid IL or missing references)
		//IL_019f: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_01af: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01be: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0189: Unknown result type (might be due to invalid IL or missing references)
		if (!PossessionManager.IsPossessed)
		{
			return;
		}
		if ((Object)(object)PossessionManager.localPlayerObject != (Object)null)
		{
			PossessionManager.localPlayerObject.transform.position = PossessionManager.originalPlayerPos;
		}
		EnemyBeamer currentControlledAnimal = PossessionManager.CurrentControlledAnimal;
		if ((Object)(object)currentControlledAnimal != (Object)null && (Object)(object)PossessionManager.mainCamera != (Object)null)
		{
			float num = Input.GetAxis("Mouse X") * 3.5f;
			float num2 = Input.GetAxis("Mouse Y") * 3.5f;
			PossessionManager.cameraYaw += num;
			PossessionManager.cameraPitch -= num2;
			PossessionManager.cameraPitch = Mathf.Clamp(PossessionManager.cameraPitch, -45f, 60f);
			Quaternion rotation = Quaternion.Euler(0f, PossessionManager.cameraYaw, 0f);
			((Component)currentControlledAnimal).transform.rotation = rotation;
			if ((Object)(object)currentControlledAnimal.aimVerticalTransform != (Object)null)
			{
				currentControlledAnimal.aimVerticalTransform.localRotation = Quaternion.Euler(PossessionManager.cameraPitch, 0f, 0f);
			}
			if ((Object)(object)currentControlledAnimal.laserRayTransform != (Object)null)
			{
				currentControlledAnimal.laserRayTransform.localRotation = Quaternion.Euler(PossessionManager.cameraPitch, 0f, 0f);
			}
			Enemy component = ((Component)currentControlledAnimal).GetComponent<Enemy>();
			Vector3 val = (((Object)(object)component != (Object)null && (Object)(object)component.CenterTransform != (Object)null) ? component.CenterTransform.position : (((Component)currentControlledAnimal).transform.position + Vector3.up * 1f));
			Quaternion val2 = Quaternion.Euler(PossessionManager.cameraPitch, PossessionManager.cameraYaw, 0f);
			Vector3 position = val - val2 * Vector3.forward * 3.5f;
			((Component)PossessionManager.mainCamera).transform.position = position;
			((Component)PossessionManager.mainCamera).transform.rotation = val2;
		}
	}

	private EnemyBeamer FindNearestEnemyBeamer()
	{
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: Unknown result type (might be due to invalid IL or missing references)
		EnemyBeamer[] array = Object.FindObjectsOfType<EnemyBeamer>();
		EnemyBeamer result = null;
		float num = float.MaxValue;
		Camera main = Camera.main;
		Vector3 val = (((Object)(object)main != (Object)null) ? ((Component)main).transform.position : Vector3.zero);
		EnemyBeamer[] array2 = array;
		foreach (EnemyBeamer val2 in array2)
		{
			if (!((Object)(object)val2 == (Object)null) && ((Component)val2).gameObject.activeInHierarchy)
			{
				float num2 = Vector3.Distance(val, ((Component)val2).transform.position);
				if (num2 < num && num2 < 500f)
				{
					num = num2;
					result = val2;
				}
			}
		}
		return result;
	}

	private void HandleBeamerControl(EnemyBeamer beamer)
	{
		//IL_008a: Unknown result type (might be due to invalid IL or missing references)
		//IL_008f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ef: 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_00f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0101: Unknown result type (might be due to invalid IL or missing references)
		//IL_0105: Unknown result type (might be due to invalid IL or missing references)
		//IL_010a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0217: Unknown result type (might be due to invalid IL or missing references)
		//IL_021c: Unknown result type (might be due to invalid IL or missing references)
		//IL_021f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0229: Unknown result type (might be due to invalid IL or missing references)
		//IL_022e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0233: Unknown result type (might be due to invalid IL or missing references)
		//IL_0235: Unknown result type (might be due to invalid IL or missing references)
		//IL_0237: Unknown result type (might be due to invalid IL or missing references)
		//IL_0241: Unknown result type (might be due to invalid IL or missing references)
		//IL_0246: Unknown result type (might be due to invalid IL or missing references)
		//IL_024b: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_029e: Unknown result type (might be due to invalid IL or missing references)
		NavMeshAgent component = ((Component)beamer).GetComponent<NavMeshAgent>();
		if ((Object)(object)component != (Object)null && ((Behaviour)component).enabled)
		{
			((Behaviour)component).enabled = false;
		}
		float num = 0f;
		float num2 = 0f;
		if (Input.GetKey((KeyCode)119))
		{
			num2 += 1f;
		}
		if (Input.GetKey((KeyCode)115))
		{
			num2 -= 1f;
		}
		if (Input.GetKey((KeyCode)97))
		{
			num -= 1f;
		}
		if (Input.GetKey((KeyCode)100))
		{
			num += 1f;
		}
		Vector3 val = Vector3.zero;
		if ((Object)(object)PossessionManager.mainCamera != (Object)null)
		{
			Vector3 forward = ((Component)PossessionManager.mainCamera).transform.forward;
			Vector3 right = ((Component)PossessionManager.mainCamera).transform.right;
			forward.y = 0f;
			right.y = 0f;
			((Vector3)(ref forward)).Normalize();
			((Vector3)(ref right)).Normalize();
			Vector3 val2 = forward * num2 + right * num;
			val = ((Vector3)(ref val2)).normalized;
		}
		FieldInfo field = typeof(EnemyBeamer).GetField("moveFast", BindingFlags.Instance | BindingFlags.NonPublic);
		bool flag = field != null && (bool)field.GetValue(beamer);
		float num3 = 3.5f;
		if ((Object)(object)component != (Object)null && component.speed > 0f)
		{
			num3 = component.speed;
		}
		if (flag)
		{
			num3 *= 2f;
		}
		if (!PossessionManager.isAttackingWindup)
		{
			FieldInfo field2 = typeof(EnemyBeamer).GetField("currentState", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			object obj = ((field2 != null) ? field2.GetValue(beamer) : null);
			if (!PossessionManager.nativeStates.TryGetValue("attack", out var value) || obj == null || !obj.Equals(value))
			{
				if (((Vector3)(ref val)).magnitude > 0.1f)
				{
					Vector3 val3 = ((Component)beamer).transform.position + val * num3 * Time.deltaTime;
					RaycastHit val4 = default(RaycastHit);
					if (Physics.Raycast(val3 + Vector3.up * 1f, Vector3.down, ref val4, 2f) && (Object)(object)((RaycastHit)(ref val4)).transform.root != (Object)(object)((Component)beamer).transform.root && !((RaycastHit)(ref val4)).collider.isTrigger)
					{
						val3.y = ((RaycastHit)(ref val4)).point.y;
					}
					((Component)beamer).transform.position = val3;
					SetBeamerState(beamer, "Roam");
				}
				else
				{
					SetBeamerState(beamer, "Idle");
				}
			}
		}
		if (Input.GetMouseButtonDown(0))
		{
			PossessionManager.isAttackingWindup = true;
			PossessionManager.attackWindupTimer = 0f;
			SetBeamerState(beamer, "AttackStart");
		}
		if (PossessionManager.isAttackingWindup)
		{
			PossessionManager.attackWindupTimer += Time.deltaTime;
			if (PossessionManager.attackWindupTimer >= 1.5f)
			{
				PossessionManager.isAttackingWindup = false;
				SetBeamerState(beamer, "Attack");
			}
		}
		if (Input.GetMouseButtonUp(0))
		{
			PossessionManager.isAttackingWindup = false;
			SetBeamerState(beamer, "Idle");
		}
		if (Input.GetMouseButtonDown(1))
		{
			PhotonView component2 = ((Component)beamer).GetComponent<PhotonView>();
			if ((Object)(object)component2 != (Object)null && SemiFunc.IsMultiplayer())
			{
				component2.RPC("MeleeTriggerRPC", (RpcTarget)0, Array.Empty<object>());
			}
			else
			{
				((Component)beamer).SendMessage("MeleeTriggerRPC", (SendMessageOptions)1);
			}
			SetBeamerState(beamer, "MeleeStart");
		}
		if (Input.GetKeyDown((KeyCode)101))
		{
			bool flag2 = !flag;
			field?.SetValue(beamer, flag2);
			PhotonView component3 = ((Component)beamer).GetComponent<PhotonView>();
			if ((Object)(object)component3 != (Object)null && SemiFunc.IsMultiplayer())
			{
				component3.RPC("MoveFastRPC", (RpcTarget)1, new object[1] { flag2 });
			}
		}
	}

	private void SetBeamerState(EnemyBeamer beamer, string stateName)
	{
		if (PossessionManager.nativeStates.TryGetValue(stateName.ToLower(), out var value))
		{
			FieldInfo field = typeof(EnemyBeamer).GetField("currentState", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			FieldInfo field2 = typeof(EnemyBeamer).GetField("stateImpulse", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			FieldInfo field3 = typeof(EnemyBeamer).GetField("stateTimer", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			field?.SetValue(beamer, value);
			field2?.SetValue(beamer, true);
			field3?.SetValue(beamer, 0f);
			PhotonView component = ((Component)beamer).GetComponent<PhotonView>();
			if ((Object)(object)component != (Object)null && SemiFunc.IsMultiplayer())
			{
				component.RPC("UpdateStateRPC", (RpcTarget)0, new object[1] { value });
			}
		}
	}
}
[HarmonyPatch(typeof(EnemyBeamer), "UpdateStateRPC")]
public class EnemyBeamerRPCBlockPatch
{
	private static bool Prefix(EnemyBeamer __instance)
	{
		if (PossessionManager.IsPossessed && (Object)(object)PossessionManager.CurrentControlledAnimal == (Object)(object)__instance)
		{
			return false;
		}
		return true;
	}
}
[HarmonyPatch(typeof(EnemyBeamer), "Update")]
public class EnemyBeamerUpdatePatch
{
	private static bool Prefix(EnemyBeamer __instance)
	{
		if (PossessionManager.IsPossessed && (Object)(object)PossessionManager.CurrentControlledAnimal == (Object)(object)__instance)
		{
			((Component)__instance).SendMessage("VerticalAimLogic", (SendMessageOptions)1);
			((Component)__instance).SendMessage("LaserLogic", (SendMessageOptions)1);
			return false;
		}
		return true;
	}
}
public class EnemyPossessionPatch
{
	public static void EnterPossession(EnemyBeamer beamer)
	{
		//IL_0131: Unknown result type (might be due to invalid IL or missing references)
		//IL_0136: Unknown result type (might be due to invalid IL or missing references)
		//IL_0145: Unknown result type (might be due to invalid IL or missing references)
		//IL_014a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0166: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0242: Unknown result type (might be due to invalid IL or missing references)
		//IL_0247: Unknown result type (might be due to invalid IL or missing references)
		//IL_0252: Unknown result type (might be due to invalid IL or missing references)
		//IL_0257: Unknown result type (might be due to invalid IL or missing references)
		PossessionManager.IsPossessed = true;
		PossessionManager.CurrentControlledAnimal = beamer;
		PossessionManager.isAttackingWindup = false;
		FieldInfo field = typeof(EnemyBeamer).GetField("currentState", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
		if (field != null)
		{
			Type fieldType = field.FieldType;
			PossessionManager.nativeStates.Clear();
			string[] names = Enum.GetNames(fieldType);
			Array values = Enum.GetValues(fieldType);
			for (int i = 0; i < names.Length; i++)
			{
				PossessionManager.nativeStates[names[i].ToLower()] = values.GetValue(i);
			}
		}
		Rigidbody component = ((Component)beamer).GetComponent<Rigidbody>();
		if ((Object)(object)component != (Object)null)
		{
			component.isKinematic = true;
		}
		Component component2 = ((Component)beamer).GetComponent("EnemyHealthBar");
		if ((Object)(object)component2 != (Object)null)
		{
			((object)component2).GetType().GetProperty("enabled")?.SetValue(component2, false);
		}
		PossessionManager.mainCamera = Camera.main;
		if ((Object)(object)PossessionManager.mainCamera != (Object)null)
		{
			PossessionManager.originalCamParent = ((Component)PossessionManager.mainCamera).transform.parent;
			PossessionManager.originalCamLocalPos = ((Component)PossessionManager.mainCamera).transform.localPosition;
			PossessionManager.originalCamLocalRot = ((Component)PossessionManager.mainCamera).transform.localRotation;
			((Component)PossessionManager.mainCamera).transform.SetParent((Transform)null);
			PossessionManager.cameraYaw = ((Component)beamer).transform.eulerAngles.y;
			PossessionManager.cameraPitch = 20f;
		}
		PossessionManager.currentAudioListener = Object.FindObjectOfType<AudioListener>();
		if ((Object)(object)PossessionManager.currentAudioListener != (Object)null && (Object)(object)PossessionManager.mainCamera != (Object)null)
		{
			PossessionManager.originalAudioListenerParent = ((Component)PossessionManager.currentAudioListener).transform.parent;
			((Component)PossessionManager.currentAudioListener).transform.localPosition = ((Component)PossessionManager.currentAudioListener).transform.localPosition;
			((Component)PossessionManager.currentAudioListener).transform.localRotation = ((Component)PossessionManager.currentAudioListener).transform.localRotation;
			((Component)PossessionManager.currentAudioListener).transform.SetParent(((Component)PossessionManager.mainCamera).transform, false);
		}
		GameObject val = GameObject.FindGameObjectWithTag("Player");
		if ((Object)(object)val != (Object)null)
		{
			PossessionManager.localPlayerObject = val;
			PossessionManager.originalPlayerPos = val.transform.position;
			PossessionManager.originalPlayerRot = val.transform.rotation;
			Renderer[] componentsInChildren = val.GetComponentsInChildren<Renderer>(true);
			foreach (Renderer val2 in componentsInChildren)
			{
				val2.enabled = false;
			}
			Rigidbody component3 = val.GetComponent<Rigidbody>();
			if ((Object)(object)component3 != (Object)null)
			{
				component3.isKinematic = true;
			}
			PossessionManager.disabledPlayerBehaviours.Clear();
			Behaviour[] componentsInChildren2 = val.GetComponentsInChildren<Behaviour>(true);
			foreach (Behaviour val3 in componentsInChildren2)
			{
				if (!((Object)(object)val3 == (Object)null))
				{
					string text = ((object)val3).GetType().Name.ToLower();
					if ((text.Contains("playernamechecker") || text.Contains("move") || text.Contains("controller") || text.Contains("look") || text.Contains("fall") || text.Contains("interact") || text.Contains("grab") || text.Contains("action")) && val3.enabled)
					{
						val3.enabled = false;
						PossessionManager.disabledPlayerBehaviours.Add(val3);
					}
				}
			}
		}
		Debug.Log((object)"[Possession] 成功夺舍 EnemyBeamer。");
	}

	public static void ExitPossession(EnemyBeamer beamer)
	{
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0159: Unknown result type (might be due to invalid IL or missing references)
		//IL_016b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0214: Unknown result type (might be due to invalid IL or missing references)
		//IL_0229: 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_01c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_011f: Unknown result type (might be due to invalid IL or missing references)
		if (!PossessionManager.IsPossessed)
		{
			return;
		}
		PossessionManager.isAttackingWindup = false;
		if ((Object)(object)PossessionManager.currentAudioListener != (Object)null)
		{
			((Component)PossessionManager.currentAudioListener).transform.SetParent(PossessionManager.originalAudioListenerParent);
			((Component)PossessionManager.currentAudioListener).transform.localPosition = PossessionManager.originalAudioListenerLocalPos;
			((Component)PossessionManager.currentAudioListener).transform.localRotation = PossessionManager.originalAudioListenerLocalRot;
			PossessionManager.currentAudioListener = null;
		}
		if ((Object)(object)beamer != (Object)null)
		{
			Rigidbody component = ((Component)beamer).GetComponent<Rigidbody>();
			if ((Object)(object)component != (Object)null)
			{
				component.isKinematic = false;
			}
			Component component2 = ((Component)beamer).GetComponent("EnemyHealthBar");
			if ((Object)(object)component2 != (Object)null)
			{
				((object)component2).GetType().GetProperty("enabled")?.SetValue(component2, true);
			}
			NavMeshAgent component3 = ((Component)beamer).GetComponent<NavMeshAgent>();
			if ((Object)(object)component3 != (Object)null)
			{
				NavMeshHit val = default(NavMeshHit);
				if (NavMesh.SamplePosition(((Component)beamer).transform.position, ref val, 5f, -1))
				{
					((Component)beamer).transform.position = ((NavMeshHit)(ref val)).position;
				}
				((Behaviour)component3).enabled = true;
			}
		}
		if ((Object)(object)PossessionManager.localPlayerObject != (Object)null)
		{
			GameObject localPlayerObject = PossessionManager.localPlayerObject;
			localPlayerObject.transform.position = PossessionManager.originalPlayerPos;
			localPlayerObject.transform.rotation = PossessionManager.originalPlayerRot;
			Renderer[] componentsInChildren = localPlayerObject.GetComponentsInChildren<Renderer>(true);
			foreach (Renderer val2 in componentsInChildren)
			{
				val2.enabled = true;
			}
			Rigidbody component4 = localPlayerObject.GetComponent<Rigidbody>();
			if ((Object)(object)component4 != (Object)null)
			{
				component4.isKinematic = false;
				component4.velocity = Vector3.zero;
				component4.angularVelocity = Vector3.zero;
			}
		}
		if ((Object)(object)PossessionManager.mainCamera != (Object)null)
		{
			((Component)PossessionManager.mainCamera).transform.SetParent(PossessionManager.originalCamParent);
			((Component)PossessionManager.mainCamera).transform.localPosition = PossessionManager.originalCamLocalPos;
			((Component)PossessionManager.mainCamera).transform.localRotation = PossessionManager.originalCamLocalRot;
			PossessionManager.mainCamera = null;
			PossessionManager.originalCamParent = null;
		}
		foreach (Behaviour disabledPlayerBehaviour in PossessionManager.disabledPlayerBehaviours)
		{
			if ((Object)(object)disabledPlayerBehaviour != (Object)null)
			{
				disabledPlayerBehaviour.enabled = true;
			}
		}
		PossessionManager.disabledPlayerBehaviours.Clear();
		PossessionManager.IsPossessed = false;
		PossessionManager.CurrentControlledAnimal = null;
		Debug.Log((object)"[Possession] secede EnemyBeamer。");
	}
}