Decompiled source of Budget Arms Slaught O Matic v1.1.2

Budget_Arms_Slaught_O_Matic.dll

Decompiled 3 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
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.Configuration;
using FistVR;
using HarmonyLib;
using OtherLoader;
using ProBuilder2.Common;
using ProBuilder2.MeshOperations;
using Sodalite.Api;
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 Okkim.Budget_Arms_Slaught_O_Matic
{
	[BepInPlugin("MeatKit", "MeatKit Plugin", "1.0.0")]
	[BepInProcess("h3vr.exe")]
	public class MeatKitPlugin_Slaughtomatic : BaseUnityPlugin
	{
		private static readonly string BasePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

		private void Awake()
		{
			LoadAssets();
		}

		private void LoadAssets()
		{
		}
	}
	internal class Slaughtomatic : OpenBoltReceiver
	{
		[Header("Slaught-O-Matic Config")]
		public SlaughtomaticSeal seal;

		public PinnedGrenadePin muzzleCap;

		public Vector3 muzzleCapEjectionForce;

		public Vector3 muzzleCapEjectionRotationalForce;

		public Transform muzzleCapEjectionPoint;

		private bool hasMuzzleCap = true;

		public List<MeshRenderer> meshesWithVariableMats;

		[HideInInspector]
		private int shotsFired;

		private int skinID = -1;

		[Header("Malfunction Config")]
		public int malfunctionShotThreshold = 20;

		public float malfunctionChanceIncrease;

		private float curMalfunctionChance;

		public float timeBetweenBreakageEjections;

		[Tooltip("How much the ejection time can fluctuate")]
		public float ejectionVariance;

		[HideInInspector]
		public bool isMalfunctioned;

		[Header("Breakage Config")]
		public int breakingShotThreshold = 36;

		public float breakingChanceIncrease;

		private float curBreakingChance;

		public MeshFilter[] meshesToBreak;

		public Mesh[] correspondingBrokenMeshes;

		public ParticleSystem breakingParticles;

		public AudioEvent audEvent_BreakGun;

		[HideInInspector]
		public bool isBroken;

		private float timeSinceHeld;

		[Header("Overrides")]
		public bool randomSkinsDisabledOverride = false;

		public bool malfunctionsDisabledOverride = false;

		public override void Awake()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			((OpenBoltReceiver)this).Awake();
			GM.CurrentSceneSettings.ShotFiredEvent += new ShotFired(OnShotFired);
			if (randomSkinsDisabledOverride || skinID >= 0 || !SlaughtomaticConfig.randomSkinsEnabled.Value)
			{
				return;
			}
			if (meshesWithVariableMats.Count > 0)
			{
				skinID = SlaughtomaticConfig.GetWeightedRandomSkinID();
				Material skinByID = SlaughtomaticConfig.GetSkinByID(skinID);
				if (!((Object)(object)skinByID != (Object)null))
				{
					return;
				}
				{
					foreach (MeshRenderer meshesWithVariableMat in meshesWithVariableMats)
					{
						((Renderer)meshesWithVariableMat).material = skinByID;
					}
					return;
				}
			}
			Debug.Log((object)"no meshes to change");
		}

		public override void ConfigureFromFlagDic(Dictionary<string, string> f)
		{
			string key = "SkinID";
			if (f.ContainsKey(key))
			{
				string s = f[key];
				if (int.TryParse(s, out var result))
				{
					skinID = result;
					Material skinByID = SlaughtomaticConfig.GetSkinByID(skinID);
					if ((Object)(object)skinByID != (Object)null)
					{
						foreach (MeshRenderer meshesWithVariableMat in meshesWithVariableMats)
						{
							((Renderer)meshesWithVariableMat).material = skinByID;
						}
					}
				}
			}
			((FVRFireArm)this).ConfigureFromFlagDic(f);
		}

		public override Dictionary<string, string> GetFlagDic()
		{
			Dictionary<string, string> flagDic = ((FVRFireArm)this).GetFlagDic();
			string key = "SkinID";
			string value = skinID.ToString();
			flagDic.Add(key, value);
			return flagDic;
		}

		public override void BeginInteraction(FVRViveHand hand)
		{
			((FVRFireArm)this).BeginInteraction(hand);
			timeSinceHeld = 0f;
		}

		public override void EndInteractionIntoInventorySlot(FVRViveHand hand, FVRQuickBeltSlot slot)
		{
			((OpenBoltReceiver)this).EndInteractionIntoInventorySlot(hand, slot);
			timeSinceHeld = 0f;
		}

		private void OnShotFired(FVRFireArm firearm)
		{
			//IL_002d: 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)
			if (!((Object)(object)firearm == (Object)(object)this) || isBroken)
			{
				return;
			}
			if (hasMuzzleCap)
			{
				DetachAndAddForce(muzzleCap, muzzleCapEjectionForce, muzzleCapEjectionRotationalForce, muzzleCapEjectionPoint);
				hasMuzzleCap = false;
			}
			if (malfunctionsDisabledOverride || !SlaughtomaticConfig.malfunctionsEnabled.Value)
			{
				return;
			}
			shotsFired++;
			if (shotsFired > breakingShotThreshold)
			{
				curBreakingChance += breakingChanceIncrease;
				if (Random.Range(0f, 1f) < curBreakingChance)
				{
					BreakGun();
					return;
				}
			}
			if (shotsFired > malfunctionShotThreshold)
			{
				curMalfunctionChance += malfunctionChanceIncrease;
				if (Random.Range(0f, 1f) < curMalfunctionChance)
				{
					isMalfunctioned = true;
					base.Bolt.m_doesFiringPinStrikeOnArrivalAtFore = false;
				}
			}
		}

		private void BreakGun()
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			isBroken = true;
			if ((Object)(object)breakingParticles != (Object)null)
			{
				breakingParticles.Play();
			}
			SM.PlayCoreSound((FVRPooledAudioType)5, audEvent_BreakGun, ((Component)this).transform.position);
			if (meshesToBreak.Length == correspondingBrokenMeshes.Length)
			{
				for (int i = 0; i < meshesToBreak.Length; i++)
				{
					if ((Object)(object)meshesToBreak[i] != (Object)null && (Object)(object)correspondingBrokenMeshes[i] != (Object)null)
					{
						meshesToBreak[i].mesh = correspondingBrokenMeshes[i];
					}
					else
					{
						Debug.LogError((object)("Mesh or mesh filter of count " + i + "is null on Slaughtomatic"));
					}
				}
			}
			((OpenBoltReceiver)this).EngageSeer();
			((MonoBehaviour)this).StartCoroutine(SpewRemainingBullets());
		}

		private IEnumerator SpewRemainingBullets()
		{
			while (true)
			{
				if (((FVRFireArm)this).Magazine.HasARound())
				{
					FVRFireArmRound component = Object.Instantiate<GameObject>(((FVRFireArm)this).Magazine.RemoveRound(false)).GetComponent<FVRFireArmRound>();
					((Component)component).transform.localRotation = base.RoundPos_Ejection.rotation;
					component.Eject(base.RoundPos_Ejection.position, ((Component)this).transform.right * base.EjectionSpeed.x + ((Component)this).transform.up * base.EjectionSpeed.y + ((Component)this).transform.forward * base.EjectionSpeed.z, ((Component)this).transform.right * base.EjectionSpin.x + ((Component)this).transform.up * base.EjectionSpin.y + ((Component)this).transform.forward * base.EjectionSpin.z);
					SM.PlayGenericSound(((FVRFireArm)this).AudioClipSet.MagazineEjectRound, ((Component)this).transform.position);
				}
				yield return (object)new WaitForSeconds(timeBetweenBreakageEjections + Random.Range(ejectionVariance * -1f, ejectionVariance));
			}
		}

		public void StartDespawnTimer()
		{
			if (SlaughtomaticConfig.weaponDespawnTimer.Value > 0f)
			{
				((MonoBehaviour)this).StartCoroutine(DespawnTimer());
			}
		}

		public IEnumerator DespawnTimer()
		{
			while (true)
			{
				if (((FVRInteractiveObject)this).IsHeld || (Object)(object)((FVRPhysicalObject)this).QuickbeltSlot != (Object)null || SlaughtomaticConfig.weaponDespawnTimer.Value == 0f)
				{
					yield return null;
				}
				timeSinceHeld += Time.deltaTime;
				if (timeSinceHeld > SlaughtomaticConfig.weaponDespawnTimer.Value)
				{
					Object.Destroy((Object)(object)((Component)this).gameObject);
				}
				yield return null;
			}
		}

		public void DetachAndAddForce(PinnedGrenadePin _thing, Vector3 _detachForce, Vector3 _detachRotationalForce, Transform _detachPoint)
		{
			//IL_0017: 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_0071: 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_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: 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_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: 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_010e: 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_011f: Unknown result type (might be due to invalid IL or missing references)
			((Behaviour)_thing).enabled = true;
			((FVRPhysicalObject)_thing).SetParentage((Transform)null);
			((Component)_thing).transform.position = _detachPoint.position;
			((Component)_thing).transform.rotation = _detachPoint.rotation;
			if ((Object)(object)((FVRPhysicalObject)_thing).RootRigidbody == (Object)null)
			{
				((FVRPhysicalObject)_thing).RootRigidbody = ((Component)_thing).gameObject.AddComponent<Rigidbody>();
			}
			((FVRPhysicalObject)_thing).RootRigidbody.mass = 0.02f;
			((FVRPhysicalObject)_thing).RootRigidbody.velocity = ((Component)this).transform.right * _detachForce.x + ((Component)this).transform.up * _detachForce.y + ((Component)this).transform.forward * _detachForce.z;
			((FVRPhysicalObject)_thing).RootRigidbody.maxAngularVelocity = 200f;
			((FVRPhysicalObject)_thing).RootRigidbody.angularVelocity = ((Component)this).transform.right * _detachRotationalForce.x + ((Component)this).transform.up * _detachRotationalForce.y + ((Component)this).transform.forward * _detachRotationalForce.z;
		}
	}
	[BepInPlugin("okkim.slaughtomatic", "Budget Arms Slaught-O-Matic", "1.0.0")]
	[BepInProcess("h3vr.exe")]
	internal class SlaughtomaticConfig : BaseUnityPlugin
	{
		private const string ASSET_BUNDLE_NAME = "slaughtomatic_skins";

		public static List<MaterialProfileEntry> registeredMaterialEntries = new List<MaterialProfileEntry>();

		public static int skinWeightSum;

		public static ConfigEntry<bool> malfunctionsEnabled;

		public static ConfigEntry<bool> randomSkinsEnabled;

		public static ConfigEntry<bool> randomRareSkinsEnabled;

		public static ConfigEntry<bool> pulltabAutoDetachEnabled;

		public static ConfigEntry<float> weaponDespawnTimer;

		private void Awake()
		{
			malfunctionsEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Slaught-O-Matic Config", "Enable Malfunctions", true, "Allows the weapon to jam past 20 shots, and break past 36 shots. After all, you weren't meant to reload it!");
			randomSkinsEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Slaught-O-Matic Config", "Randomize Weapon Skins", true, "If enabled, any new Slaught-O-Matic will have a randomly chosen paintjob.");
			randomRareSkinsEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Slaught-O-Matic Config", "Spawn Rare Skins", true, "Adds a collection of rare (and lore-breaking) skins to the pool of random Slaught-O-Matic paintjobs. Requires restart.");
			pulltabAutoDetachEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Slaught-O-Matic Config", "Remove Pulltab With Trigger Pull", false, "Allows the pulltab to be removed simply by pulling the trigger. Disables TnH scoring.");
			weaponDespawnTimer = ((BaseUnityPlugin)this).Config.Bind<float>("Slaught-O-Matic Config", "Used Weapon Despawn Timer", 30f, "Despawns used Slaught-O-Matics after a set duration. Set to 0 to disable (will impact performance!)");
			string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
			AssetBundle skinBundle = AssetBundle.LoadFromFile(Path.Combine(directoryName, "slaughtomatic_skins"));
			RegisterSkins(skinBundle);
			Harmony.CreateAndPatchAll(typeof(SlaughtomaticConfig), (string)null);
		}

		private void RegisterSkins(AssetBundle _skinBundle)
		{
			SlaughtomaticMaterialProfile slaughtomaticMaterialProfile = _skinBundle.LoadAsset<SlaughtomaticMaterialProfile>("obj_SlaughtomaticMaterialProfile");
			foreach (MaterialProfileEntry materialProfileEntry in slaughtomaticMaterialProfile.materialProfileEntries)
			{
				if (randomRareSkinsEnabled.Value || !materialProfileEntry.isRare)
				{
					registeredMaterialEntries.Add(materialProfileEntry);
					skinWeightSum += materialProfileEntry.weight;
				}
			}
		}

		public static int GetWeightedRandomSkinID()
		{
			int num = Random.Range(0, skinWeightSum + 1);
			int num2 = 0;
			foreach (MaterialProfileEntry registeredMaterialEntry in registeredMaterialEntries)
			{
				num -= registeredMaterialEntry.weight;
				if (num <= 0)
				{
					return num2;
				}
				num2++;
			}
			Debug.LogError((object)"Slaughtomatic: Weighted random skin ID selection didn't return a material entry");
			return -1;
		}

		public static Material GetSkinByID(int _ID)
		{
			if (_ID >= 0)
			{
				return registeredMaterialEntries[_ID].material;
			}
			return null;
		}

		[HarmonyPatch(typeof(OpenBoltReceiver), "ReleaseSeer")]
		[HarmonyPrefix]
		public static bool OpenBoltReceiver_ReleaseSeer_Patch(OpenBoltReceiver __instance)
		{
			if (__instance is Slaughtomatic)
			{
				Slaughtomatic slaughtomatic = __instance as Slaughtomatic;
				if (!slaughtomatic.seal.isPulled || slaughtomatic.isBroken)
				{
					if (pulltabAutoDetachEnabled.Value && !slaughtomatic.seal.isPulled)
					{
						LeaderboardAPI.LeaderboardDisabled.TakeLock();
						slaughtomatic.seal.PullOutSeal(null);
					}
					return false;
				}
			}
			return true;
		}

		[HarmonyPatch(typeof(OpenBoltReceiverBolt), "BoltEvent_EjectRound")]
		[HarmonyPostfix]
		public static void OpenBoltReceiverBolt_BoltEvent_EjectRound_Patch(OpenBoltReceiverBolt __instance)
		{
			if (__instance.Receiver is Slaughtomatic)
			{
				Slaughtomatic slaughtomatic = __instance.Receiver as Slaughtomatic;
				if (slaughtomatic.isMalfunctioned && ((FVRInteractiveObject)((OpenBoltReceiver)slaughtomatic).Bolt).IsHeld)
				{
					((OpenBoltReceiver)slaughtomatic).Bolt.m_doesFiringPinStrikeOnArrivalAtFore = true;
					slaughtomatic.isMalfunctioned = false;
				}
			}
		}
	}
}
[Serializable]
[CreateAssetMenu(fileName = "New SlaughtomaticMaterialProfile", menuName = "Okkim/Slaughtomatic Material Profile", order = 1)]
public class SlaughtomaticMaterialProfile : ScriptableObject
{
	private int materialWeightSum = 0;

