Decompiled source of TerribleScripts v0.2.5

TerribleScripts.dll

Decompiled a day ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using FistVR;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyCompany("nootarc")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Scripts for my mods. It's like i'm a real modder now!")]
[assembly: AssemblyFileVersion("0.2.5.0")]
[assembly: AssemblyInformationalVersion("0.2.5+f8a5a294cfcc405ecf622684b3bebc24263ab197")]
[assembly: AssemblyProduct("TerribleScripts")]
[assembly: AssemblyTitle("TerribleScripts")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.2.5.0")]
[module: UnverifiableCode]
namespace BepInEx
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class BepInAutoPluginAttribute : Attribute
	{
		public BepInAutoPluginAttribute(string id = null, string name = null, string version = null)
		{
		}
	}
}
namespace BepInEx.Preloader.Core.Patching
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class PatcherAutoPluginAttribute : Attribute
	{
		public PatcherAutoPluginAttribute(string id = null, string name = null, string version = null)
		{
		}
	}
}
namespace nootarc
{
	[CreateAssetMenu(menuName = "Misc/CalculateBDCC", fileName = "NewBDCCurve")]
	public class ScaleBDCC : ScriptableObject
	{
		public AnimationCurve curve;

		public AnimationCurve scaledCurve;

		public float Width = 1f;

		public float Height = 0.1f;

		[ContextMenu("Scale Curve")]
		public void ScaleCurve()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < curve.keys.Length; i++)
			{
				Keyframe val = curve.keys[i];
				((Keyframe)(ref val)).value = ((Keyframe)(ref curve.keys[i])).value * Height;
				((Keyframe)(ref val)).time = ((Keyframe)(ref curve.keys[i])).time * Width;
				((Keyframe)(ref val)).inTangent = ((Keyframe)(ref curve.keys[i])).inTangent * Height / Width;
				((Keyframe)(ref val)).outTangent = ((Keyframe)(ref curve.keys[i])).outTangent * Height / Width;
				scaledCurve.AddKey(val);
			}
		}
	}
}
namespace nootarc.HCBBoltStuff
{
	public class HCBBoltify : MonoBehaviour
	{
		public FVRFireArm FireArm;

		public FVRFireArmChamber Chamber;

		private void Hook()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			GM.CurrentSceneSettings.ShotFiredEvent += new ShotFired(OnShotFired);
		}

		private void OnShotFired(FVRFireArm firearm)
		{
			//IL_004e: 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_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)firearm == (Object)(object)FireArm && (Object)(object)((Component)Chamber.GetRound()).GetComponent<RoundHCBBoltType>() != (Object)null)
			{
				FVRFireArmRound round = Chamber.GetRound();
				RoundHCBBoltType component = ((Component)round).GetComponent<RoundHCBBoltType>();
				GameObject roundHCBBolt = component.RoundHCBBolt;
				GameObject val = Object.Instantiate<GameObject>(roundHCBBolt, firearm.CurrentMuzzle.position, firearm.CurrentMuzzle.rotation);
				HCBBolt component2 = val.GetComponent<HCBBolt>();
				component2.SetCookedAmount(1f);
				component2.Fire(firearm.MuzzlePos.forward, firearm.MuzzlePos.position, 1f);
			}
		}

