Decompiled source of CZ457BoltActionRifle v1.0.1

CZ457BoltActionRifle.dll

Decompiled 13 hours ago
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using FistVR;
using HarmonyLib;
using OpenScripts2;
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]
public class SuppressorAddSound : Suppressor
{
	public bool PlaysTail = true;

	public AudioEvent AudEvent_SoundToPlay;

	public override void OnShot(FVRFireArm f, FVRTailSoundClass tailClass)
	{
		//IL_0072: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		FVRFirearmAudioSet audioClipSet = f.AudioClipSet;
		if (PlaysTail)
		{
			f.PlayShotTail((FVRTailSoundClass)11, (FVRSoundEnvironment)12, 1f);
			int playerIFF = GM.CurrentPlayerBody.GetPlayerIFF();
			GM.CurrentSceneSettings.OnPerceiveableSound(200f, 80f, ((Component)this).transform.position, playerIFF, GM.CurrentPlayerBody.PlayerEntities[0]);
		}
		else
		{
			f.PlayAudioAsHandling(AudEvent_SoundToPlay, ((Component)this).transform.position);
		}
		((MuzzleDevice)this).OnShot(f, tailClass);
	}

	public override void OnShot(AttachableFirearm f, FVRTailSoundClass tailClass)
	{
		//IL_0072: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		FVRFirearmAudioSet audioClipSet = f.AudioClipSet;
		if (PlaysTail)
		{
			f.PlayShotTail((FVRTailSoundClass)11, (FVRSoundEnvironment)12, 1f);
			int playerIFF = GM.CurrentPlayerBody.GetPlayerIFF();
			GM.CurrentSceneSettings.OnPerceiveableSound(200f, 80f, ((Component)this).transform.position, playerIFF, GM.CurrentPlayerBody.PlayerEntities[0]);
		}
		else
		{
			f.PlayAudioAsHandling(AudEvent_SoundToPlay, ((Component)this).transform.position);
		}
		((MuzzleDevice)this).OnShot(f, tailClass);
	}

	[ContextMenu("Copy Suppressor")]
	public void CopySuppressor()
	{
		Suppressor[] components = ((Component)this).GetComponents<Suppressor>();
		Suppressor val = components.Single((Suppressor c) => (Object)(object)c != (Object)(object)this);
		foreach (FVRFireArmAttachmentMount attachmentMount in ((FVRPhysicalObject)val).AttachmentMounts)
		{
			attachmentMount.MyObject = (FVRPhysicalObject)(object)this;
			attachmentMount.Parent = (FVRPhysicalObject)(object)this;
		}
		((FVRFireArmAttachment)val).AttachmentInterface.Attachment = (FVRFireArmAttachment)(object)this;
		((FVRFireArmAttachment)val).Sensor.Attachment = (FVRFireArmAttachment)(object)this;
		UniversalCopy.CopyComponent<Suppressor>((Component)(object)this, val);
	}
}
namespace Volks.CZ457BoltActionRifle;

[BepInPlugin("Volks.CZ457BoltActionRifle", "CZ457BoltActionRifle", "1.0.1")]
[BepInProcess("h3vr.exe")]
[Description("Built with MeatKit")]
[BepInDependency("h3vr.otherloader", "1.3.0")]
public class CZ457BoltActionRiflePlugin : 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.CZ457BoltActionRifle");
		OtherLoader.RegisterDirectLoad(BasePath, "Volks.CZ457BoltActionRifle", "", "", "cz457rifle", "");
	}
}
public class FVRTorch : FVRPhysicalObject
{
	public GameObject FireGO;

	public GameObject LinkedObject;

	public AudioSource fireAud;

	public float BurnDuration = 120f;

	public float DestructionDelay = 5f;

	private bool m_isBurning = false;

	private bool m_hasBeenLit = false;

	private bool m_canDestroy = false;

	private float m_burnTimer;

	private float m_unheldTimer;

	public override void Awake()
	{
		((FVRPhysicalObject)this).Awake();
		if ((Object)(object)FireGO != (Object)null)
		{
			fireAud = FireGO.GetComponent<AudioSource>();
			FireGO.SetActive(false);
		}
		if ((Object)(object)LinkedObject != (Object)null)
		{
			LinkedObject.SetActive(false);
		}
	}

	public override void FVRUpdate()
	{
		((FVRPhysicalObject)this).FVRUpdate();
		if (m_isBurning)
		{
			m_burnTimer -= Time.deltaTime;
			if ((Object)(object)fireAud != (Object)null)
			{
				fireAud.volume = Mathf.Lerp(fireAud.volume, 0f, Time.deltaTime / BurnDuration);
			}
			if (m_burnTimer <= 0f)
			{
				StopBurning();
			}
		}
		if (m_canDestroy && !((FVRInteractiveObject)this).IsHeld)
		{
			m_unheldTimer -= Time.deltaTime;
			if (m_unheldTimer <= 0f)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
		}
		else if (((FVRInteractiveObject)this).IsHeld)
		{
			m_unheldTimer = DestructionDelay;
		}
	}

	public void Ignite()
	{
		if (!m_hasBeenLit)
		{
			m_hasBeenLit = true;
			m_isBurning = true;
			m_burnTimer = BurnDuration;
			if ((Object)(object)FireGO != (Object)null)
			{
				FireGO.SetActive(true);
			}
			if ((Object)(object)fireAud != (Object)null)
			{
				fireAud.Play();
			}
			if ((Object)(object)LinkedObject != (Object)null)
			{
				LinkedObject.SetActive(true);
			}
			Debug.Log((object)"Torch has been ignited!");
		}
	}

	private void StopBurning()
	{
		m_isBurning = false;
		m_canDestroy = true;
		if ((Object)(object)FireGO != (Object)null)
		{
			FireGO.SetActive(false);
		}
		if ((Object)(object)fireAud != (Object)null)
		{
			fireAud.Stop();
		}
		Debug.Log((object)"Torch fire has died out.");
	}

	private void OnCollisionEnter(Collision col)
	{
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		//IL_005f: Expected O, but got Unknown
		//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_0099: 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_00aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_00af: Unknown result type (might be due to invalid IL or missing references)
		if (m_hasBeenLit && m_isBurning && (Object)(object)col.collider.attachedRigidbody != (Object)null)
		{
			IFVRDamageable val = ((Component)col.collider).GetComponent<IFVRDamageable>() ?? ((Component)col.collider.attachedRigidbody).GetComponent<IFVRDamageable>();
			if (val != null)
			{
				Damage val2 = new Damage();
				val2.Dam_Thermal = 50f;
				val2.Dam_TotalEnergetic = 50f;
				val2.point = ((ContactPoint)(ref col.contacts[0])).point;
				val2.hitNormal = ((ContactPoint)(ref col.contacts[0])).normal;
				val2.strikeDir = ((Component)this).transform.forward;
				val.Damage(val2);
			}
		}
	}
}
public class TorchTrigger : MonoBehaviour
{
	public FVRTorch Torch;

	public Collider collider;

	private void OnTriggerEnter(Collider col)
	{
		collider.enabled = false;
		((Component)collider).gameObject.layer = LayerMask.NameToLayer("NoCol");
		Torch.Ignite();
	}
}