	public List<MaterialProfileEntry> materialProfileEntries;

	[ContextMenu("ListPercentages")]
	public void ListPercentages()
	{
		Debug.Log((object)("Material weight sum = " + materialWeightSum));
		int num = 0;
		foreach (MaterialProfileEntry materialProfileEntry in materialProfileEntries)
		{
			float num2 = (float)materialProfileEntry.weight / (float)materialWeightSum;
			Debug.Log((object)("Material " + num + " = " + ((Object)materialProfileEntry.material).name + ", weight = " + materialProfileEntry.weight + ", chance to drop = " + (num2 * 100f).ToString("F4") + "%"));
			num++;
		}
	}

	private void OnValidate()
	{
		materialWeightSum = 0;
		foreach (MaterialProfileEntry materialProfileEntry in materialProfileEntries)
		{
			if (materialProfileEntry != null)
			{
				materialWeightSum += materialProfileEntry.weight;
			}
		}
	}
}
[Serializable]
public class MaterialProfileEntry
{
	public Material material;

	[Tooltip("The higher the value, the more often it shows up in-game")]
	public int weight = 1;

	public bool isRare;
}
namespace Okkim.Budget_Arms_Slaught_O_Matic
{
	internal class SlaughtomaticSeal : FVRInteractiveObject
	{
		[Header("Seal Config")]
		public Slaughtomatic slaughtomatic;

