Decompiled source of UnderbarrelFlamethrower v1.0.0

UnderbarrelFlamethrower.dll

Decompiled a month ago
using System;
using System.Collections;
using System.Collections.Generic;
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 OpenScripts2;
using OtherLoader;
using UnityEngine;
using VolksScripts;

[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.UnderbarrelFlamethrower
{
	[BepInPlugin("Volks.UnderbarrelFlamethrower", "UnderbarrelFlamethrower", "1.0.0")]
	[BepInProcess("h3vr.exe")]
	[Description("Built with MeatKit")]
	[BepInDependency("h3vr.otherloader", "1.3.0")]
	public class UnderbarrelFlamethrowerPlugin : 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.UnderbarrelFlamethrower");
			OtherLoader.RegisterDirectLoad(BasePath, "Volks.UnderbarrelFlamethrower", "", "", "underbarrelflamethrower", "");
		}
	}
}
namespace VolksScripts
{
	public class PocketWatch : FVRPhysicalObject
	{
		[SerializeField]
		private GameObject secondsHandle;

		[SerializeField]
		private GameObject minutesHandle;

		[SerializeField]
		private GameObject hoursHandle;

		private float secondsMultiplier = 1f;

		public Transform WatchLid;

		public float openRotationX = 90f;

		public float openRotationY = 0f;

		public float openRotationZ = 0f;

		public float closeRotationX = 0f;

		public float closeRotationY = 0f;

		public float closeRotationZ = 0f;

		public float rotationSpeed = 5f;

		private bool isOpen = false;

		[SerializeField]
		private AudioSource openCloseAudioSource;

		[SerializeField]
		private AudioClip openClip;

		[SerializeField]
		private AudioClip closeClip;

		[SerializeField]
		private AudioSource tickingAudioSource;

		[SerializeField]
		private AudioClip tickingClip;

		private Coroutine tickingCoroutine;

		private bool isTouching = false;

		private Vector2 initTouch = Vector2.zero;

		private Vector2 LastTouchPoint = Vector2.zero;

		private void Update()
		{
			//IL_005c: 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_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			DateTime now = DateTime.Now;
			int second = now.Second;
			int minute = now.Minute;
			int hour = now.Hour;
			float num = second * 6;
			float num2 = (float)(minute * 6) + (float)second * 0.1f;
			float num3 = (float)(hour * 30) + (float)minute * 0.5f;
			secondsHandle.transform.localRotation = Quaternion.Euler(0f - num, 0f, 0f);
			minutesHandle.transform.localRotation = Quaternion.Euler(0f - num2, 0f, 0f);
			hoursHandle.transform.localRotation = Quaternion.Euler(0f - num3, 0f, 0f);
			Quaternion val = ((!isOpen) ? Quaternion.Euler(closeRotationX, closeRotationY, closeRotationZ) : Quaternion.Euler(openRotationX, openRotationY, openRotationZ));
			WatchLid.localRotation = Quaternion.Lerp(WatchLid.localRotation, val, Time.deltaTime * rotationSpeed);
		}

		public void ToggleLid()
		{
			isOpen = !isOpen;
			if (isOpen)
			{
				openCloseAudioSource.PlayOneShot(openClip);
				if (tickingCoroutine == null)
				{
					tickingCoroutine = ((MonoBehaviour)this).StartCoroutine(PlayTickingSound());
				}
				return;
			}
			openCloseAudioSource.PlayOneShot(closeClip);
			if (tickingCoroutine != null)
			{
				((MonoBehaviour)this).StopCoroutine(tickingCoroutine);
				tickingCoroutine = null;
			}
			tickingAudioSource.Stop();
		}

		private IEnumerator PlayTickingSound()
		{
			while (true)
			{
				tickingAudioSource.PlayOneShot(tickingClip);
				yield return (object)new WaitForSeconds(1f);
			}
		}

