Decompiled source of laser pointer pistol and shotgun v1.0.1

Gun Laser Pointer.dll

Decompiled a month ago
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("Gun Laser Pointer")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Gun Laser Pointer")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("f8ff057c-b134-4fbd-ac76-95d1d2add057")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
[BepInPlugin("com.yourname.lasermod", "Laser Mod", "1.0.0")]
public class LaserPlugin : BaseUnityPlugin
{
	private Dictionary<GameObject, LaserParts> weaponLasers = new Dictionary<GameObject, LaserParts>();

	private string[] weaponScripts = new string[2] { "Weapon", "Gun" };

	private bool laserActive = true;

	private void Update()
	{
		//IL_026d: Unknown result type (might be due to invalid IL or missing references)
		//IL_026f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0274: Unknown result type (might be due to invalid IL or missing references)
		//IL_0276: Unknown result type (might be due to invalid IL or missing references)
		//IL_027f: Unknown result type (might be due to invalid IL or missing references)
		//IL_030b: Unknown result type (might be due to invalid IL or missing references)
		//IL_031b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0324: Unknown result type (might be due to invalid IL or missing references)
		//IL_032e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0333: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_02bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e6: Unknown result type (might be due to invalid IL or missing references)
		if (Input.GetKeyDown((KeyCode)108))
		{
			laserActive = !laserActive;
		}
		if (!laserActive)
		{
			foreach (LaserParts value in weaponLasers.Values)
			{
				((Renderer)value.line).enabled = false;
				value.dot.SetActive(false);
			}
			return;
		}
		Transform[] source = Object.FindObjectsOfType<Transform>();
		List<GameObject> list = (from t in source
			where ((Object)t).name.ToLower().Contains("gun") || ((Object)t).name.ToLower().Contains("pistol") || ((Object)t).name.ToLower().Contains("1911") || ((Object)t).name.ToLower().Contains("shotgun")
			where weaponScripts.Any((string s) => (Object)(object)((Component)t).gameObject.GetComponent(s) != (Object)null)
			select ((Component)t).gameObject).Distinct().ToList();
		HashSet<Transform> hashSet = new HashSet<Transform>();
		Vector3 val = default(Vector3);
		RaycastHit val3 = default(RaycastHit);
		foreach (GameObject item2 in list)
		{
			if ((Object)(object)item2 == (Object)null)
			{
				continue;
			}
			Transform item = (((Object)(object)item2.transform.parent != (Object)null) ? item2.transform.parent : item2.transform);
			if (!hashSet.Contains(item))
			{
				if (!weaponLasers.ContainsKey(item2))
				{
					weaponLasers[item2] = InitializeLaserAssets();
				}
				hashSet.Add(item);
				LaserParts laserParts = weaponLasers[item2];
				string text = ((Object)item2).name.ToLower();
				if (text.Contains("shotgun"))
				{
					((Vector3)(ref val))..ctor(0f, 0.1f, 0.35f);
				}
				else if (text.Contains("pistol") || text.Contains("1911") || (text.Contains("gun") && !text.Contains("safe") && !text.Contains("blow")))
				{
					((Vector3)(ref val))..ctor(0f, 0.67f, 0.35f);
				}
				else
				{
					((Vector3)(ref val))..ctor(0f, 0.05f, 0.3f);
				}
				Vector3 val2 = item2.transform.TransformPoint(val);
				if (Physics.Raycast(val2, item2.transform.forward, ref val3, 60f))
				{
					((Renderer)laserParts.line).enabled = true;
					laserParts.line.SetPosition(0, val2);
					laserParts.line.SetPosition(1, ((RaycastHit)(ref val3)).point);
					laserParts.dot.SetActive(true);
					laserParts.dot.transform.position = ((RaycastHit)(ref val3)).point;
				}
				else
				{
					((Renderer)laserParts.line).enabled = true;
					laserParts.line.SetPosition(0, val2);
					laserParts.line.SetPosition(1, val2 + item2.transform.forward * 60f);
					laserParts.dot.SetActive(false);
				}
			}
		}
	}

	private LaserParts InitializeLaserAssets()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Expected O, but got Unknown
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Expected O, but got Unknown
		//IL_0042: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0075: 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)
		GameObject val = new GameObject("LaserLine");
		LineRenderer val2 = val.AddComponent<LineRenderer>();
		val2.startWidth = 0.02f;
		val2.endWidth = 0.02f;
		((Renderer)val2).material = new Material(Shader.Find("Sprites/Default"));
		val2.startColor = Color.red;
		val2.endColor = Color.red;
		GameObject val3 = GameObject.CreatePrimitive((PrimitiveType)0);
		val3.transform.localScale = new Vector3(0.05f, 0.05f, 0.05f);
		val3.GetComponent<Renderer>().material.color = Color.red;
		Object.Destroy((Object)(object)val3.GetComponent<Collider>());
		return new LaserParts
		{
			line = val2,
			dot = val3
		};
	}
}
public class LaserParts
{
	public LineRenderer line;

	public GameObject dot;
}