		public PinnedGrenadePin pulltab;

		public Vector3 pulltabEjectionForce;

		public Vector3 pulltabEjectionRotationalForce;

		public WaggleJoint pulltabWaggleJoint;

		public PinnedGrenadePin chamberBlock;

		public Vector3 chamberBlockEjectionForce;

		public Vector3 chamberBlockEjectionRotationalForce;

		public Transform chamberBlockEjectionPoint;

		[HideInInspector]
		public bool isPulled = false;

		public AudioEvent audEvent_PullOutSeal;

		public float distanceNeededToPullOut;

		public Transform anchorPoint;

		public override bool IsInteractable()
		{
			return (((Object)(object)((FVRPhysicalObject)slaughtomatic).QuickbeltSlot != (Object)null && !((FVRPhysicalObject)slaughtomatic).m_isSpawnLock) || (Object)(object)((FVRPhysicalObject)slaughtomatic).QuickbeltSlot == (Object)null) && !isPulled && ((FVRInteractiveObject)this).IsInteractable();
		}

		public override void UpdateInteraction(FVRViveHand hand)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: 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_002e: 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_0038: 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_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_00c7: 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_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: 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_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: 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_015a: 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)
			((FVRInteractiveObject)this).UpdateInteraction(hand);
			Vector3 val = Vector3.ProjectOnPlane(((Component)hand).transform.position - anchorPoint.position, ((Component)slaughtomatic).transform.right);
			Vector3 val2 = anchorPoint.InverseTransformPoint(((Component)hand).transform.position);
			if (val2.y > 0f)
			{
				if (val2.z < 0f)
				{
					((Component)pulltab).transform.LookAt(anchorPoint.position + val, ((Component)slaughtomatic).transform.up * -1f);
				}
				else
				{
					((Component)pulltab).transform.LookAt(anchorPoint.position + val, ((Component)slaughtomatic).transform.up);
				}
				((Component)pulltab).transform.localEulerAngles = new Vector3(Mathf.Clamp(((Component)pulltab).transform.localEulerAngles.x, 270f - pulltabWaggleJoint.angleLimitRight, 270f + pulltabWaggleJoint.angleLimitLeft), ((Component)pulltab).transform.localEulerAngles.y, ((Component)pulltab).transform.localEulerAngles.z);
				if (((Vector3)(ref val2)).sqrMagnitude > distanceNeededToPullOut * distanceNeededToPullOut)
				{
					PullOutSeal(hand);
				}
			}
		}

		public override void EndInteraction(FVRViveHand hand)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			((FVRInteractiveObject)this).EndInteraction(hand);
			((Component)pulltab).transform.rotation = Quaternion.identity;
		}

		public override void FVRUpdate()
		{
			if (!((FVRInteractiveObject)this).IsHeld)
			{
				pulltabWaggleJoint.Execute();
			}
		}

		public void PullOutSeal(FVRViveHand _hand)
		{
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: 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_0100: 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)
			if (!isPulled)
			{
				isPulled = true;
				slaughtomatic.StartDespawnTimer();
				((FVRPhysicalObject)pulltab).RootRigidbody = ((Component)pulltab).gameObject.AddComponent<Rigidbody>();
				((FVRPhysicalObject)pulltab).RootRigidbody.mass = 0.02f;
				((Behaviour)pulltab).enabled = true;
				((FVRInteractiveObject)this).ForceBreakInteraction();
				if ((Object)(object)_hand == (Object)null)
				{
					slaughtomatic.DetachAndAddForce(pulltab, pulltabEjectionForce, pulltabEjectionRotationalForce * -0.5f, chamberBlockEjectionPoint);
				}
				else
				{
					_hand.ForceSetInteractable((FVRInteractiveObject)(object)pulltab);
					((Component)pulltab).transform.position = ((HandInput)(ref _hand.Input)).Pos;
					((FVRInteractiveObject)pulltab).BeginInteraction(_hand);
				}
				SM.PlayCoreSound((FVRPooledAudioType)10, audEvent_PullOutSeal, ((Component)this).transform.position);
				slaughtomatic.DetachAndAddForce(chamberBlock, chamberBlockEjectionForce, chamberBlockEjectionRotationalForce, chamberBlockEjectionPoint);
				((Behaviour)pulltabWaggleJoint).enabled = false;
				((Component)this).gameObject.SetActive(false);
			}
		}
	}
}
[RequireComponent(typeof(ParticleSystem))]
public class CFX_AutoDestructShuriken : MonoBehaviour
{
	public bool OnlyDeactivate;

