Decompiled source of deadlockinrorain2 v0.1.0

plugins/ValorantRain.dll

Decompiled 7 hours ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using R2API;
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: AssemblyVersion("0.0.0.0")]
namespace ValorantRain;

public sealed class DeadlockFirstPerson : MonoBehaviour
{
	private static DeadlockFirstPerson instance;

	private CharacterBody currentBody;

	private CameraRigController currentRig;

	private Camera originalCamera;

	private Camera firstPersonCamera;

	private Transform cameraAnchor;

	private Renderer[] hiddenRenderers;

	private bool[] previousRendererStates;

	private GameObject viewmodel;

	private int vandalRounds = 25;

	private int killsSinceUltimate;

	private float nextVandalShot;

	private float reloadFinishedAt;

	private float sonicSensorReadyAt;

	private float barrierMeshReadyAt;

	private float gravNetReadyAt;

	private bool reloadMessageShown;

	private void Awake()
	{
		instance = this;
	}

	private void Update()
	{
		if (Object.op_Implicit((Object)(object)currentBody) && Object.op_Implicit((Object)(object)firstPersonCamera) && NetworkServer.active && !PauseManager.isPaused)
		{
			if (Input.GetMouseButton(0))
			{
				FireVandal();
			}
			if (Input.GetKeyDown((KeyCode)114))
			{
				StartReload();
			}
			if (Input.GetKeyDown((KeyCode)99))
			{
				PlaceSonicSensor();
			}
			if (Input.GetKeyDown((KeyCode)101))
			{
				PlaceBarrierMesh();
			}
			if (Input.GetKeyDown((KeyCode)113))
			{
				ThrowGravNet();
			}
			if (Input.GetKeyDown((KeyCode)120))
			{
				FireAnnihilation();
			}
		}
	}