		public override void UpdateInteraction(FVRViveHand hand)
		{
			//IL_0108: 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_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: 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_00bb: 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_00be: 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_0087: 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_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			((FVRPhysicalObject)this).UpdateInteraction(hand);
			if (hand.IsInStreamlinedMode)
			{
				if (hand.Input.BYButtonDown || hand.Input.AXButtonDown)
				{
					ToggleLid();
				}
				return;
			}
			if (hand.Input.TouchpadTouched && !isTouching && hand.Input.TouchpadAxes != Vector2.zero)
			{
				isTouching = true;
				initTouch = hand.Input.TouchpadAxes;
			}
			if (hand.Input.TouchpadTouchUp && isTouching)
			{
				isTouching = false;
				Vector2 lastTouchPoint = LastTouchPoint;
				float y = (lastTouchPoint - initTouch).y;
				if (y > 0.5f || y < -0.5f)
				{
					ToggleLid();
				}
				initTouch = Vector2.zero;
				lastTouchPoint = Vector2.zero;
			}
			LastTouchPoint = hand.Input.TouchpadAxes;
		}
	}
}
namespace GravyScripts.Components
{
	public class AttachableFlammenwerfer : AttachableFirearm
	{
		[Header("FlameThrower Params")]
		public FlameThrowerValve Valve;

		public bool UsesValve = true;

		public MF2_FlamethrowerValve MF2Valve;

		public bool UsesMF2Valve;

		[Header("Trigger Config")]
		public Transform Trigger;

		public float TriggerFiringThreshold = 0.8f;

		public float Trigger_ForwardValue;

		public float Trigger_RearwardValue;

		public InterpStyle TriggerInterpStyle = (InterpStyle)1;

		private float m_triggerFloat;

		[Header("Special Audio Config")]
		public AudioEvent AudEvent_Ignite;

		public AudioEvent AudEvent_Extinguish;

		public AudioSource AudSource_FireLoop;

		private float m_triggerHasBeenHeldFor;

		private bool m_hasFiredStartSound;

		private bool m_isFiring;

		public ParticleSystem FireParticles;

		public Vector2 FireWidthRange;

		public Vector2 SpeedRangeMin;

		public Vector2 SpeedRangeMax;

		public Vector2 SizeRangeMin;

		public Vector2 SizeRangeMax;

		public Vector2 AudioPitchRange = new Vector2(1.5f, 0.5f);

		public float ParticleVolume = 40f;

		public bool UsesPilotLightSystem;

		public bool UsesAirBlastSystem;

		[Header("PilotLight")]
		public Transform PilotLight;

		private bool m_isPilotLightOn;

		public AudioEvent AudEvent_PilotOn;

		[Header("Airblast")]
		public bool UsesAirBlast;

		public Transform AirBlastCenter;

		public GameObject AirBlastGo;

		private float m_airBurstRecovery;

		public override void Awake()
		{
			((AttachableFirearm)this).Awake();
			if (UsesPilotLightSystem)
			{
				((Component)PilotLight).gameObject.SetActive(false);
			}
		}

		private float GetVLerp()
		{
			if (UsesValve)
			{
				return Valve.ValvePos;
			}
			if (UsesMF2Valve)
			{
				return MF2Valve.Lerp;
			}
			return 0.5f;
		}

		public override void Update()
		{
			//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_008d: 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)
			((AttachableFirearm)this).Update();
			UpdateFire();
			if (!UsesPilotLightSystem)
			{
				return;
			}
			if ((Object)(object)base.Magazine != (Object)null && base.Magazine.FuelAmountLeft > 0f)
			{
				if (!m_isPilotLightOn)
				{
					PilotOn();
				}
			}
			else if (m_isPilotLightOn)
			{
				PilotOff();
			}
			if (m_isPilotLightOn)
			{
				PilotLight.localScale = Vector3.one + Random.onUnitSphere * 0.05f;
			}
		}

		private void PilotOn()
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			m_isPilotLightOn = true;
			if (AudEvent_PilotOn != null && (Object)(object)((AttachableFirearm)this).GetMuzzle() != (Object)null)
			{
				SM.PlayCoreSound((FVRPooledAudioType)10, AudEvent_PilotOn, ((AttachableFirearm)this).GetMuzzle().position);
			}
			((Component)PilotLight).gameObject.SetActive(true);
		}

