Decompiled source of HuntAvtomat v1.0.0

HuntAvtomat.dll

Decompiled 5 days ago
using System.Collections;
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 UnityEditor;
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 BitWizrd.HuntAvtomat;

[BepInPlugin("BitWizrd.HuntAvtomat", "HuntAvtomat", "1.0.0")]
[BepInProcess("h3vr.exe")]
[Description("Built with MeatKit")]
[BepInDependency("h3vr.otherloader", "1.3.0")]
public class HuntAvtomatPlugin : 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(), "BitWizrd.HuntAvtomat");
		OtherLoader.RegisterDirectLoad(BasePath, "BitWizrd.HuntAvtomat", "", "avtomat", "", "");
	}
}
public class BloodBondSR : MonoBehaviour
{
	private void Awake()
	{
		string name = "Ammo_69_CashMoney_D100(Clone)";
		((Object)((Component)this).gameObject).name = name;
		Collider[] componentsInChildren = ((Component)this).GetComponentsInChildren<Collider>(true);
		for (int i = 0; i < componentsInChildren.Length; i++)
		{
			((Object)((Component)componentsInChildren[i]).gameObject).name = name;
		}
	}
}
public class CooldownSound : MonoBehaviour
{
	public ClosedBoltWeapon weapon;

	public AudioClip[] audioClips;

	public float volume = 1f;

	public int minShots = 5;

	public int maxShots = 10;

	public float minDelay = 0.5f;

	public float maxDelay = 2f;

	public float resetTime = 1.5f;

	private AudioSource audioSource;

	private int shotCounter = 0;

	private float lastShotTime;

	private bool lastRoundSpent;

	private int nextShotThreshold;

	private bool isPlayingSound = false;

	private void Start()
	{
		if ((Object)(object)weapon == (Object)null)
		{
			weapon = ((Component)this).GetComponent<ClosedBoltWeapon>();
		}
		if ((Object)(object)weapon == (Object)null)
		{
			Debug.LogError((object)"CooldownSound: Weapon reference is missing. Attach this script to a ClosedBoltWeapon.");
			return;
		}
		audioSource = ((Component)weapon).gameObject.GetComponent<AudioSource>();
		if ((Object)(object)audioSource == (Object)null)
		{
			audioSource = ((Component)weapon).gameObject.AddComponent<AudioSource>();
		}
		audioSource.spatialBlend = 1f;
		audioSource.playOnAwake = false;
		audioSource.rolloffMode = (AudioRolloffMode)0;
		lastRoundSpent = weapon.Chamber.IsSpent;
		SetNewShotThreshold();
	}

	private void Update()
	{
		DetectFiring();
	}

	private void DetectFiring()
	{
		if (weapon.Chamber.IsFull && weapon.Chamber.IsSpent && !lastRoundSpent)
		{
			OnWeaponFired();
		}
		lastRoundSpent = weapon.Chamber.IsSpent;
	}

	private void OnWeaponFired()
	{
		float num = Time.time - lastShotTime;
		if (num > resetTime)
		{
			shotCounter = 0;
			SetNewShotThreshold();
		}
		shotCounter++;
		lastShotTime = Time.time;
		if (shotCounter >= nextShotThreshold)
		{
			((MonoBehaviour)this).StartCoroutine(PlaySoundWithDelay());
			shotCounter = 0;
			SetNewShotThreshold();
		}
	}

	private IEnumerator PlaySoundWithDelay()
	{
		if (!isPlayingSound)
		{
			isPlayingSound = true;
			float delay = Random.Range(minDelay, maxDelay);
			yield return (object)new WaitForSeconds(delay);
			if (audioClips.Length > 0)
			{
				int index = Random.Range(0, audioClips.Length);
				audioSource.clip = audioClips[index];
				audioSource.PlayOneShot(audioSource.clip, volume);
				yield return (object)new WaitForSeconds(audioSource.clip.length);
			}
			isPlayingSound = false;
		}
	}

	private void SetNewShotThreshold()
	{
		nextShotThreshold = Random.Range(minShots, maxShots + 1);
	}
}
public class CylindersphereAdjuster : EditorWindow
{
	private Transform centerTransform;

	private float offset = 1E-05f;

	private string offsetString = "0.00001";

	private bool useLocalSpace = true;

	private string instructions = "Select the sphere objects you want to adjust. When using Local Space, each object's local position will be adjusted radially (from its parent's center). When not using Local Space, a Center Transform (or world origin if left empty) is used to compute the radial offset.";

	[MenuItem("Tools/Cylindersphere Adjuster")]
	public static void ShowWindow()
	{
		EditorWindow.GetWindow<CylindersphereAdjuster>("Cylindersphere Adjuster");
	}