	private void LateUpdate()
	{
		//IL_014d: Unknown result type (might be due to invalid IL or missing references)
		//IL_016e: Unknown result type (might be due to invalid IL or missing references)
		//IL_019b: Unknown result type (might be due to invalid IL or missing references)
		CharacterBody localBody = GetLocalBody();
		if (!Object.op_Implicit((Object)(object)localBody) || !((Object)localBody).name.Contains("DeadlockBody"))
		{
			if (Object.op_Implicit((Object)(object)currentBody))
			{
				Restore();
			}
			return;
		}
		NetworkUser val = ((NetworkUser.readOnlyLocalPlayersList.Count > 0) ? NetworkUser.readOnlyLocalPlayersList[0] : null);
		if (!Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)val.cameraRigController))
		{
			return;
		}
		if ((Object)(object)currentBody != (Object)(object)localBody || (Object)(object)currentRig != (Object)(object)val.cameraRigController || !Object.op_Implicit((Object)(object)firstPersonCamera))
		{
			Restore();
			Attach(localBody, val.cameraRigController);
			vandalRounds = 25;
			reloadFinishedAt = 0f;
			reloadMessageShown = false;
			sonicSensorReadyAt = 0f;
			barrierMeshReadyAt = 0f;
			gravNetReadyAt = 0f;
			killsSinceUltimate = 0;
		}
		if (Object.op_Implicit((Object)(object)firstPersonCamera) && Object.op_Implicit((Object)(object)cameraAnchor))
		{
			((Component)firstPersonCamera).transform.position = cameraAnchor.position;
			((Component)firstPersonCamera).transform.rotation = ((Component)currentRig).transform.rotation;
			if (Object.op_Implicit((Object)(object)localBody.inputBank))
			{
				localBody.inputBank.aimDirection = ((Component)firstPersonCamera).transform.forward;
			}
		}
	}

	private static CharacterBody GetLocalBody()
	{
		if (NetworkUser.readOnlyLocalPlayersList.Count == 0)
		{
			return null;
		}
		NetworkUser val = NetworkUser.readOnlyLocalPlayersList[0];
		return (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val.master)) ? val.master.GetBody() : null;
	}

	private void Attach(CharacterBody body, CameraRigController rig)
	{
		//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
		if (!Object.op_Implicit((Object)(object)rig.sceneCam))
		{
			return;
		}
		currentBody = body;
		currentRig = rig;
		originalCamera = rig.sceneCam;
		cameraAnchor = FindCameraAnchor(body);
		if (!Object.op_Implicit((Object)(object)cameraAnchor))
		{
			Plugin.Log.LogWarning((object)"Deadlock's model has no head/aim anchor; first-person camera was not attached.");
			currentBody = null;
			currentRig = null;
			return;
		}
		hiddenRenderers = (Renderer[])((Object.op_Implicit((Object)(object)((Component)body).GetComponent<ModelLocator>()) && Object.op_Implicit((Object)(object)((Component)body).GetComponent<ModelLocator>().modelTransform)) ? ((Array)((Component)((Component)body).GetComponent<ModelLocator>().modelTransform).GetComponentsInChildren<Renderer>(true)) : ((Array)new Renderer[0]));
		previousRendererStates = new bool[hiddenRenderers.Length];
		for (int i = 0; i < hiddenRenderers.Length; i++)
		{
			previousRendererStates[i] = Object.op_Implicit((Object)(object)hiddenRenderers[i]) && hiddenRenderers[i].enabled;
			if (Object.op_Implicit((Object)(object)hiddenRenderers[i]))
			{
				hiddenRenderers[i].enabled = false;
			}
		}
		GameObject val = Object.Instantiate<GameObject>(((Component)originalCamera).gameObject, cameraAnchor, false);
		((Object)val).name = "DeadlockFirstPersonCamera";
		firstPersonCamera = val.GetComponent<Camera>();
		if (!Object.op_Implicit((Object)(object)firstPersonCamera))
		{
			Object.Destroy((Object)(object)val);
			Restore();
			Plugin.Log.LogError((object)"RoR2's scene camera clone had no Camera component.");
			return;
		}
		AudioListener component = val.GetComponent<AudioListener>();
		if (Object.op_Implicit((Object)(object)component))
		{
			((Behaviour)component).enabled = false;
		}
		firstPersonCamera.nearClipPlane = 0.035f;
		firstPersonCamera.fieldOfView = 90f;
		((Component)firstPersonCamera).transform.localPosition = Vector3.zero;
		((Component)firstPersonCamera).transform.localRotation = Quaternion.identity;
		((Behaviour)originalCamera).enabled = false;
		rig.sceneCam = firstPersonCamera;
		BuildPlaceholderViewmodel(((Component)firstPersonCamera).transform);
		Plugin.Log.LogInfo((object)"Deadlock first-person camera attached. The visible rifle is a temporary proxy until VALORANT assets are verified.");
		Chat.AddMessage("Deadlock prototype: Vandal LMB / R reload; C Sonic Sensor; E Barrier Mesh; Q GravNet; X Annihilation after 8 kills.");
	}

	private static Transform FindCameraAnchor(CharacterBody body)
	{
		ModelLocator component = ((Component)body).GetComponent<ModelLocator>();
		Transform val = (Object.op_Implicit((Object)(object)component) ? component.modelTransform : null);
		if (Object.op_Implicit((Object)(object)val))
		{
			Transform[] componentsInChildren = ((Component)val).GetComponentsInChildren<Transform>(true);
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				string text = ((Object)componentsInChildren[i]).name.ToLowerInvariant();
				if (text == "head" || text.EndsWith("_head") || text.Contains("headhurtbox"))
				{
					return componentsInChildren[i];
				}
			}
		}
		return Object.op_Implicit((Object)(object)body.aimOriginTransform) ? body.aimOriginTransform : ((Component)body).transform;
	}

	private void BuildPlaceholderViewmodel(Transform parent)
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Expected O, but got Unknown
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0079: Unknown result type (might be due to invalid IL or missing references)
		//IL_0093: Unknown result type (might be due to invalid IL or missing references)
		//IL_00be: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0112: Unknown result type (might be due to invalid IL or missing references)
		//IL_0126: Unknown result type (might be due to invalid IL or missing references)
		//IL_013a: 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_017a: Unknown result type (might be due to invalid IL or missing references)
		//IL_017f: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0204: Unknown result type (might be due to invalid IL or missing references)
		//IL_0209: 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_0249: Unknown result type (might be due to invalid IL or missing references)
		//IL_025d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0289: Unknown result type (might be due to invalid IL or missing references)
		//IL_029d: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0313: Unknown result type (might be due to invalid IL or missing references)
		//IL_0327: Unknown result type (might be due to invalid IL or missing references)
		//IL_032c: Unknown result type (might be due to invalid IL or missing references)
		viewmodel = new GameObject("DeadlockVandalViewmodelProxy");
		viewmodel.transform.SetParent(parent, false);
		viewmodel.transform.localPosition = Vector3.zero;
		viewmodel.transform.localRotation = Quaternion.identity;
		Material material = MakeMaterial(new Color(0.055f, 0.07f, 0.08f));
		Material material2 = MakeMaterial(new Color(0.05f, 0.48f, 0.45f));
		Material material3 = MakeMaterial(new Color(0.68f, 0.48f, 0.19f));
		AddShape(viewmodel.transform, (PrimitiveType)1, "LeftSleeve", new Vector3(-0.27f, -0.43f, 0.35f), new Vector3(0.1f, 0.36f, 0.1f), new Vector3(24f, 0f, -48f), material2);
		AddShape(viewmodel.transform, (PrimitiveType)1, "RightSleeve", new Vector3(0.22f, -0.4f, 0.48f), new Vector3(0.1f, 0.38f, 0.1f), new Vector3(14f, 0f, 28f), material2);
		AddShape(viewmodel.transform, (PrimitiveType)3, "RifleStock", new Vector3(0.31f, -0.22f, 0.13f), new Vector3(0.13f, 0.12f, 0.3f), Vector3.zero, material);
		AddShape(viewmodel.transform, (PrimitiveType)3, "RifleReceiver", new Vector3(0.31f, -0.21f, 0.45f), new Vector3(0.17f, 0.12f, 0.39f), Vector3.zero, material);
		AddShape(viewmodel.transform, (PrimitiveType)3, "RifleHandguard", new Vector3(0.31f, -0.19f, 0.75f), new Vector3(0.13f, 0.11f, 0.26f), Vector3.zero, material2);
		AddShape(viewmodel.transform, (PrimitiveType)3, "RifleMagazine", new Vector3(0.31f, -0.33f, 0.48f), new Vector3(0.09f, 0.2f, 0.14f), new Vector3(8f, 0f, 0f), material);
		AddShape(viewmodel.transform, (PrimitiveType)3, "RifleBarrel", new Vector3(0.31f, -0.18f, 0.98f), new Vector3(0.055f, 0.055f, 0.3f), Vector3.zero, material3);
		AddShape(viewmodel.transform, (PrimitiveType)3, "RifleMuzzle", new Vector3(0.31f, -0.18f, 1.13f), new Vector3(0.09f, 0.075f, 0.08f), Vector3.zero, material);
		AddShape(viewmodel.transform, (PrimitiveType)3, "RifleSight", new Vector3(0.31f, -0.12f, 0.55f), new Vector3(0.08f, 0.055f, 0.13f), Vector3.zero, material3);
	}

	private static Material MakeMaterial(Color color)
	{
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Expected O, but got Unknown
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		Shader val = Shader.Find("Hopoo Games/Deferred/Standard") ?? Shader.Find("Standard");
		Material val2 = new Material(val);
		val2.color = color;
		return val2;
	}

	private static void AddShape(Transform parent, PrimitiveType type, string name, Vector3 position, Vector3 scale, Vector3 rotation, Material material)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = GameObject.CreatePrimitive(type);
		((Object)val).name = name;
		val.transform.SetParent(parent, false);
		val.transform.localPosition = position;
		val.transform.localRotation = Quaternion.Euler(rotation);
		val.transform.localScale = scale;
		Collider component = val.GetComponent<Collider>();
		if (Object.op_Implicit((Object)(object)component))
		{
			component.enabled = false;
		}
		Renderer component2 = val.GetComponent<Renderer>();
		if (Object.op_Implicit((Object)(object)component2))
		{
			component2.material = material;
		}
	}

	private void FireVandal()
	{
		//IL_0076: Unknown result type (might be due to invalid IL or missing references)
		//IL_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_008c: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: 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_00b9: 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_00cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00de: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f0: 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_0112: Unknown result type (might be due to invalid IL or missing references)
		//IL_011d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0128: 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_0155: Unknown result type (might be due to invalid IL or missing references)
		//IL_0161: Expected O, but got Unknown
		if (Time.time < nextVandalShot || Time.time < reloadFinishedAt)
		{
			if (Time.time < reloadFinishedAt && !reloadMessageShown)
			{
				Chat.AddMessage("Vandal reloading...");
				reloadMessageShown = true;
			}
			return;
		}
		if (vandalRounds <= 0)
		{
			StartReload();
			return;
		}
		BulletAttack val = new BulletAttack
		{
			owner = ((Component)currentBody).gameObject,
			weapon = ((Component)currentBody).gameObject,
			origin = ((Component)firstPersonCamera).transform.position + ((Component)firstPersonCamera).transform.forward * 0.45f,
			aimVector = ((Component)firstPersonCamera).transform.forward,
			bulletCount = 1u,
			damage = currentBody.damage * 0.78f,
			force = 35f,
			procCoefficient = 0.5f,
			radius = 0.06f,
			maxDistance = 50f,
			isCrit = Util.CheckRoll(currentBody.crit, currentBody.master),
			muzzleName = "Muzzle"
		};
		val.Fire();
		vandalRounds--;
		nextVandalShot = Time.time + 4f / 39f;
	}

	private void StartReload()
	{
		if (vandalRounds < 25 && !(Time.time < reloadFinishedAt))
		{
			reloadFinishedAt = Time.time + 2.5f;
			nextVandalShot = reloadFinishedAt;
			((MonoBehaviour)this).Invoke("FinishReload", 2.5f);
			reloadMessageShown = false;
		}
	}

	private void FinishReload()
	{
		vandalRounds = 25;
		reloadFinishedAt = 0f;
		reloadMessageShown = false;
	}

	private void PlaceSonicSensor()
	{
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_004f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		//IL_005f: 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)
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_009a: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
		if (!(Time.time < sonicSensorReadyAt))
		{
			sonicSensorReadyAt = Time.time + 14f;
			Vector3 targetPoint = GetTargetPoint(18f);
			GameObject val = GameObject.CreatePrimitive((PrimitiveType)0);
			((Object)val).name = "DeadlockSonicSensor";
			val.transform.position = targetPoint + Vector3.up * 0.18f;
			val.transform.localScale = Vector3.one * 0.35f;
			val.GetComponent<Renderer>().material = MakeMaterial(new Color(0.08f, 0.9f, 0.83f));
			Collider component = val.GetComponent<Collider>();
			if (Object.op_Implicit((Object)(object)component))
			{
				component.enabled = false;
			}
			SonicSensorTrap sonicSensorTrap = val.AddComponent<SonicSensorTrap>();
			sonicSensorTrap.Configure(currentBody.teamComponent.teamIndex, ((Component)currentBody).gameObject, 18f, 12f, 2.5f);
			Chat.AddMessage("Sonic Sensor deployed.");
		}
	}

	private void PlaceBarrierMesh()
	{
		//IL_0035: 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_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_004d: Unknown result type (might be due to invalid IL or missing references)
		//IL_007e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0083: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: Unknown result type (might be due to invalid IL or missing references)
		//IL_008e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0093: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0072: Unknown result type (might be due to invalid IL or missing references)
		//IL_010d: Unknown result type (might be due to invalid IL or missing references)
		//IL_010e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0111: Unknown result type (might be due to invalid IL or missing references)
		//IL_0116: Unknown result type (might be due to invalid IL or missing references)
		//IL_0128: Unknown result type (might be due to invalid IL or missing references)
		//IL_0129: 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)
		if (!(Time.time < barrierMeshReadyAt))
		{
			barrierMeshReadyAt = Time.time + 28f;
			Vector3 val = Vector3.ProjectOnPlane(((Component)firstPersonCamera).transform.forward, Vector3.up);
			Vector3 val2 = ((Vector3)(ref val)).normalized;
			if (((Vector3)(ref val2)).sqrMagnitude < 0.01f)
			{
				val2 = ((Component)currentBody).transform.forward;
			}
			Vector3 val3 = ((Component)currentBody).transform.position + val2 * 5.5f + Vector3.up * 1.6f;
			val = Vector3.Cross(Vector3.up, val2);
			Vector3 normalized = ((Vector3)(ref val)).normalized;
			Material material = MakeMaterial(new Color(0.06f, 0.55f, 0.54f));
			for (int i = 0; i < 4; i++)
			{
				float num = ((float)i - 1.5f) * 2.5f;
				GameObject val4 = GameObject.CreatePrimitive((PrimitiveType)3);
				((Object)val4).name = "DeadlockBarrierMeshPanel";
				val4.transform.position = val3 + normalized * num;
				val4.transform.rotation = Quaternion.LookRotation(val2);
				val4.transform.localScale = new Vector3(2.55f, 3.2f, 0.28f);
				val4.GetComponent<Renderer>().material = material;
				Object.Destroy((Object)(object)val4, 12f);
			}
			Chat.AddMessage("Barrier Mesh deployed for 12 seconds.");
		}
	}

	private void ThrowGravNet()
	{
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_010d: Unknown result type (might be due to invalid IL or missing references)
		//IL_011a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0124: Unknown result type (might be due to invalid IL or missing references)
		//IL_0149: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: Unknown result type (might be due to invalid IL or missing references)
		//IL_0092: Unknown result type (might be due to invalid IL or missing references)
		if (Time.time < gravNetReadyAt)
		{
			return;
		}
		gravNetReadyAt = Time.time + 18f;
		Vector3 targetPoint = GetTargetPoint(35f);
		Collider[] array = Physics.OverlapSphere(targetPoint, 10f);
		for (int i = 0; i < array.Length; i++)
		{
			CharacterBody componentInParent = ((Component)array[i]).GetComponentInParent<CharacterBody>();
			if (Object.op_Implicit((Object)(object)componentInParent) && Object.op_Implicit((Object)(object)componentInParent.healthComponent) && Object.op_Implicit((Object)(object)componentInParent.teamComponent) && componentInParent.teamComponent.teamIndex != currentBody.teamComponent.teamIndex)
			{
				TimedMoveSpeedSlow timedMoveSpeedSlow = ((Component)componentInParent).GetComponent<TimedMoveSpeedSlow>();
				if (!Object.op_Implicit((Object)(object)timedMoveSpeedSlow))
				{
					timedMoveSpeedSlow = ((Component)componentInParent).gameObject.AddComponent<TimedMoveSpeedSlow>();
				}
				timedMoveSpeedSlow.Apply(4f, 0.35f);
			}
		}
		GameObject val = GameObject.CreatePrimitive((PrimitiveType)0);
		((Object)val).name = "DeadlockGravNetEffect";
		val.transform.position = targetPoint;
		val.transform.localScale = Vector3.one * 20f;
		val.GetComponent<Renderer>().material = MakeMaterial(new Color(0.45f, 0.22f, 0.75f, 0.3f));
		Collider component = val.GetComponent<Collider>();
		if (Object.op_Implicit((Object)(object)component))
		{
			component.enabled = false;
		}
		Object.Destroy((Object)(object)val, 0.5f);
		Chat.AddMessage("GravNet deployed.");
	}

	private void FireAnnihilation()
	{
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_0053: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c6: 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_0139: 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_015b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0163: Unknown result type (might be due to invalid IL or missing references)
		//IL_016e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0171: 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_017c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0181: Unknown result type (might be due to invalid IL or missing references)
		//IL_0186: Unknown result type (might be due to invalid IL or missing references)
		//IL_0188: Unknown result type (might be due to invalid IL or missing references)
		//IL_018d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0192: Unknown result type (might be due to invalid IL or missing references)
		//IL_019b: Expected O, but got Unknown
		if (killsSinceUltimate < 8)
		{
			Chat.AddMessage("Annihilation needs 8 kills: " + killsSinceUltimate + "/8.");
			return;
		}
		Ray val = default(Ray);
		((Ray)(ref val))..ctor(((Component)firstPersonCamera).transform.position, ((Component)firstPersonCamera).transform.forward);
		RaycastHit val2 = default(RaycastHit);
		if (!Physics.Raycast(val, ref val2, 35f))
		{
			Chat.AddMessage("Annihilation found no target.");
			return;
		}
		HurtBox componentInParent = ((Component)((RaycastHit)(ref val2)).collider).GetComponentInParent<HurtBox>();
		CharacterBody val3 = (Object.op_Implicit((Object)(object)componentInParent) ? componentInParent.healthComponent.body : null);
		if (Object.op_Implicit((Object)(object)val3) && val3.teamComponent.teamIndex != currentBody.teamComponent.teamIndex)
		{
			HealthComponent healthComponent = val3.healthComponent;
			if (Object.op_Implicit((Object)(object)healthComponent))
			{
				float damage = (val3.isBoss ? Mathf.Min(healthComponent.combinedHealth, Mathf.Max(250f, healthComponent.fullCombinedHealth * 0.35f)) : (healthComponent.combinedHealth + 1000f));
				DamageInfo val4 = new DamageInfo
				{
					attacker = ((Component)currentBody).gameObject,
					inflictor = ((Component)currentBody).gameObject,
					damage = damage,
					procCoefficient = 0f,
					position = ((RaycastHit)(ref val2)).point,
					force = Vector3.zero,
					damageType = DamageTypeCombo.op_Implicit((DamageType)0),
					inflictedHurtbox = componentInParent
				};
				healthComponent.TakeDamage(val4);
				killsSinceUltimate = 0;
				Chat.AddMessage("Annihilation fired.");
			}
		}
	}

	private Vector3 GetTargetPoint(float maxDistance)
	{
		//IL_000e: 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_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_004d: Unknown result type (might be due to invalid IL or missing references)
		Ray val = default(Ray);
		((Ray)(ref val))..ctor(((Component)firstPersonCamera).transform.position, ((Component)firstPersonCamera).transform.forward);
		RaycastHit val2 = default(RaycastHit);
		return Physics.Raycast(val, ref val2, maxDistance) ? ((RaycastHit)(ref val2)).point : ((Ray)(ref val)).GetPoint(maxDistance * 0.6f);
	}

	internal static void ReportKill(DamageReport report)
	{
		if (Object.op_Implicit((Object)(object)instance) && Object.op_Implicit((Object)(object)instance.currentBody) && report != null && !((Object)(object)report.attackerBody != (Object)(object)instance.currentBody))
		{
			instance.killsSinceUltimate++;
			if (instance.killsSinceUltimate >= 8)
			{
				Chat.AddMessage("Annihilation ready. Press X.");
			}
		}
	}

	private void Restore()
	{
		if (Object.op_Implicit((Object)(object)currentRig) && Object.op_Implicit((Object)(object)originalCamera))
		{
			currentRig.sceneCam = originalCamera;
			((Behaviour)originalCamera).enabled = true;
		}
		if (hiddenRenderers != null && previousRendererStates != null)
		{
			for (int i = 0; i < hiddenRenderers.Length && i < previousRendererStates.Length; i++)
			{
				if (Object.op_Implicit((Object)(object)hiddenRenderers[i]))
				{
					hiddenRenderers[i].enabled = previousRendererStates[i];
				}
			}
		}
		if (Object.op_Implicit((Object)(object)firstPersonCamera))
		{
			Object.Destroy((Object)(object)((Component)firstPersonCamera).gameObject);
		}
		if (Object.op_Implicit((Object)(object)viewmodel))
		{
			Object.Destroy((Object)(object)viewmodel);
		}
		currentBody = null;
		currentRig = null;
		originalCamera = null;
		firstPersonCamera = null;
		cameraAnchor = null;
		hiddenRenderers = null;
		previousRendererStates = null;
		viewmodel = null;
	}

	private void OnDestroy()
	{
		Restore();
	}

	private void OnGUI()
	{
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: 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_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: 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_0141: Unknown result type (might be due to invalid IL or missing references)
		if (Object.op_Implicit((Object)(object)currentBody) && Object.op_Implicit((Object)(object)firstPersonCamera))
		{
			Color color = GUI.color;
			GUI.color = new Color(0.65f, 1f, 0.95f, 0.95f);
			GUI.Label(new Rect(22f, 20f, 340f, 24f), "DEADLOCK  |  VANDAL  " + ((Time.time < reloadFinishedAt) ? "RELOADING" : (vandalRounds + " / 25")));
			GUI.Label(new Rect(22f, 44f, 420f, 24f), "C Sensor " + CooldownText(sonicSensorReadyAt) + "   E Barrier " + CooldownText(barrierMeshReadyAt));
			GUI.Label(new Rect(22f, 68f, 420f, 24f), "Q GravNet " + CooldownText(gravNetReadyAt) + "   X Annihilation " + killsSinceUltimate + " / 8");
			GUI.color = color;
		}
	}

	private static string CooldownText(float readyAt)
	{
		float num = readyAt - Time.time;
		return (num > 0f) ? (num.ToString("0.0") + "s") : "READY";
	}
}
public sealed class SonicSensorTrap : MonoBehaviour
{
	private TeamIndex ownerTeam;

