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 BepInEx.Logging;
using Microsoft.CodeAnalysis;
using MonoMod.RuntimeDetour;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyCompany("WeaponLasers")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+0b5c4aab30000d5d9601dd7c41d6188eb4ffcba5")]
[assembly: AssemblyProduct("Weapon Lasers")]
[assembly: AssemblyTitle("WeaponLasers")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace WeaponLasers
{
[BepInPlugin("WeaponLasers", "Weapon Lasers", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
private class LaserRenderer : MonoBehaviour
{
private void OnGUI()
{
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: 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_0093: 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_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: 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_00b8: 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_00d2: Unknown result type (might be due to invalid IL or missing references)
//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ec: 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_00fd: Unknown result type (might be due to invalid IL or missing references)
try
{
foreach (PhysGrabObject catchedPhysGrabObject in CatchedPhysGrabObjects)
{
try
{
if (!((Object)(object)catchedPhysGrabObject != (Object)null) || !catchedPhysGrabObject.grabbedLocal || !catchedPhysGrabObject.GetField<bool>("isActive") || !catchedPhysGrabObject.GetField<bool>("isGun"))
{
continue;
}
ItemGun component = ((Component)catchedPhysGrabObject).GetComponent<ItemGun>();
if ((Object)(object)component != (Object)null && (Object)(object)component.gunMuzzle != (Object)null)
{
Vector3 position = component.gunMuzzle.position;
Vector3 forward = component.gunMuzzle.forward;
float num = 100f;
Vector3 world = position + forward * num;
if (!((Object)(object)Camera.main == (Object)null) && Utils.WorldToScreen(Camera.main, position, out var screen) && Utils.WorldToScreen(Camera.main, world, out var screen2))
{
Render.Line(new Vector2(screen.x, screen.y), new Vector2(screen2.x, screen2.y), 2f, Color.red);
}
}
}
catch (Exception arg)
{
Logger.LogError((object)$"Inner loop error: {arg}");
}
}
}
catch (Exception arg2)
{
Logger.LogError((object)$"OnGUI error: {arg2}");
}
}
}
internal static ManualLogSource Logger;
private static Hook AwakeHook;
private static Hook DestroyHook;
internal static List<PhysGrabObject> CatchedPhysGrabObjects = new List<PhysGrabObject>();
private void Awake()
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Expected O, but got Unknown
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Expected O, but got Unknown
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_00c4: Expected O, but got Unknown
Logger = ((BaseUnityPlugin)this).Logger;
GameObject val = new GameObject("WeaponLasersRenderer")
{
hideFlags = (HideFlags)61
};
val.AddComponent<LaserRenderer>();
Object.DontDestroyOnLoad((Object)val);
PhysGrabObject[] array = Object.FindObjectsOfType<PhysGrabObject>(true);
List<PhysGrabObject> list = new List<PhysGrabObject>(array.Length);
PhysGrabObject[] array2 = array;
foreach (PhysGrabObject item in array2)
{
list.Add(item);
}
CatchedPhysGrabObjects = list;
AwakeHook = new Hook((MethodBase)typeof(PhysGrabObject).GetMethod("Awake", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic), typeof(Plugin).GetMethod("Awake_Detour", BindingFlags.Static | BindingFlags.NonPublic));
DestroyHook = new Hook((MethodBase)typeof(PhysGrabObject).GetMethod("OnDestroy", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic), typeof(Plugin).GetMethod("OnDestroy_Detour", BindingFlags.Static | BindingFlags.NonPublic));
Logger.LogInfo((object)"Plugin WeaponLasers is loaded!");
}
private static void Awake_Detour(Action<PhysGrabObject> orig, PhysGrabObject self)
{
orig(self);
CatchedPhysGrabObjects.Add(self);
}
private static void OnDestroy_Detour(Action<PhysGrabObject> orig, PhysGrabObject self)
{
orig(self);
CatchedPhysGrabObjects.Remove(self);
}
}
internal static class ReflectExtension
{
private static Dictionary<string, FieldInfo> _fieldCache = new Dictionary<string, FieldInfo>();
internal static T GetField<T>(this object obj, string name)
{
string key = obj.GetType().FullName + ":" + name;
if (!_fieldCache.TryGetValue(key, out var value))
{
FieldInfo? field = obj.GetType().GetField(name, BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
if (field == null)
{
throw new MissingFieldException("Field '" + name + "' not found");
}
value = field;
_fieldCache[key] = value;
}
return (T)value.GetValue(obj);
}
}
internal static class Utils
{
internal static bool WorldToScreen(Camera camera, Vector3 world, out Vector3 screen)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//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)
screen = camera.WorldToViewportPoint(world);
screen.x *= Screen.width;
screen.y *= Screen.height;
screen.y = (float)Screen.height - screen.y;
return screen.z > 0f;
}
}
internal static class Render
{
internal static Color Color = Color.white;
internal static void Line(Vector2 from, Vector2 to, float thickness, Color color)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
Color = color;
Line(from, to, thickness);
}
internal static void Line(Vector2 from, Vector2 to, float thickness)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: 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_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: 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_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
Vector2 val = to - from;
Vector2 normalized = ((Vector2)(ref val)).normalized;
float num = Mathf.Atan2(normalized.y, normalized.x) * 57.29578f;
GUIUtility.RotateAroundPivot(num, from);
Vector2 right = Vector2.right;
val = from - to;
Box(from, right * ((Vector2)(ref val)).magnitude, thickness, centered: false);
GUIUtility.RotateAroundPivot(0f - num, from);
}
internal static void Box(Vector2 position, Vector2 size, float thickness, Color color, bool centered = true)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
Color = color;
Box(position, size, thickness, centered);
}
internal static void Box(Vector2 position, Vector2 size, float thickness, bool centered = true)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: 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_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0003: 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)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: 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_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: 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_0051: 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_0066: 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_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: 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_008f: 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_009b: 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_00ab: Unknown result type (might be due to invalid IL or missing references)
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
Vector2 val = (centered ? (position - size / 2f) : position);
GUI.color = Color;
GUI.DrawTexture(new Rect(val.x, val.y, size.x, thickness), (Texture)(object)Texture2D.whiteTexture);
GUI.DrawTexture(new Rect(val.x, val.y, thickness, size.y), (Texture)(object)Texture2D.whiteTexture);
GUI.DrawTexture(new Rect(val.x + size.x, val.y, thickness, size.y), (Texture)(object)Texture2D.whiteTexture);
GUI.DrawTexture(new Rect(val.x, val.y + size.y, size.x + thickness, thickness), (Texture)(object)Texture2D.whiteTexture);
GUI.color = Color.white;
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "WeaponLasers";
public const string PLUGIN_NAME = "Weapon Lasers";
public const string PLUGIN_VERSION = "1.0.0";
}
}