		private void PilotOff()
		{
			m_isPilotLightOn = false;
			((Component)PilotLight).gameObject.SetActive(false);
		}

		private void AirBlast()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Object.Instantiate<GameObject>(AirBlastGo, AirBlastCenter.position, AirBlastCenter.rotation);
			val.GetComponent<Explosion>().IFF = GM.CurrentPlayerBody.GetPlayerIFF();
			val.GetComponent<ExplosionSound>().IFF = GM.CurrentPlayerBody.GetPlayerIFF();
		}

		public void UpdateFire()
		{
			//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_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: 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_0055: 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_005d: 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)
			//IL_00b8: 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_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			EmissionModule emission = FireParticles.emission;
			MinMaxCurve rateOverTime = ((EmissionModule)(ref emission)).rateOverTime;
			if (m_isFiring)
			{
				((MinMaxCurve)(ref rateOverTime)).mode = (ParticleSystemCurveMode)0;
				((MinMaxCurve)(ref rateOverTime)).constantMax = ParticleVolume;
				((MinMaxCurve)(ref rateOverTime)).constantMin = ParticleVolume;
				float vLerp = GetVLerp();
				MainModule main = FireParticles.main;
				MinMaxCurve startSpeed = ((MainModule)(ref main)).startSpeed;
				((MinMaxCurve)(ref startSpeed)).mode = (ParticleSystemCurveMode)3;
				((MinMaxCurve)(ref startSpeed)).constantMax = Mathf.Lerp(SpeedRangeMax.x, SpeedRangeMax.y, vLerp);
				((MinMaxCurve)(ref startSpeed)).constantMin = Mathf.Lerp(SpeedRangeMin.x, SpeedRangeMin.y, vLerp);
				((MainModule)(ref main)).startSpeed = startSpeed;
				MinMaxCurve startSize = ((MainModule)(ref main)).startSize;
				((MinMaxCurve)(ref startSize)).mode = (ParticleSystemCurveMode)3;
				((MinMaxCurve)(ref startSize)).constantMax = Mathf.Lerp(SizeRangeMax.x, SizeRangeMax.y, vLerp);
				((MinMaxCurve)(ref startSize)).constantMin = Mathf.Lerp(SizeRangeMin.x, SizeRangeMin.y, vLerp);
				((MainModule)(ref main)).startSize = startSize;
				ShapeModule shape = FireParticles.shape;
				((ShapeModule)(ref shape)).angle = Mathf.Lerp(FireWidthRange.x, FireWidthRange.y, vLerp);
			}
			else
			{
				((MinMaxCurve)(ref rateOverTime)).mode = (ParticleSystemCurveMode)0;
				((MinMaxCurve)(ref rateOverTime)).constantMax = 0f;
				((MinMaxCurve)(ref rateOverTime)).constantMin = 0f;
			}
			((EmissionModule)(ref emission)).rateOverTime = rateOverTime;
		}

		private bool HasFuel()
		{
			return !((Object)(object)base.Magazine == (Object)null) && base.Magazine.FuelAmountLeft > 0f;
		}

		private void StopFiring()
		{
			if (m_isFiring && (Object)(object)AudSource_FireLoop != (Object)null)
			{
				AudSource_FireLoop.Stop();
				AudSource_FireLoop.volume = 0f;
			}
			m_isFiring = false;
			m_hasFiredStartSound = false;
		}

		public override void ProcessInput(FVRViveHand hand, bool fromInterface, FVRInteractiveObject o)
		{
			//IL_0307: Unknown result type (might be due to invalid IL or missing references)
			//IL_034a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0350: Invalid comparison between Unknown and I4
			//IL_0339: Unknown result type (might be due to invalid IL or missing references)
			//IL_037d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			((AttachableFirearm)this).ProcessInput(hand, fromInterface, o);
			if ((Object)(object)o == (Object)null || (Object)(object)hand == (Object)null)
			{
				return;
			}
			if (o.IsHeld)
			{
				if (o.m_hasTriggeredUpSinceBegin)
				{
					m_triggerFloat = hand.Input.TriggerFloat;
				}
				else
				{
					m_triggerFloat = 0f;
				}
				if (UsesAirBlast && m_airBurstRecovery <= 0f && HasFuel() && ((hand.IsInStreamlinedMode && hand.Input.BYButtonDown) || (!hand.IsInStreamlinedMode && hand.Input.TouchpadDown)))
				{
					m_airBurstRecovery = 1f;
					AirBlast();
					if ((Object)(object)base.Magazine != (Object)null)
					{
						base.Magazine.DrainFuel(5f);
						if (!m_hasFiredStartSound)
						{
							m_hasFiredStartSound = true;
							if (AudEvent_Ignite != null && (Object)(object)((AttachableFirearm)this).GetMuzzle() != (Object)null)
							{
								SM.PlayCoreSound((FVRPooledAudioType)10, AudEvent_Ignite, ((AttachableFirearm)this).GetMuzzle().position);
							}
						}
					}
				}
				if (m_airBurstRecovery > 0f)
				{
					m_airBurstRecovery -= Time.deltaTime;
				}
				if (m_triggerFloat > 0.2f && HasFuel() && m_airBurstRecovery <= 0f)
				{
					if (m_triggerHasBeenHeldFor < 2f)
					{
						m_triggerHasBeenHeldFor += Time.deltaTime;
					}
					m_isFiring = true;
					if (!m_hasFiredStartSound)
					{
						m_hasFiredStartSound = true;
						if (AudEvent_Ignite != null && (Object)(object)((AttachableFirearm)this).GetMuzzle() != (Object)null)
						{
							SM.PlayCoreSound((FVRPooledAudioType)10, AudEvent_Ignite, ((AttachableFirearm)this).GetMuzzle().position);
						}
					}
					if ((Object)(object)AudSource_FireLoop != (Object)null)
					{
						float volume = Mathf.Clamp(m_triggerHasBeenHeldFor * 2f, 0f, 0.4f);
						AudSource_FireLoop.volume = volume;
						float vLerp = GetVLerp();
						AudSource_FireLoop.pitch = Mathf.Lerp(AudioPitchRange.x, AudioPitchRange.y, vLerp);
						if (!AudSource_FireLoop.isPlaying)
						{
							AudSource_FireLoop.Play();
						}
					}
					if ((Object)(object)base.Magazine != (Object)null)
					{
						base.Magazine.DrainFuel(Time.deltaTime);
					}
				}
				else
				{
					m_triggerHasBeenHeldFor = 0f;
					StopFiring();
				}
			}
			else
			{
				m_triggerFloat = 0f;
			}
			if (m_triggerFloat <= 0f)
			{
				StopFiring();
			}
			if ((Object)(object)Trigger != (Object)null)
			{
				if ((int)TriggerInterpStyle == 0)
				{
					Trigger.localPosition = new Vector3(0f, 0f, Mathf.Lerp(Trigger_ForwardValue, Trigger_RearwardValue, m_triggerFloat));
				}
				else if ((int)TriggerInterpStyle == 1)
				{
					Trigger.localEulerAngles = new Vector3(Mathf.Lerp(Trigger_ForwardValue, Trigger_RearwardValue, m_triggerFloat), 0f, 0f);
				}
			}
		}
	}
}
public class UBFlameTankRelease : FVRInteractiveObject
{
	public AttachableFirearm AFireArm;