		public void Awake()
		{
			Hook();
		}
	}
	public class RoundHCBBoltType : MonoBehaviour
	{
		public GameObject RoundHCBBolt;
	}
	public class TrepangExplodeyBolt : MonoBehaviour
	{
		public ParticleSystem fuseParticles;

		public AudioEvent fuseSound;

		[HideInInspector]
		public float fuseTime = 3f;

		public float startFuseTime = 3f;

		public List<GameObject> ExplosionSpawns;

		[HideInInspector]
		public int IFF;

		[HideInInspector]
		public float fuseTick;

		public void StartExplosion()
		{
			//IL_008b: 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_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: 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)
			fuseTime -= Time.deltaTime;
			float num = Mathf.Clamp(1f - fuseTime / startFuseTime, 0f, 1f);
			num = Mathf.Pow(num, 2f);
			if (fuseTick <= 0f)
			{
				fuseTick = Mathf.Lerp(0.3f, 0.01f, num);
				float num2 = Mathf.Lerp(1.8f, 3.7f, num);
				SM.PlayCoreSoundOverrides((FVRPooledAudioType)0, fuseSound, ((Component)this).transform.position, new Vector2(1f, 1f), new Vector2(num2, num2));
				fuseParticles.Emit(2);
			}
			else
			{
				fuseTick -= Time.deltaTime;
			}
			if (!(fuseTime <= 0f))
			{
				return;
			}
			foreach (GameObject explosionSpawn in ExplosionSpawns)
			{
				GameObject val = Object.Instantiate<GameObject>(explosionSpawn, ((Component)this).transform.position, Quaternion.identity);
				Explosion component = val.GetComponent<Explosion>();
				if ((Object)(object)component != (Object)null)
				{
					component.IFF = IFF;
				}
				ExplosionSound component2 = val.GetComponent<ExplosionSound>();
				if ((Object)(object)component2 != (Object)null)
				{
					component2.IFF = IFF;
				}
			}
			Object.Destroy((Object)(object)((Component)this).gameObject);
		}

		public void Update()
		{
			if (!Object.op_Implicit((Object)(object)((Component)this).gameObject.GetComponent<HCBBolt>()) || !((Component)this).gameObject.GetComponent<HCBBolt>().m_isFlying)
			{
				StartExplosion();
			}
		}
	}
}
namespace TerribleScripts
{
	[BepInProcess("h3vr.exe")]
	[BepInPlugin("TerribleScripts", "TerribleScripts", "0.2.5+f8a5a294cfcc405ecf622684b3bebc24263ab197")]
	public class TerribleScriptsBase : BaseUnityPlugin
	{
		public const string Id = "TerribleScripts";

		public static string Name => "TerribleScripts";

		public static string Version => "0.2.5+f8a5a294cfcc405ecf622684b3bebc24263ab197";
	}
}
namespace TerribleScripts.WeaponModifications
{
	public class DuplicatedMuzzle : MonoBehaviour
	{
		public FVRFireArm FireArm;

		public void Hook()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			GM.CurrentSceneSettings.ShotFiredEvent += new ShotFired(OnShotFired);
		}

		public void Awake()
		{
			Hook();
		}

