Decompiled source of VolksFurniturePack v3.0.0

VolksFurniturePack.dll

Decompiled 3 days 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 OtherLoader;
using UnityEngine;
using UnityEngine.UI;

[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 DigitalClock : MonoBehaviour
{
	private Text textClock;

	private void Awake()
	{
		textClock = ((Component)this).GetComponent<Text>();
	}

	private void Update()
	{
		DateTime now = DateTime.Now;
		string text = LeadingZero(now.Hour);
		string text2 = LeadingZero(now.Minute);
		string text3 = LeadingZero(now.Second);
		textClock.text = text + ":" + text2 + ":" + text3;
	}

	private string LeadingZero(int n)
	{
		return n.ToString().PadLeft(2, '0');
	}
}
public class RandomPhoneRing : MonoBehaviour
{
	[Header("Phone Behavior")]
	public AudioSource audioSource;

	public List<AudioClip> ringClips;

	public List<AudioClip> speechClips;

	public AudioClip phoneTone;

	public float minRingInterval = 5f;

	public float maxRingInterval = 15f;

	public float ringDuration = 10f;

	public float speechStartDelay = 2f;

	public float ringCooldown = 20f;

	[Header("Blinking Light")]
	public GameObject lightObject;

	public float lightBlinkInterval = 0.5f;

	private bool isRinging = false;

	private bool isHeld = false;

	private bool isCooldown = false;

	private Coroutine ringCoroutine;

	private Coroutine blinkCoroutine;

	private void Start()
	{
		StartRandomRinging();
	}

	private void Update()
	{
		FVRPhysicalObject component = ((Component)this).GetComponent<FVRPhysicalObject>();
		if (!((Object)(object)component != (Object)null))
		{
			return;
		}
		bool flag = ((FVRInteractiveObject)component).IsHeld;
		if (flag != isHeld)
		{
			isHeld = flag;
			if (isHeld)
			{
				HandlePickup();
			}
			else
			{
				HandlePutDown();
			}
		}
	}

	private void HandlePickup()
	{
		if (isRinging)
		{
			StopRinging();
			((MonoBehaviour)this).StartCoroutine(PlaySpeechAfterDelay(speechStartDelay));
		}
		else if (!isRinging && (Object)(object)phoneTone != (Object)null)
		{
			PlayPhoneTone();
		}
	}

	private void HandlePutDown()
	{
		StopAudio();
		if (!isCooldown)
		{
			((MonoBehaviour)this).StartCoroutine(CooldownBeforeNextRing());
		}
	}

	private void StartRandomRinging()
	{
		if (ringCoroutine == null)
		{
			ringCoroutine = ((MonoBehaviour)this).StartCoroutine(RandomRingRoutine());
		}
	}

	private void StopRinging()
	{
		if (audioSource.isPlaying && isRinging)
		{
			audioSource.Stop();
		}
		if (blinkCoroutine != null)
		{
			((MonoBehaviour)this).StopCoroutine(blinkCoroutine);
			blinkCoroutine = null;
		}
		if ((Object)(object)lightObject != (Object)null)
		{
			lightObject.SetActive(false);
		}
		isRinging = false;
	}

	private IEnumerator RandomRingRoutine()
	{
		while (true)
		{
			float interval = Random.Range(minRingInterval, maxRingInterval);
			yield return (object)new WaitForSeconds(interval);
			if (!isHeld && !isCooldown && ringClips.Count > 0)
			{
				isRinging = true;
				audioSource.clip = ringClips[Random.Range(0, ringClips.Count)];
				audioSource.loop = true;
				audioSource.Play();
				if (blinkCoroutine == null)
				{
					blinkCoroutine = ((MonoBehaviour)this).StartCoroutine(BlinkLightRoutine());
				}
				yield return (object)new WaitForSeconds(ringDuration);
				if (isRinging)
				{
					StopRinging();
				}
				if (!isHeld)
				{
					((MonoBehaviour)this).StartCoroutine(CooldownBeforeNextRing());
				}
			}
		}
	}

	private IEnumerator BlinkLightRoutine()
	{
		while (true)
		{
			if ((Object)(object)lightObject != (Object)null)
			{
				lightObject.SetActive(!lightObject.activeSelf);
			}
			yield return (object)new WaitForSeconds(lightBlinkInterval);
		}
	}

	private IEnumerator PlaySpeechAfterDelay(float delay)
	{
		yield return (object)new WaitForSeconds(delay);
		if (isHeld && speechClips.Count > 0)
		{
			audioSource.loop = false;
			audioSource.clip = speechClips[Random.Range(0, speechClips.Count)];
			audioSource.Play();
		}
		((MonoBehaviour)this).StartCoroutine(CooldownBeforeNextRing());
	}

	private void PlayPhoneTone()
	{
		if ((Object)(object)phoneTone != (Object)null && !audioSource.isPlaying)
		{
			audioSource.loop = true;
			audioSource.clip = phoneTone;
			audioSource.Play();
		}
	}

	private void StopAudio()
	{
		if (audioSource.isPlaying)
		{
			audioSource.Stop();
		}
	}

	private IEnumerator CooldownBeforeNextRing()
	{
		isCooldown = true;
		yield return (object)new WaitForSeconds(ringCooldown);
		isCooldown = false;
		StartRandomRinging();
	}
}
public class PlateRackToggle : SteelPopTarget
{
	public List<HingeJoint> hingeJointsToToggle;

	public override void Start()
	{
		((SteelPopTarget)this).Start();
		bool useSpring = base.SpringSwitchJoint.useSpring;
		UpdateHingeJointsSpring(useSpring);
	}

	private void Update()
	{
		bool useSpring = base.SpringSwitchJoint.useSpring;
		UpdateHingeJointsSpring(useSpring);
	}

	private void UpdateHingeJointsSpring(bool springEnabled)
	{
		foreach (HingeJoint item in hingeJointsToToggle)
		{
			item.useSpring = springEnabled;
		}
	}
}
namespace Volks.VolksFurniturePack;

[BepInPlugin("Volks.VolksFurniturePack", "VolksFurniturePack", "3.0.0")]
[BepInProcess("h3vr.exe")]
[Description("Built with MeatKit")]
[BepInDependency("h3vr.otherloader", "1.3.0")]
public class VolksFurniturePackPlugin : 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.VolksFurniturePack");
		OtherLoader.RegisterDirectLoad(BasePath, "Volks.VolksFurniturePack", "", "", "furnituresvpack", "");
	}
}
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 float timeBeforeEnableStick = 0.1f;

	private bool canStick = false;

	private Transform fakeParent;

	private Vector3 pos;

	private Vector3 fw;

	private Vector3 up;

	public override void FVRUpdate()
	{
		if (base.m_isLeverReleased && !canStick)
		{
			timeBeforeEnableStick -= Time.deltaTime;
			if (timeBeforeEnableStick <= 0f)
			{
				canStick = true;
			}
		}
		((PinnedGrenade)this).FVRUpdate();
	}

	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_0053: 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_0090: Unknown result type (might be due to invalid IL or missing references)
		//IL_0095: 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_00b1: 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_00d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
		((PinnedGrenade)this).OnCollisionEnter(collision);
		if (!((FVRInteractiveObject)this).IsHeld && canStick && (Object)(object)fakeParent == (Object)null)
		{
			fakeParent = collision.gameObject.transform;
			((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();
			}
		}
	}

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