	private void OnEnable()
	{
		((MonoBehaviour)this).StartCoroutine("CheckIfAlive");
	}

	private IEnumerator CheckIfAlive()
	{
		do
		{
			yield return (object)new WaitForSeconds(0.5f);
		}
		while (((Component)this).GetComponent<ParticleSystem>().IsAlive(true));
		if (OnlyDeactivate)
		{
			((Component)this).gameObject.SetActive(false);
		}
		else
		{
			Object.Destroy((Object)(object)((Component)this).gameObject);
		}
	}
}
[RequireComponent(typeof(Light))]
public class CFX_LightIntensityFade : MonoBehaviour
{
	public float duration = 1f;

	public float delay = 0f;

	public float finalIntensity = 0f;

	private float baseIntensity;

	public bool autodestruct;

	private float p_lifetime = 0f;

	private float p_delay;

	private void Start()
	{
		baseIntensity = ((Component)this).GetComponent<Light>().intensity;
	}

	private void OnEnable()
	{
		p_lifetime = 0f;
		p_delay = delay;
		if (delay > 0f)
		{
			((Behaviour)((Component)this).GetComponent<Light>()).enabled = false;
		}
	}

	private void Update()
	{
		if (p_delay > 0f)
		{
			p_delay -= Time.deltaTime;
			if (p_delay <= 0f)
			{
				((Behaviour)((Component)this).GetComponent<Light>()).enabled = true;
			}
		}
		else if (p_lifetime / duration < 1f)
		{
			((Component)this).GetComponent<Light>().intensity = Mathf.Lerp(baseIntensity, finalIntensity, p_lifetime / duration);
			p_lifetime += Time.deltaTime;
		}
		else if (autodestruct)
		{
			Object.Destroy((Object)(object)((Component)this).gameObject);
		}
	}
}
[RequireComponent(typeof(MeshFilter))]
public class WFX_BulletHoleDecal : MonoBehaviour
{
	private static Vector2[] quadUVs = (Vector2[])(object)new Vector2[4]
	{
		new Vector2(0f, 0f),
		new Vector2(0f, 1f),
		new Vector2(1f, 0f),
		new Vector2(1f, 1f)
	};