		public void OnShotFired(FVRFireArm firearm)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: 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_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: 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_0109: 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_0116: 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_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: 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_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: 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_0178: 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)
			if (!((Object)(object)firearm == (Object)(object)FireArm))
			{
				return;
			}
			float chamberVelMult = AM.GetChamberVelMult(firearm.FChambers[0].RoundType, Vector3.Distance(((Component)firearm.FChambers[0]).transform.position, firearm.CurrentMuzzle.position));
			float num = firearm.GetCombinedFixedDrop(firearm.AccuracyClass) * 0.0166667f;
			Vector2 val = firearm.GetCombinedFixedDrift(firearm.AccuracyClass) * 0.0166667f;
			for (int i = 0; i < firearm.FChambers[0].GetRound().NumProjectiles; i++)
			{
				float num2 = firearm.FChambers[0].GetRound().ProjectileSpread + firearm.m_internalMechanicalMOA + firearm.GetCombinedMuzzleDeviceAccuracy();
				if ((Object)(object)firearm.FChambers[0].GetRound().BallisticProjectilePrefab != (Object)null)
				{
					Vector3 val2 = ((Component)this).transform.forward * 0.005f;
					GameObject val3 = Object.Instantiate<GameObject>(firearm.FChambers[0].GetRound().BallisticProjectilePrefab, ((Component)this).transform.position - val2, ((Component)this).transform.rotation);
					Vector2 val4 = (Random.insideUnitCircle + Random.insideUnitCircle + Random.insideUnitCircle) * (1f / 3f) * num2;
					val3.transform.Rotate(new Vector3(val4.x + val.y + num, val4.y + val.x, 0f));
					BallisticProjectile component = val3.GetComponent<BallisticProjectile>();
					component.Fire(component.MuzzleVelocityBase * firearm.FChambers[0].ChamberVelocityMultiplier * 1f * chamberVelMult, val3.transform.forward, firearm, true);
				}
			}
		}
	}
	public class ToggleOnGrabRelease : MonoBehaviour
	{
		[Tooltip("Object that you pick up/release")]
		public FVRPhysicalObject Parent;

		[Tooltip("When true, enables objects when parent is held and disables them when not held; Reverse when false")]
		public bool Enable;

		[Tooltip("Objects to toggle")]
		public List<GameObject> Objects;

		[HideInInspector]
		public bool Held;

		public void Hook()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			GM.CurrentSceneSettings.ObjectPickedUpEvent += new FVRObjectPickedUp(ObjectPickedUp);
		}

		public void Awake()
		{
			Hook();
		}

		public void ObjectPickedUp(FVRPhysicalObject ParentObject)
		{
			if ((Object)(object)ParentObject == (Object)(object)Parent)
			{
				for (int i = 0; i < Objects.Count; i++)
				{
					Objects[i].SetActive(Enable);
					Held = true;
				}
			}
		}

		private void Update()
		{
			if (Held && !((FVRInteractiveObject)Parent).m_isHeld)
			{
				for (int i = 0; i < Objects.Count; i++)
				{
					Objects[i].SetActive(!Enable);
				}
				Held = false;
			}
		}
	}
	public class FakeMinigunSounds : MonoBehaviour
	{
	}
	public class ReplenishFirearmMagazineAutomagically : MonoBehaviour
	{
		[Header("NOTE: This script is used with firearms, not magazines!")]
		[Tooltip("The round class that should be replenished by default if the gun spawns empty")]
		public FireArmRoundClass FallbackRoundClass = (FireArmRoundClass)1;

		public FVRFireArm firearm;

		[Tooltip("Makes the magazine only replenish when the firearm is being held and the AX button is being pressed. If false, firearm replenishes when *not* held, and stops when held. ")]
		public bool HoldToReplenish;

		[Tooltip("*Only functions when HoldToReplenish is false* Clicking the AX button toggles the replenish-when-not-held feature on and off.")]
		public bool ToggleToReplenish;

		[Tooltip("Should the trigger make the firearm stop replenishing")]
		public bool TriggerBlocksReplenish;

		[Header("Delays")]
		[Tooltip("Delay in seconds between loading rounds at the fastest")]
		public float minReplenishRate = 0.066f;

		[Tooltip("Delay in seconds between loading rounds at the slowest")]
		public float maxReplenishRate = 5f;

		[Tooltip("Smaller the number, the longer the delay, and vice versa. 0 to bypass lerp and replenish at max, 1 to replenish at min")]
		public float lerpFactor = 0.5f;

		[Header("Audio")]
		[Tooltip("Makes the mag insert round sound every time a round is replenished")]
		public bool IndividualRoundSound;

		[Tooltip("OPTIONAL: audio source w/ clip that will play when the gun is replenishing, e.g. if you want to have a quiet loop instead of CLICK CLICK CLICK CLICK CLICK")]
		public AudioSource replenishAudioSource;

		[HideInInspector]
		public bool isReplenishing;

		[HideInInspector]
		public float replenishTimer;

		[HideInInspector]
		public FireArmRoundClass RoundClass;

		[HideInInspector]
		public FVRViveHand hand;

		public void Awake()
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			RoundClass = FallbackRoundClass;
		}

		public void Update()
		{
			//IL_0020: 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_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_00cd: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)firearm.FChambers[0].GetRound() != (Object)null && RoundClass != firearm.FChambers[0].GetRound().RoundClass)
			{
				RoundClass = firearm.FChambers[0].GetRound().RoundClass;
			}
			if (isReplenishing && replenishTimer > 0f)
			{
				replenishTimer -= Time.deltaTime;
			}
			else if (isReplenishing && replenishTimer <= 0f)
			{
				firearm.Magazine.AddRound(RoundClass, IndividualRoundSound, false);
				replenishTimer = Mathf.Lerp(replenishTimer, minReplenishRate, lerpFactor);
			}
			if ((Object)(object)replenishAudioSource != (Object)null)
			{
				if (isReplenishing && !replenishAudioSource.isPlaying)
				{
					replenishAudioSource.Play();
				}
				else
				{
					replenishAudioSource.Stop();
				}
			}
			if (HoldToReplenish)
			{
				isReplenishing = false;
			}
			if ((Object)(object)((FVRInteractiveObject)firearm).m_hand == (Object)null && (HoldToReplenish || ToggleToReplenish))
			{
				return;
			}
			if (HoldToReplenish)
			{
				hand = ((FVRInteractiveObject)firearm).m_hand;
				if ((TriggerBlocksReplenish && (double)hand.Input.TriggerFloat < 0.1) || !TriggerBlocksReplenish)
				{
					if (hand.Input.AXButtonDown)
					{
						isReplenishing = true;
					}
					else if (hand.Input.AXButtonUp)
					{
						isReplenishing = false;
					}
				}
				else
				{
					isReplenishing = false;
				}
			}
			else if (ToggleToReplenish)
			{
				hand = ((FVRInteractiveObject)firearm).m_hand;
				if (hand.Input.AXButtonDown)
				{
					isReplenishing = !isReplenishing;
				}
			}
			else
			{
				isReplenishing = !((FVRInteractiveObject)firearm).IsHeld;
			}
		}
	}
}
namespace TerribleScripts.ModMods
{
	public class AmmoCountUIColorShenanigans : MonoBehaviour
	{
		[Header("Note: There should be one gradient per object with them having")]
		[Header("the same positions (topmost object will use the topmost gradient, for example)")]
		[Tooltip("Graphics to recolor")]
		public List<Graphic> Graphics;