	private GameObject owner;

	private float triggerRadius;

	private float concussRadius;

	private float concussDuration;

	private float expiresAt;

	private float nextCheck;

	public void Configure(TeamIndex team, GameObject ownerObject, float trigger, float radius, float duration)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0003: Unknown result type (might be due to invalid IL or missing references)
		ownerTeam = team;
		owner = ownerObject;
		triggerRadius = trigger;
		concussRadius = radius;
		concussDuration = duration;
		expiresAt = Time.time + 60f;
	}

	private void Update()
	{
		//IL_0056: 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_00a6: 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_0138: Unknown result type (might be due to invalid IL or missing references)
		//IL_013e: Unknown result type (might be due to invalid IL or missing references)
		if (Time.time >= expiresAt)
		{
			Object.Destroy((Object)(object)((Component)this).gameObject);
		}
		else
		{
			if (Time.time < nextCheck)
			{
				return;
			}
			nextCheck = Time.time + 0.15f;
			Collider[] array = Physics.OverlapSphere(((Component)this).transform.position, triggerRadius);
			bool flag = false;
			for (int i = 0; i < array.Length; i++)
			{
				CharacterBody componentInParent = ((Component)array[i]).GetComponentInParent<CharacterBody>();
				if (Object.op_Implicit((Object)(object)componentInParent) && Object.op_Implicit((Object)(object)componentInParent.healthComponent) && Object.op_Implicit((Object)(object)componentInParent.teamComponent) && componentInParent.teamComponent.teamIndex != ownerTeam)
				{
					flag = true;
					break;
				}
			}
			if (!flag)
			{
				return;
			}
			Collider[] array2 = Physics.OverlapSphere(((Component)this).transform.position, concussRadius);
			for (int j = 0; j < array2.Length; j++)
			{
				CharacterBody componentInParent2 = ((Component)array2[j]).GetComponentInParent<CharacterBody>();
				if (Object.op_Implicit((Object)(object)componentInParent2) && Object.op_Implicit((Object)(object)componentInParent2.healthComponent) && Object.op_Implicit((Object)(object)componentInParent2.teamComponent) && componentInParent2.teamComponent.teamIndex != ownerTeam)
				{
					SetStateOnHurt.SetStunOnObject(((Component)componentInParent2).gameObject, concussDuration);
				}
			}
			Object.Destroy((Object)(object)((Component)this).gameObject);
		}
	}
}
public sealed class TimedMoveSpeedSlow : MonoBehaviour
{
	private CharacterBody body;

