Decompiled source of RKG3AntiTank v1.0.0

RKG3AntiTank.dll

Decompiled a day ago
using System.Collections;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using FistVR;
using HarmonyLib;
using OtherLoader;
using UnityEngine;

[assembly: Debuggable(DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
namespace Volks.RKG3AntiTank;

[BepInPlugin("Volks.RKG3AntiTank", "RKG3AntiTank", "1.0.0")]
[BepInProcess("h3vr.exe")]
[Description("Built with MeatKit")]
[BepInDependency("h3vr.otherloader", "1.3.0")]
public class RKG3AntiTankPlugin : BaseUnityPlugin
{
	private static readonly string BasePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

	internal static ManualLogSource Logger;

	private void Awake()
	{
		Logger = ((BaseUnityPlugin)this).Logger;
		LoadAssets();
	}

	private void LoadAssets()
	{
		Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "Volks.RKG3AntiTank");
		OtherLoader.RegisterDirectLoad(BasePath, "Volks.RKG3AntiTank", "", "", "rkg3grenade", "");
	}
}
public class FlipGrip : FVRAlternateGrip
{
	private float curXRot;

	private float m_curFlipLerp;

	private float m_tarFlipLerp;

	private float m_lastFlipLerp;

	public float XRotUp;

	public float XRotDown;

	public bool IsUp { get; private set; }

	public override void Awake()
	{
		((FVRAlternateGrip)this).Awake();
		if (IsUp)
		{
			curXRot = XRotUp;
			m_curFlipLerp = 1f;
			m_tarFlipLerp = 1f;
			m_lastFlipLerp = 1f;
		}
		else
		{
			curXRot = XRotDown;
			m_curFlipLerp = 0f;
			m_tarFlipLerp = 0f;
			m_lastFlipLerp = 0f;
		}
	}

	public override void UpdateInteraction(FVRViveHand hand)
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: 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_0068: Unknown result type (might be due to invalid IL or missing references)
		Vector2 touchpadAxes = hand.Input.TouchpadAxes;
		if (hand.IsInStreamlinedMode)
		{
			if (hand.Input.BYButtonDown)
			{
				IsUp = !IsUp;
				Flip();
			}
		}
		else if (hand.Input.TouchpadDown && ((Vector2)(ref touchpadAxes)).magnitude > 0.25f && Vector2.Angle(touchpadAxes, Vector2.up) <= 45f)
		{
			Flip();
		}
		((FVRAlternateGrip)this).UpdateInteraction(hand);
	}

	private void Flip()
	{
		if (IsUp)
		{
			curXRot = XRotUp;
			m_tarFlipLerp = 1f;
		}
		else
		{
			curXRot = XRotDown;
			m_tarFlipLerp = 0f;
		}
	}
}
public class GripRotation : FVRAlternateGrip
{
	[Header("Grip Rotation")]
	public Vector3 rotationDirection = Vector3.up;
}
public enum E_InteractionType
{
	None = -1,
	Holding,
	Touchpad,
	TouchpadUp,
	TouchpadDown,
	TouchpadLeft,
	TouchpadRight,
	AXButton,
	BYButton,
	Trigger,
	Simple,
	TriggerTouched,
	GripPressed
}
public class Safety_RPG : SimpleLauncher
{
	private int m_fireSelectorMode;

	public int FireSelectorModeIndex => m_fireSelectorMode;

	private void Start()
	{
	}

	private void Update()
	{
	}
}
public class RKGChute : PinnedGrenade
{
	public GameObject objectToEnable;

	public float delay = 1f;

	public float dragFactor = 5f;

	public Vector3 targetDirection = Vector3.right;

	public float rotationSpeed = 5f;

	private bool isTimerStarted = false;

	private Rigidbody rb;

	private void Start()
	{
		rb = ((Component)this).GetComponent<Rigidbody>();
	}

	public override void FVRUpdate()
	{
		((PinnedGrenade)this).FVRUpdate();
		if (base.m_isPinPulled && base.m_isLeverReleased && !((FVRInteractiveObject)this).IsHeld && !isTimerStarted)
		{
			((MonoBehaviour)this).StartCoroutine(EnableObjectAfterDelay());
		}
		if ((Object)(object)objectToEnable != (Object)null && objectToEnable.activeSelf)
		{
			AlignToWorldDirection();
		}
	}

	private IEnumerator EnableObjectAfterDelay()
	{
		isTimerStarted = true;
		yield return (object)new WaitForSeconds(delay);
		if ((Object)(object)objectToEnable != (Object)null)
		{
			objectToEnable.SetActive(true);
			Debug.Log((object)"Parachute deployed.");
		}
	}