	public override bool IsInteractable()
	{
		return (Object)(object)AFireArm != (Object)null && (Object)(object)AFireArm.Magazine != (Object)null;
	}

	public override void BeginInteraction(FVRViveHand hand)
	{
		if (!((Object)(object)AFireArm == (Object)null) && (Object)(object)AFireArm.Magazine != (Object)null)
		{
			FVRFireArmMagazine magazine = AFireArm.Magazine;
			AFireArm.EjectMag(false);
			hand.ForceSetInteractable((FVRInteractiveObject)(object)magazine);
			((FVRInteractiveObject)magazine).BeginInteraction(hand);
		}
	}
}
namespace VolksScripts
{
	public class CigarCase : FVRPhysicalObject
	{
		private bool isOpen = false;

		private bool isTouching = false;

		private Vector2 initTouch = Vector2.zero;

		private Vector2 LastTouchPoint = Vector2.zero;

		public Transform CaseLid;

		public float openRotationX = 90f;

		public float openRotationY = 0f;

		public float openRotationZ = 0f;

		public float closeRotationX = 0f;

		public float closeRotationY = 0f;

		public float closeRotationZ = 0f;

		public float rotationSpeed = 5f;

		public AudioSource audioSource;

		public AudioClip openSound;

		public AudioClip closeSound;