	private void OnGUI()
	{
		EditorGUILayout.LabelField("Cylindersphere Adjuster", EditorStyles.boldLabel, (GUILayoutOption[])(object)new GUILayoutOption[0]);
		EditorGUILayout.HelpBox(instructions, (MessageType)1);
		useLocalSpace = EditorGUILayout.Toggle("Use Local Space", useLocalSpace, (GUILayoutOption[])(object)new GUILayoutOption[0]);
		if (!useLocalSpace)
		{
			ref Transform reference = ref centerTransform;
			Object obj = EditorGUILayout.ObjectField("Center Transform", (Object)(object)centerTransform, typeof(Transform), true, (GUILayoutOption[])(object)new GUILayoutOption[0]);
			reference = (Transform)(object)((obj is Transform) ? obj : null);
		}
		offsetString = EditorGUILayout.TextField("Offset", offsetString, (GUILayoutOption[])(object)new GUILayoutOption[0]);
		if (!float.TryParse(offsetString, out offset))
		{
			offset = 1E-05f;
			offsetString = offset.ToString("0.000000");
		}
		else
		{
			offsetString = offset.ToString("0.000000");
		}
		if (GUILayout.Button("Apply Adjustment to Selected", (GUILayoutOption[])(object)new GUILayoutOption[0]))
		{
			AdjustSelectedObjects();
		}
	}

	private void AdjustSelectedObjects()
	{
		//IL_005d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_0063: 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_00fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a9: 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_00bd: 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_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_010f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0114: 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_0118: Unknown result type (might be due to invalid IL or missing references)
		//IL_015b: Unknown result type (might be due to invalid IL or missing references)
		//IL_015f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0166: Unknown result type (might be due to invalid IL or missing references)
		//IL_016b: 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)
		//IL_0178: Unknown result type (might be due to invalid IL or missing references)
		if (Selection.gameObjects.Length == 0)
		{
			EditorUtility.DisplayDialog("No Objects Selected", "Please select the sphere objects to adjust.", "OK");
			return;
		}
		GameObject[] gameObjects = Selection.gameObjects;
		foreach (GameObject val in gameObjects)
		{
			if (useLocalSpace)
			{
				Undo.RecordObject((Object)(object)val.transform, "Adjust Local Position");
				Vector3 localPosition = val.transform.localPosition;
				if (localPosition == Vector3.zero)
				{
					Debug.LogWarning((object)("Object " + ((Object)val).name + " has a local position of zero and cannot be adjusted."));
					continue;
				}
				float magnitude = ((Vector3)(ref localPosition)).magnitude;
				float num = magnitude + offset;
				Vector3 localPosition2 = ((Vector3)(ref localPosition)).normalized * num;
				val.transform.localPosition = localPosition2;
				continue;
			}
			Undo.RecordObject((Object)(object)val.transform, "Adjust World Position");
			Vector3 val2 = ((!Object.op_Implicit((Object)(object)centerTransform)) ? Vector3.zero : centerTransform.position);
			Vector3 val3 = val.transform.position - val2;
			if (val3 == Vector3.zero)
			{
				Debug.LogWarning((object)("Object " + ((Object)val).name + " is at the center point and cannot be adjusted."));
				continue;
			}
			float magnitude2 = ((Vector3)(ref val3)).magnitude;
			float num2 = magnitude2 + offset;
			Vector3 position = val2 + ((Vector3)(ref val3)).normalized * num2;
			val.transform.position = position;
		}
	}
}
public class HuntDollarSR : MonoBehaviour
{
	private IEnumerator Start()
	{
		yield return (object)new WaitForSeconds(3f);
		string str = "CharcoalBriquette(Clone)";
		((Object)((Component)this).gameObject).name = str;
		Collider[] componentsInChildren = ((Component)this).GetComponentsInChildren<Collider>(true);
		for (int i = 0; i < componentsInChildren.Length; i++)
		{
			Component val = (Component)(object)componentsInChildren[i];
			((Object)val.gameObject).name = str;
		}
	}
}
public class PlayRandomSoundOnSpawn : MonoBehaviour
{
	public AudioClip[] spawnSounds;

	public float volume = 1f;

	[Header("Pitch Settings")]
	public float minPitch = 0.9f;

	public float maxPitch = 1.1f;

	private AudioSource audioSource;

	private void Start()
	{
		if (spawnSounds.Length > 0)
		{
			audioSource = ((Component)this).gameObject.AddComponent<AudioSource>();
			audioSource.playOnAwake = false;
			audioSource.spatialBlend = 1f;
			audioSource.volume = volume;
			AudioClip val = spawnSounds[Random.Range(0, spawnSounds.Length)];
			audioSource.pitch = Random.Range(minPitch, maxPitch);
			audioSource.PlayOneShot(val);
		}
	}
}
public class RandomSpinOnSpawn : MonoBehaviour
{
	public float spinForce = 0.5f;

	public Vector3 torqueAxis = new Vector3(1f, 0f, 0f);

	private Rigidbody rb;

	private void Start()
	{
		//IL_003e: 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_005f: Unknown result type (might be due to invalid IL or missing references)
		rb = ((Component)this).GetComponent<Rigidbody>();
		if ((Object)(object)rb != (Object)null)
		{
			((Component)this).transform.rotation = Quaternion.Euler(0f, Random.Range(0f, 360f), 0f);
			rb.AddTorque(((Vector3)(ref torqueAxis)).normalized * spinForce, (ForceMode)1);
		}
	}
}