	private void AlignToWorldDirection()
	{
		//IL_0023: 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_004a: 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_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: 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_007a: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)rb == (Object)null))
		{
			rb.velocity *= 1f - Time.deltaTime * dragFactor;
			Vector3 normalized = ((Vector3)(ref targetDirection)).normalized;
			Quaternion val = Quaternion.LookRotation(normalized, Vector3.up);
			((Component)this).transform.rotation = Quaternion.Slerp(((Component)this).transform.rotation, val, rotationSpeed * Time.deltaTime);
		}
	}
}
public class DM34Destroy : MonoBehaviour
{
	public FVRPhysicalObject triggerDestroy;

	public FVRFireArmChamber chamber;

	private bool isTimerStarted;

	public float timeBeforedestruction;

	private float timer = 1f;

	private void FixedUpdate()
	{
		if (!chamber.IsFull && !isTimerStarted)
		{
			isTimerStarted = true;
			timer = timeBeforedestruction;
		}
		if (((FVRInteractiveObject)triggerDestroy).IsHeld)
		{
			timer = timeBeforedestruction;
		}
		if (isTimerStarted)
		{
			timer -= Time.fixedDeltaTime;
		}
		if (timer <= 0f)
		{
			Object.Destroy((Object)(object)((Component)triggerDestroy).gameObject);
		}
	}
}
public class EnableEngine : MonoBehaviour
{
	public FVRFireArmChamber chamber;

	public GameObject objectToEnable;

	private void FixedUpdate()
	{
		if (!chamber.IsFull)
		{
			objectToEnable.SetActive(true);
		}
	}
}
public class Semtex : PinnedGrenade
{
	[Header("Semtex Values")]
	public bool isSticky;

	public LayerMask stickyMask;

	[Header("Semtex Extras (Leave Empty If Not Needed)")]
	[Tooltip("If not null, will play audio clip placed inside of source. Used for a stick sound if you want.")]
	public AudioSource StickSource;

	public override void OnCollisionEnter(Collision collision)
	{
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		if (collision.gameObject.layer == LayerMask.op_Implicit(stickyMask) && !((FVRInteractiveObject)this).IsHeld)
		{
			((Component)this).transform.parent = collision.transform;
			((Component)this).GetComponent<Rigidbody>().isKinematic = true;
			if ((Object)(object)StickSource != (Object)null)
			{
				StickSource.Play();
			}
		}
		((PinnedGrenade)this).OnCollisionEnter(collision);
	}
}
public class Semtex_Updated : PinnedGrenade
{
	[Header("Semtex Values")]
	public bool isSticky;

	public LayerMask stickyMask;

	[Header("Semtex Extras (Leave Empty If Not Needed)")]
	[Tooltip("If not null, will play audio clip placed inside of source. Used for a stick sound if you want.")]
	public AudioSource StickSource;

	private Transform fakeParent;

	private Vector3 pos;

	private Vector3 fw;

	private Vector3 up;

	private void FixedUpdate()
	{
		//IL_001f: 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_0029: 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_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: 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_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_0059: 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_0066: 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)
		if ((Object)(object)fakeParent != (Object)null)
		{
			Vector3 position = ((Component)fakeParent).transform.TransformPoint(pos);
			Vector3 val = ((Component)fakeParent).transform.TransformDirection(fw);
			Vector3 val2 = ((Component)fakeParent).transform.TransformDirection(up);
			Quaternion rotation = Quaternion.LookRotation(val, val2);
			((Component)this).transform.position = position;
			((Component)this).transform.rotation = rotation;
		}
	}

	public override void OnCollisionEnter(Collision collision)
	{
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: 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_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: 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_0087: Unknown result type (might be due to invalid IL or missing references)
		//IL_009e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: 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_00bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
		if (((1 << collision.gameObject.layer) & LayerMask.op_Implicit(stickyMask)) != 0 && !((FVRInteractiveObject)this).IsHeld)
		{
			((Component)this).transform.position = ((ContactPoint)(ref collision.contacts[0])).point;
			((Component)this).transform.rotation = Quaternion.LookRotation(((ContactPoint)(ref collision.contacts[0])).normal);
			pos = ((Component)fakeParent).transform.InverseTransformPoint(((Component)this).transform.position);
			fw = ((Component)fakeParent).transform.InverseTransformDirection(((Component)this).transform.forward);
			up = ((Component)fakeParent).transform.InverseTransformDirection(((Component)this).transform.up);
			((Component)this).GetComponent<Rigidbody>().isKinematic = true;
			if ((Object)(object)StickSource != (Object)null)
			{
				StickSource.Play();
			}
		}
		((PinnedGrenade)this).OnCollisionEnter(collision);
	}

	public override void BeginInteraction(FVRViveHand hand)
	{
		((PinnedGrenade)this).BeginInteraction(hand);
		fakeParent = null;
	}
}