	public float lifetime = 10f;

	public float fadeoutpercent = 80f;

	public Vector2 frames;

	public bool randomRotation = false;

	public bool deactivate = false;

	private float life;

	private float fadeout;

	private Color color;

	private float orgAlpha;

	private void Awake()
	{
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		color = ((Component)this).GetComponent<Renderer>().material.GetColor("_TintColor");
		orgAlpha = color.a;
	}

	private void OnEnable()
	{
		//IL_014d: Unknown result type (might be due to invalid IL or missing references)
		int num = Random.Range(0, (int)(frames.x * frames.y));
		int num2 = (int)((float)num % frames.x);
		int num3 = (int)((float)num / frames.y);
		Vector2[] array = (Vector2[])(object)new Vector2[4];
		for (int i = 0; i < 4; i++)
		{
			array[i].x = (quadUVs[i].x + (float)num2) * (1f / frames.x);
			array[i].y = (quadUVs[i].y + (float)num3) * (1f / frames.y);
		}
		((Component)this).GetComponent<MeshFilter>().mesh.uv = array;
		if (randomRotation)
		{
			((Component)this).transform.Rotate(0f, 0f, Random.Range(0f, 360f), (Space)1);
		}
		life = lifetime;
		fadeout = life * (fadeoutpercent / 100f);
		color.a = orgAlpha;
		((Component)this).GetComponent<Renderer>().material.SetColor("_TintColor", color);
		((MonoBehaviour)this).StopAllCoroutines();
		((MonoBehaviour)this).StartCoroutine("holeUpdate");
	}

