using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using Crosshairs;
using HBMF.GameResources;
using HBMF.ModMenu;
using HBMF.Utilities;
using Il2Cpp;
using Il2CppFirearmSystem;
using Il2CppInteractionSystem;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using MelonLoader;
using MelonLoader.Preferences;
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: MelonInfo(typeof(Mod), "Crosshairs", "1.2.0", "korbykob", null)]
[assembly: MelonGame("GexagonVR", "Hard Bullet")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("Crosshairs")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Crosshairs")]
[assembly: AssemblyTitle("Crosshairs")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Crosshairs;
public class Mod : MelonMod
{
private RawImage rightCrosshair;
private RawImage leftCrosshair;
private Il2CppAssetBundle images;
private MelonPreferences_Entry<bool> enabled;
private MelonPreferences_Entry<int> image;
public override void OnInitializeMelon()
{
images = Il2CppAssetBundleManager.LoadFromMemory(Il2CppStructArray<byte>.op_Implicit(Utils.GetResource(Assembly.GetExecutingAssembly(), "Crosshairs.crosshairs.assets")));
MelonPreferences_Category val = MelonPreferences.CreateCategory("Crosshairs");
enabled = val.CreateEntry<bool>("Enabled", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
image = val.CreateEntry<int>("Crosshair", 0, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
Menu.CreateCategory("CROSSHAIRS").CreateBool("ENABLE", enabled.Value, (Action<bool>)delegate(bool value)
{
enabled.Value = value;
((Behaviour)rightCrosshair).enabled = value;
((Behaviour)leftCrosshair).enabled = value;
}).CreateEnum("CROSSHAIR", image.Value, new string[5] { "CIRCLES", "CROSS", "DARTBOARD", "DASHES", "PRECISE" }, (Action<int>)delegate(int value)
{
image.Value = value;
Texture2D[] array = Il2CppArrayBase<Texture2D>.op_Implicit((Il2CppArrayBase<Texture2D>)(object)images.LoadAllAssets<Texture2D>());
rightCrosshair.texture = (Texture)(object)array[value];
leftCrosshair.texture = (Texture)(object)array[value];
});
}
public override void OnSceneWasLoaded(int buildIndex, string sceneName)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: 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_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: 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_00f4: 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_010c: Unknown result type (might be due to invalid IL or missing references)
Transform transform = new GameObject().transform;
CanvasScaler val = new GameObject().AddComponent<CanvasScaler>();
((Component)val).transform.SetParent(transform);
val.dynamicPixelsPerUnit = 100f;
RectTransform component = ((Component)val).GetComponent<RectTransform>();
component.anchorMin = Vector2.zero;
component.anchorMax = Vector2.zero;
component.offsetMin = new Vector2(-0.15f, -0.15f);
component.offsetMax = new Vector2(0.15f, 0.15f);
rightCrosshair = new GameObject().AddComponent<RawImage>();
((Component)rightCrosshair).transform.SetParent((Transform)(object)component);
((Behaviour)rightCrosshair).enabled = enabled.Value;
rightCrosshair.texture = (Texture)(object)((Il2CppArrayBase<Texture2D>)(object)images.LoadAllAssets<Texture2D>())[image.Value];
RectTransform component2 = ((Component)rightCrosshair).GetComponent<RectTransform>();
component2.anchorMin = Vector2.zero;
component2.anchorMax = Vector2.one;
component2.offsetMin = Vector2.zero;
component2.offsetMax = Vector2.zero;
leftCrosshair = ((Component)Object.Instantiate<Transform>(transform).GetChild(0).GetChild(0)).GetComponent<RawImage>();
}
public override void OnUpdate()
{
Check(GameResources.RightGrabber, rightCrosshair);
Check(GameResources.LeftGrabber, leftCrosshair);
}
private void Check(Grabber hand, RawImage crosshair)
{
//IL_005d: 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_00a1: Unknown result type (might be due to invalid IL or missing references)
FirearmEntity val = default(FirearmEntity);
if (enabled.Value && (Object)(object)hand != (Object)null && ((AbstractGrabber)hand).CurrentGrab != null && ((Component)((AbstractGrabber)hand).CurrentGrab.Grabbable).TryGetComponent<FirearmEntity>(ref val))
{
Transform val2 = ((Component)((Component)((AbstractGrabber)hand).CurrentGrab.Grabbable).GetComponentInChildren<Chamber>()).transform.Find("ProjectileInstantiatePosition");
RaycastHit val3 = default(RaycastHit);
if (Physics.Raycast(val2.position, val2.forward, ref val3, 100f, ~LayerMask.GetMask(new string[1] { "Triggers" })))
{
((Component)crosshair).transform.parent.parent.position = ((RaycastHit)(ref val3)).point;
((Component)crosshair).transform.parent.parent.LookAt(GameResources.Camera);
((Component)((Component)crosshair).transform.parent.parent).gameObject.SetActive(true);
}
else
{
((Component)((Component)crosshair).transform.parent.parent).gameObject.SetActive(false);
}
}
else
{
((Component)((Component)crosshair).transform.parent.parent).gameObject.SetActive(false);
}
}
}