		[Tooltip("Lasers & Lights to recolor (Uses gradients that come immediately after the graphics ones)")]
		public List<LaserLight> LaserLights;

		[Tooltip("Gradients to recolor the graphics with; key position is the fullness factor (e.g 0.2f is 20% capacity remaining)")]
		public List<Gradient> Gradients;

		[Tooltip("Firearm :)")]
		public FVRFireArm FireArm;

		[Tooltip("Does your firearm have/uses magazines or is it direct chamber-loaded?")]
		public bool UsesMags;

		[HideInInspector]
		public int MaxCap;

		[HideInInspector]
		public float CurrentAmount;

		[HideInInspector]
		public int LoadedChambers;

		[HideInInspector]
		public float CurrentPercentage;

		[HideInInspector]
		public Color UIColor;

		[HideInInspector]
		public bool DelayFlip = true;

		public void Update()
		{
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: 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)
			DelayFlip = !DelayFlip;
			if (!DelayFlip)
			{
				return;
			}
			for (int i = 0; i < FireArm.FChambers.Count; i++)
			{
				if (FireArm.FChambers[i].IsFull)
				{
					LoadedChambers++;
				}
			}
			if ((Object)(object)FireArm.Magazine != (Object)null)
			{
				MaxCap = FireArm.Magazine.m_capacity;
				CurrentAmount = FireArm.Magazine.m_numRounds;
			}
			else
			{
				MaxCap = ((!UsesMags) ? 1 : FireArm.FChambers.Count);
				CurrentAmount = LoadedChambers;
			}
			float num = CurrentAmount / (float)MaxCap;
			CurrentPercentage = Mathf.Clamp01(num);
			if (DelayFlip)
			{
				for (int j = 0; j < Graphics.Count; j++)
				{
					UIColor = Gradients[j].Evaluate(CurrentPercentage);
					Graphics[j].color = UIColor;
				}
				for (int k = 0; k < LaserLights.Count; k++)
				{
					UIColor = Gradients[k + Graphics.Count].Evaluate(CurrentPercentage);
					LaserLights[k].color = UIColor;
				}
			}
			LoadedChambers = 0;
		}
	}
}