	private IEnumerator holeUpdate()
	{
		while (life > 0f)
		{
			life -= Time.deltaTime;
			if (life <= fadeout)
			{
				color.a = Mathf.Lerp(0f, orgAlpha, life / fadeout);
				((Component)this).GetComponent<Renderer>().material.SetColor("_TintColor", color);
			}
			yield return null;
		}
	}
}
[RequireComponent(typeof(Light))]
public class WFX_LightFlicker : MonoBehaviour
{
	public float time = 0.05f;

	private float timer;

	private void Start()
	{
		timer = time;
		((MonoBehaviour)this).StartCoroutine("Flicker");
	}

	private IEnumerator Flicker()
	{
		while (true)
		{
			((Behaviour)((Component)this).GetComponent<Light>()).enabled = !((Behaviour)((Component)this).GetComponent<Light>()).enabled;
			do
			{
				timer -= Time.deltaTime;
				yield return null;
			}
			while (timer > 0f);
			timer = time;
		}
	}
}
[BepInPlugin("Okkim.Budget_Arms_Slaught_O_Matic", "Budget_Arms_Slaught_O_Matic", "1.1.2")]
[BepInProcess("h3vr.exe")]
[BepInDependency("h3vr.otherloader", "1.3.0")]
public class Budget_Arms_Slaught_O_MaticPlugin : BaseUnityPlugin
{
	private static readonly string BasePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