		public GameObject objectToToggle;

		public List<Transform> Dings;

		public int m_numDings;

		public CigarCaseTrigger cigarCaseTrigger;

		private Quaternion targetRotation;

		public override void Start()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			CaseLid.localRotation = Quaternion.Euler(closeRotationX, closeRotationY, closeRotationZ);
			targetRotation = CaseLid.localRotation;
		}

		private void Update()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: 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)
			CaseLid.localRotation = Quaternion.Lerp(CaseLid.localRotation, targetRotation, Time.deltaTime * rotationSpeed);
		}

		public override void UpdateInteraction(FVRViveHand hand)
		{
			//IL_0108: 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_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: 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_00bb: 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_00be: 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_0087: 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_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			((FVRPhysicalObject)this).UpdateInteraction(hand);
			if (hand.IsInStreamlinedMode)
			{
				if (hand.Input.BYButtonDown || hand.Input.AXButtonDown)
				{
					ToggleLid();
				}
				return;
			}
			if (hand.Input.TouchpadTouched && !isTouching && hand.Input.TouchpadAxes != Vector2.zero)
			{
				isTouching = true;
				initTouch = hand.Input.TouchpadAxes;
			}
			if (hand.Input.TouchpadTouchUp && isTouching)
			{
				isTouching = false;
				Vector2 lastTouchPoint = LastTouchPoint;
				float y = (lastTouchPoint - initTouch).y;
				if (y > 0.5f || y < -0.5f)
				{
					ToggleLid();
				}
				initTouch = Vector2.zero;
				lastTouchPoint = Vector2.zero;
			}
			LastTouchPoint = hand.Input.TouchpadAxes;
		}

		private void ToggleLid()
		{
			//IL_004a: 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)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			isOpen = !isOpen;
			targetRotation = ((!isOpen) ? Quaternion.Euler(closeRotationX, closeRotationY, closeRotationZ) : Quaternion.Euler(openRotationX, openRotationY, openRotationZ));
			if (isOpen)
			{
				if ((Object)(object)audioSource != (Object)null && (Object)(object)openSound != (Object)null)
				{
					audioSource.PlayOneShot(openSound);
				}
				if ((Object)(object)objectToToggle != (Object)null)
				{
					objectToToggle.SetActive(true);
				}
				Open();
			}
			else
			{
				if ((Object)(object)audioSource != (Object)null && (Object)(object)closeSound != (Object)null)
				{
					audioSource.PlayOneShot(closeSound);
				}
				if ((Object)(object)objectToToggle != (Object)null)
				{
					objectToToggle.SetActive(false);
				}
				Close();
			}
		}

		public bool IsOpen()
		{
			return isOpen;
		}

		public bool HasADing()
		{
			return m_numDings > 0;
		}

		public override void FVRUpdate()
		{
			((FVRPhysicalObject)this).FVRUpdate();
		}

		public void Open()
		{
			isOpen = true;
			if ((Object)(object)audioSource != (Object)null && (Object)(object)openSound != (Object)null)
			{
				audioSource.PlayOneShot(openSound);
			}
			UpdateDingDisplay();
		}

		public void Close()
		{
			isOpen = false;
			if ((Object)(object)audioSource != (Object)null && (Object)(object)closeSound != (Object)null)
			{
				audioSource.PlayOneShot(closeSound);
			}
			UpdateDingDisplay();
		}

		public void RemoveDing()
		{
			if (m_numDings > 0)
			{
				m_numDings--;
				UpdateDingDisplay();
			}
		}

		private void UpdateDingDisplay()
		{
			for (int i = 0; i < Dings.Count; i++)
			{
				if (i < m_numDings)
				{
					((Component)Dings[i]).gameObject.SetActive(true);
				}
				else
				{
					((Component)Dings[i]).gameObject.SetActive(false);
				}
			}
		}
	}
}
public class CigarCaseTrigger : FVRInteractiveObject
{
	public CigarCase cigarCase;