	private float originalBaseSpeed;

	private float expiresAt;

	private float multiplier;

	private bool initialized;

	public void Apply(float duration, float speedMultiplier)
	{
		if (!initialized)
		{
			body = ((Component)this).GetComponent<CharacterBody>();
			if (!Object.op_Implicit((Object)(object)body))
			{
				Object.Destroy((Object)(object)this);
				return;
			}
			originalBaseSpeed = body.baseMoveSpeed;
			initialized = true;
		}
		multiplier = Mathf.Clamp(speedMultiplier, 0.05f, 1f);
		expiresAt = Mathf.Max(expiresAt, Time.time + duration);
		body.baseMoveSpeed = originalBaseSpeed * multiplier;
	}

	private void Update()
	{
		if (!(Time.time < expiresAt))
		{
			if (Object.op_Implicit((Object)(object)body))
			{
				body.baseMoveSpeed = originalBaseSpeed;
			}
			Object.Destroy((Object)(object)this);
		}
	}
}
[BepInPlugin("com.codex.valorant.rain", "VALORANT: Risk of Rain", "0.1.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public sealed class Plugin : BaseUnityPlugin
{
	public const string PluginGuid = "com.codex.valorant.rain";

	public const string PluginName = "VALORANT: Risk of Rain";

	public const string PluginVersion = "0.1.0";

	internal static ManualLogSource Log;

	private void Awake()
	{
		Log = ((BaseUnityPlugin)this).Logger;
		GlobalEventManager.onCharacterDeathServer += OnCharacterDeath;
		RegisterDeadlockPrototype();
		((Component)this).gameObject.AddComponent<DeadlockFirstPerson>();
	}

	private void OnDestroy()
	{
		GlobalEventManager.onCharacterDeathServer -= OnCharacterDeath;
	}

	private static void OnCharacterDeath(DamageReport report)
	{
		DeadlockFirstPerson.ReportKill(report);
	}

	private static void RegisterDeadlockPrototype()
	{
		//IL_0195: Unknown result type (might be due to invalid IL or missing references)
		//IL_019a: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = Resources.Load<GameObject>("Prefabs/CharacterBodies/CommandoBody");
		GameObject val2 = Resources.Load<GameObject>("Prefabs/CharacterDisplays/CommandoDisplay");
		if (!Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)val2))
		{
			Log.LogError((object)"Could not load the Commando body/display template; Deadlock was not registered.");
			return;
		}
		GameObject val3 = PrefabAPI.InstantiateClone(val, "DeadlockBody", true);
		CharacterBody component = val3.GetComponent<CharacterBody>();
		if (Object.op_Implicit((Object)(object)component))
		{
			component.baseMaxHealth = 110f;
			component.levelMaxHealth = 33f;
			component.baseRegen = 1f;
			component.levelRegen = 0.2f;
			component.baseMoveSpeed = 7f;
			component.baseDamage = 12f;
			component.baseAttackSpeed = 1f;
			component.baseJumpCount = 1;
		}
		SkillLocator component2 = val3.GetComponent<SkillLocator>();
		if (Object.op_Implicit((Object)(object)component2))
		{
			if (Object.op_Implicit((Object)(object)component2.primary))
			{
				((Behaviour)component2.primary).enabled = false;
			}
			if (Object.op_Implicit((Object)(object)component2.secondary))
			{
				((Behaviour)component2.secondary).enabled = false;
			}
			if (Object.op_Implicit((Object)(object)component2.utility))
			{
				((Behaviour)component2.utility).enabled = false;
			}
			if (Object.op_Implicit((Object)(object)component2.special))
			{
				((Behaviour)component2.special).enabled = false;
			}
		}
		ContentAddition.AddBody(val3);
		GameObject displayPrefab = PrefabAPI.InstantiateClone(val2, "DeadlockDisplay", false);
		SurvivorDef val4 = ScriptableObject.CreateInstance<SurvivorDef>();
		val4.bodyPrefab = val3;
		val4.displayPrefab = displayPrefab;
		val4.primaryColor = new Color(0.04f, 0.58f, 0.55f);
		val4.desiredSortPosition = 100f;
		val4.cachedName = "Deadlock";
		val4.displayNameToken = "VALORANT_RAIN_DEADLOCK_NAME";
		val4.descriptionToken = "VALORANT_RAIN_DEADLOCK_DESC";
		LanguageAPI.Add(val4.displayNameToken, "Deadlock");
		LanguageAPI.Add(val4.descriptionToken, "A VALORANT agent adapted to a solo Risk of Rain run. First-person Vandal with Sonic Sensor, Barrier Mesh, GravNet, and Annihilation.");
		ContentAddition.AddSurvivorDef(val4);
		Log.LogWarning((object)"Deadlock prototype registered on the Commando template. VALORANT model and skill assets are not yet integrated.");
	}
}