	private void Awake()
	{
		LoadAssets();
	}

	private void LoadAssets()
	{
		OtherLoader.RegisterDirectLoad(BasePath, "Okkim.Budget_Arms_Slaught_O_Matic", "", "", "slaughtomatic", "");
	}
}
public class FollowTargetDebug : MonoBehaviour
{
	public bool check;

	private void OnLevelWasLoaded()
	{
		Debug.Log((object)("OnLevelWasLoaded, player head exists: " + GM.CurrentPlayerBody != null));
	}

	private void Awake()
	{
		Debug.Log((object)"OnAwake, player head exists: ");
	}

	private void Start()
	{
		Debug.Log((object)"Start, player head exists: ");
	}

	private void Update()
	{
		if (!check)
		{
			Debug.Log((object)"Update, player head exists: ");
		}
		check = true;
	}
}
public class ExtrudeRandomEdges : MonoBehaviour
{
	private pb_Object pb;

	private pb_Face lastExtrudedFace = null;

	public float distance = 1f;

	private void Start()
	{
		pb = pb_ShapeGenerator.PlaneGenerator(1f, 1f, 0, 0, (Axis)2, false);
		pb.SetFaceMaterial(pb.faces, pb_Constant.DefaultMaterial);
		lastExtrudedFace = pb.faces[0];
	}

	private void OnGUI()
	{
		if (GUILayout.Button("Extrude Random Edge", (GUILayoutOption[])(object)new GUILayoutOption[0]))
		{
			ExtrudeEdge();
		}
	}