	public GameObject cigarPrefab;

	public override bool IsInteractable()
	{
		return cigarCase.HasADing() && ((FVRInteractiveObject)this).IsInteractable();
	}

	public override void BeginInteraction(FVRViveHand hand)
	{
		((FVRInteractiveObject)this).SimpleInteraction(hand);
	}

	public override void SimpleInteraction(FVRViveHand hand)
	{
		//IL_0030: 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)
		((FVRInteractiveObject)this).SimpleInteraction(hand);
		if (cigarCase.IsOpen())
		{
			cigarCase.RemoveDing();
			GameObject val = Object.Instantiate<GameObject>(cigarPrefab, ((HandInput)(ref hand.Input)).Pos, ((HandInput)(ref hand.Input)).Rot);
			FVRPhysicalObject component = val.GetComponent<FVRPhysicalObject>();
			hand.ForceSetInteractable((FVRInteractiveObject)(object)component);
			((FVRInteractiveObject)component).BeginInteraction(hand);
		}
		else
		{
			cigarCase.Open();
		}
	}
}
public class FVRCigar : QBArmorHelmet
{
	public GameObject FireGO;

	public GameObject LinkedObject;

	public AudioSource fireAud;

	public float BurnDuration = 120f;

	public float DestructionDelay = 10f;

	public MeshFilter cigarMeshFilter;

	public MeshRenderer cigarRenderer;

	public Mesh burntMesh;

	public Material burntMaterial;

	public float damageInterval = 1f;

	private float damageTimer = 0f;

	private bool m_isBurning = false;

	private bool m_hasBeenLit = false;

	private float m_burnTimer;

	private bool m_isEquipped = false;

	private float m_unequippedTimer = 0f;

	private bool m_hasBurntOut = false;

	private FVRPlayerBody playerBody;

	public float damageAmount = 1f;

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

	public override void FVRUpdate()
	{
		((QBArmorPiece)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_isEquipped && (Object)(object)playerBody != (Object)null)
			{
				damageTimer += Time.deltaTime;
				if (damageTimer >= damageInterval)
				{
					playerBody.RegisterPlayerHit(1f, false, playerBody.GetPlayerIFF());
					damageTimer = 0f;
				}
			}
		}
		if (m_hasBurntOut && !m_isEquipped && !((FVRInteractiveObject)this).IsHeld)
		{
			m_unequippedTimer += Time.deltaTime;
			if (m_unequippedTimer >= DestructionDelay)
			{
				Debug.Log((object)"Cigar destroyed after being unequipped and left alone.");
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
		}
		else
		{
			m_unequippedTimer = 0f;
		}
	}

	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);
			}
		}
	}

	private void StopBurning()
	{
		m_isBurning = false;
		m_hasBurntOut = true;
		if ((Object)(object)FireGO != (Object)null)
		{
			FireGO.SetActive(false);
		}
		if ((Object)(object)fireAud != (Object)null)
		{
			fireAud.Stop();
		}
		if ((Object)(object)cigarMeshFilter != (Object)null && (Object)(object)burntMesh != (Object)null)
		{
			cigarMeshFilter.mesh = burntMesh;
		}
		if ((Object)(object)cigarRenderer != (Object)null && (Object)(object)burntMaterial != (Object)null)
		{
			((Renderer)cigarRenderer).material = burntMaterial;
		}
		Debug.Log((object)"Cigar has burnt out.");
	}

	public override void SetQuickBeltSlot(FVRQuickBeltSlot slot)
	{
		((QBArmorHelmet)this).SetQuickBeltSlot(slot);
		if ((Object)(object)slot != (Object)null)
		{
			m_isEquipped = true;
			m_unequippedTimer = 0f;
		}
		else
		{
			m_isEquipped = false;
		}
	}
}
namespace VolksScripts
{
	public class MatchStick : FVRPhysicalObject
	{
		private bool m_isLit;