	private void ExtrudeEdge()
	{
		//IL_0096: Unknown result type (might be due to invalid IL or missing references)
		//IL_009b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00df: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0101: 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_0122: 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_016c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0174: Unknown result type (might be due to invalid IL or missing references)
		pb_Face sourceFace = lastExtrudedFace;
		List<pb_WingedEdge> wingedEdges = pb_WingedEdge.GetWingedEdges(pb, false);
		IEnumerable<pb_WingedEdge> source = wingedEdges.Where((pb_WingedEdge x) => x.face == sourceFace);
		List<pb_Edge> list = (from x in source
			where x.opposite == null
			select x into y
			select y.edge.local).ToList();
		int index = Random.Range(0, list.Count);
		pb_Edge val = list[index];
		Vector3 val2 = (pb.vertices[val.x] + pb.vertices[val.y]) * 0.5f - pb_Math.Average<int>((IList<int>)sourceFace.distinctIndices, (Func<int, Vector3>)((int x) => pb.vertices[x]), (IList<int>)null);
		((Vector3)(ref val2)).Normalize();
		pb_Edge[] selectedEdges = default(pb_Edge[]);
		pbMeshOps.Extrude(pb, (pb_Edge[])(object)new pb_Edge[1] { val }, 0f, false, true, ref selectedEdges);
		lastExtrudedFace = pb.faces.Last();
		pb.SetSelectedEdges((IEnumerable<pb_Edge>)selectedEdges);
		pb_Object_Utility.TranslateVertices(pb, pb.SelectedTriangles, val2 * distance);
		pb.ToMesh();
		pb.Refresh((RefreshMask)255);
	}
}
public class HighlightNearestFace : MonoBehaviour
{
	public float travel = 50f;

	public float speed = 0.2f;

	private pb_Object target;

	private pb_Face nearest = null;

	private void Start()
	{
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
		target = pb_ShapeGenerator.PlaneGenerator(travel, travel, 25, 25, (Axis)2, false);
		target.SetFaceMaterial(target.faces, pb_Constant.DefaultMaterial);
		((Component)target).transform.position = new Vector3(travel * 0.5f, 0f, travel * 0.5f);
		target.ToMesh();
		target.Refresh((RefreshMask)255);
		Camera main = Camera.main;
		((Component)main).transform.position = new Vector3(25f, 40f, 0f);
		((Component)main).transform.localRotation = Quaternion.Euler(new Vector3(65f, 0f, 0f));
	}

	private void Update()
	{
		//IL_0048: 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)
		//IL_0085: Unknown result type (might be due to invalid IL or missing references)
		//IL_008a: 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_00dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_013d: Unknown result type (might be due to invalid IL or missing references)
		float num = Time.time * speed;
		Vector3 position = default(Vector3);
		((Vector3)(ref position))..ctor(Mathf.PerlinNoise(num, num) * travel, 2f, Mathf.PerlinNoise(num + 1f, num + 1f) * travel);
		((Component)this).transform.position = position;
		if ((Object)(object)target == (Object)null)
		{
			Debug.LogWarning((object)"Missing the ProBuilder Mesh target!");
			return;
		}
		Vector3 val = ((Component)target).transform.InverseTransformPoint(((Component)this).transform.position);
		if (nearest != null)
		{
			target.SetFaceColor(nearest, Color.white);
		}
		int num2 = target.faces.Length;
		float num3 = float.PositiveInfinity;
		nearest = target.faces[0];
		for (int i = 0; i < num2; i++)
		{
			float num4 = Vector3.Distance(val, FaceCenter(target, target.faces[i]));
			if (num4 < num3)
			{
				num3 = num4;
				nearest = target.faces[i];
			}
		}
		target.SetFaceColor(nearest, Color.blue);
		target.RefreshColors();
	}

	private Vector3 FaceCenter(pb_Object pb, pb_Face face)
	{
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_000d: 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_00bf: 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)
		Vector3[] vertices = pb.vertices;
		Vector3 zero = Vector3.zero;
		int[] distinctIndices = face.distinctIndices;
		foreach (int num in distinctIndices)
		{
			zero.x += vertices[num].x;
			zero.y += vertices[num].y;
			zero.z += vertices[num].z;
		}
		float num2 = face.distinctIndices.Length;
		zero.x /= num2;
		zero.y /= num2;
		zero.z /= num2;
		return zero;
	}
}