		private bool m_hasBurntOut;

		private bool isTouching;

		private Vector2 initTouch = Vector2.zero;

		private Vector2 LastTouchPoint = Vector2.zero;

		public Transform Flame;

		private float m_flame_min = 0.1f;

		private float m_flame_max = 0.85f;

		private float m_flame_cur = 0.1f;

		public AudioSource Audio_Lighter;

		public AudioClip AudioClip_Strike;

		public AudioClip AudioClip_Extinguish;

		public Transform[] FlameJoints;

		public float[] FlameWeights;

		public ParticleSystem Sparks;

		public AlloyAreaLight AlloyLight;

		public LayerMask LM_FireDamage;

		private RaycastHit m_hit;

		public float BurnDuration = 10f;

		private float burnTimer = 0f;

		public float DestructionDelay = 5f;

		private float destructionTimer = 0f;

		public MeshFilter matchstickMeshFilter;

		public MeshRenderer matchstickRenderer;

		public Mesh burntMesh;

		public Material burntMaterial;

		public override void UpdateInteraction(FVRViveHand hand)
		{
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: 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_00c7: 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)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: 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)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			((FVRPhysicalObject)this).UpdateInteraction(hand);
			if (hand.IsInStreamlinedMode)
			{
				if ((hand.Input.BYButtonDown || hand.Input.AXButtonDown) && !m_hasBurntOut)
				{
					Light();
				}
				return;
			}
			if (hand.Input.TouchpadTouched && !isTouching && hand.Input.TouchpadAxes != Vector2.zero)
			{
				isTouching = true;
				initTouch = hand.Input.TouchpadAxes;
			}
			if (hand.Input.TouchpadTouchUp && isTouching)
			{
				isTouching = false;
				Vector2 lastTouchPoint = LastTouchPoint;
				float y = (lastTouchPoint - initTouch).y;
				if ((y > 0.5f || y < -0.5f) && !m_hasBurntOut)
				{
					Light();
				}
				initTouch = Vector2.zero;
				lastTouchPoint = Vector2.zero;
			}
			LastTouchPoint = hand.Input.TouchpadAxes;
		}

		public override void FVRUpdate()
		{
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: 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_0129: 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_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: 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_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: 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_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ff: 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_0206: Unknown result type (might be due to invalid IL or missing references)
			//IL_0208: Unknown result type (might be due to invalid IL or missing references)
			//IL_020a: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0211: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_029f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a6: Expected O, but got Unknown
			//IL_02a9: 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_02d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f7: Unknown result type (might be due to invalid IL or missing references)
			((FVRPhysicalObject)this).FVRUpdate();
			if (m_isLit)
			{
				burnTimer += Time.deltaTime;
				if (burnTimer >= BurnDuration)
				{
					BurnOut();
				}
				m_flame_cur = Mathf.Lerp(m_flame_cur, m_flame_max, Time.deltaTime * 2f);
				AlloyLight.Intensity = m_flame_cur * (Mathf.PerlinNoise(Time.time * 10f, ((Component)AlloyLight).transform.position.y) * 0.05f + 0.5f);
			}
			else
			{
				m_flame_cur = Mathf.Lerp(m_flame_cur, m_flame_min, Time.deltaTime * 7f);
			}
			Flame.localScale = new Vector3(m_flame_cur, m_flame_cur, m_flame_cur);
			Quaternion val = Quaternion.Inverse(((Component)this).transform.rotation);
			val = Quaternion.Slerp(val, Random.rotation, Mathf.PerlinNoise(Time.time * 5f, 0f) * 0.3f);
			for (int i = 0; i < FlameJoints.Length; i++)
			{
				Quaternion val2 = Quaternion.Slerp(Quaternion.identity, val, FlameWeights[i] + Random.Range(-0.05f, 0.05f));
				FlameJoints[i].localScale = new Vector3(Random.Range(0.95f, 1.05f), Random.Range(0.98f, 1.02f), Random.Range(0.95f, 1.05f));
				FlameJoints[i].localRotation = Quaternion.Slerp(FlameJoints[i].localRotation, val2, Time.deltaTime * 6f);
			}
			if (m_isLit)
			{
				Vector3 position = FlameJoints[0].position;
				Vector3 position2 = FlameJoints[FlameJoints.Length - 1].position;
				Vector3 val3 = position2 - position;
				if (Physics.Raycast(position, ((Vector3)(ref val3)).normalized, ref m_hit, ((Vector3)(ref val3)).magnitude, LayerMask.op_Implicit(LM_FireDamage), (QueryTriggerInteraction)2))
				{
					IFVRDamageable component = ((Component)((RaycastHit)(ref m_hit)).collider).gameObject.GetComponent<IFVRDamageable>();
					if (component == null && (Object)(object)((RaycastHit)(ref m_hit)).collider.attachedRigidbody != (Object)null)
					{
						component = ((Component)((RaycastHit)(ref m_hit)).collider.attachedRigidbody).gameObject.GetComponent<IFVRDamageable>();
					}
					if (component != null)
					{
						IFVRDamageable obj = component;
						Damage val4 = new Damage();
						val4.Class = (DamageClass)2;
						val4.Dam_Thermal = 50f;
						val4.Dam_TotalEnergetic = 50f;
						val4.point = ((RaycastHit)(ref m_hit)).point;
						val4.hitNormal = ((RaycastHit)(ref m_hit)).normal;
						val4.strikeDir = ((Component)this).transform.forward;
						obj.Damage(val4);
					}
					FVRIgnitable component2 = ((Component)((Component)((RaycastHit)(ref m_hit)).collider).transform).gameObject.GetComponent<FVRIgnitable>();
					if ((Object)(object)component2 == (Object)null && (Object)(object)((RaycastHit)(ref m_hit)).collider.attachedRigidbody != (Object)null)
					{
						((Component)((RaycastHit)(ref m_hit)).collider.attachedRigidbody).gameObject.GetComponent<FVRIgnitable>();
					}
					if ((Object)(object)component2 != (Object)null)
					{
						FXM.Ignite(component2, 0.1f);
					}
				}
			}
			if (m_hasBurntOut && !((FVRInteractiveObject)this).IsHeld)
			{
				destructionTimer += Time.deltaTime;
				if (destructionTimer >= DestructionDelay)
				{
					Object.Destroy((Object)(object)((Component)this).gameObject);
				}
			}
		}

		public override void EndInteraction(FVRViveHand hand)
		{
			((FVRPhysicalObject)this).EndInteraction(hand);
			if (m_hasBurntOut)
			{
				destructionTimer = 0f;
			}
		}

		private void Light()
		{
			if (!m_isLit && !m_hasBurntOut)
			{
				Sparks.Emit(Random.Range(2, 3));
				m_isLit = true;
				burnTimer = 0f;
				Audio_Lighter.PlayOneShot(AudioClip_Strike, 0.3f);
				((Component)Flame).gameObject.SetActive(true);
			}
		}

		private void BurnOut()
		{
			m_isLit = false;
			m_hasBurntOut = true;
			Audio_Lighter.PlayOneShot(AudioClip_Extinguish, 0.3f);
			((Component)Flame).gameObject.SetActive(false);
			if ((Object)(object)matchstickMeshFilter != (Object)null && (Object)(object)burntMesh != (Object)null)
			{
				matchstickMeshFilter.mesh = burntMesh;
			}
			if ((Object)(object)matchstickRenderer != (Object)null && (Object)(object)burntMaterial != (Object)null)
			{
				((Renderer)matchstickRenderer).material = burntMaterial;
			}
			destructionTimer = 0f;
		}
	}
}
public class TorchTrigger : MonoBehaviour
{
	public FVRCigar Torch;

	public Collider collider;

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