using System;
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 BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
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: AssemblyTitle("NMCrosshair")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("NMCrosshair")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("2e32abd0-8b35-45d5-a142-462ec5858869")]
[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")]
namespace NMCrosshair;
[BepInPlugin("Swaggies.NMCrosshair", "NMCrosshair", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
private const string _guid = "Swaggies.NMCrosshair";
private const string _name = "NMCrosshair";
private const string _ver = "1.0.0";
private readonly Harmony harmony = new Harmony("Swaggies.NMCrosshair");
private static Plugin Instance;
private static ManualLogSource loggywoggy;
private static Sprite ui = null;
private static readonly int interactableObjectsMask = 832;
private void Awake()
{
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
loggywoggy = Logger.CreateLogSource("Swaggies.NMCrosshair");
harmony.PatchAll(typeof(Plugin));
loggywoggy.LogInfo((object)"NMCrosshair up and running.");
}
[HarmonyPatch(typeof(PlayerControllerB), "Start")]
[HarmonyPostfix]
private static void InitiateCursor(ref PlayerControllerB __instance)
{
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)ui == (Object)null)
{
ui = ((IEnumerable<Sprite>)Resources.FindObjectsOfTypeAll<Sprite>()).FirstOrDefault((Func<Sprite, bool>)((Sprite img) => ((Object)img).name == "UISprite"));
}
__instance.cursorIcon.sprite = ui;
((Component)__instance.cursorIcon).transform.localScale = new Vector3(0.031f, 0.031f, 0.031f);
}
[HarmonyPatch(typeof(PlayerControllerB), "LateUpdate")]
[HarmonyPostfix]
private static void ChangeCursor(ref PlayerControllerB __instance)
{
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)__instance != (Object)(object)GameNetworkManager.Instance.localPlayerController))
{
((Behaviour)__instance.cursorIcon).enabled = !__instance.isPlayerDead && !__instance.inTerminalMenu;
__instance.cursorIcon.sprite = ui;
((Graphic)__instance.cursorIcon).color = SetCrosshairIconBasedOnConditions(__instance);
}
}
public static Color SetCrosshairIconBasedOnConditions(PlayerControllerB self)
{
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: 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_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_02de: Unknown result type (might be due to invalid IL or missing references)
//IL_0175: Unknown result type (might be due to invalid IL or missing references)
//IL_025d: Unknown result type (might be due to invalid IL or missing references)
//IL_02d6: Unknown result type (might be due to invalid IL or missing references)
//IL_02db: Unknown result type (might be due to invalid IL or missing references)
//IL_00f7: 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_00fc: Unknown result type (might be due to invalid IL or missing references)
//IL_02be: Unknown result type (might be due to invalid IL or missing references)
//IL_02c3: Unknown result type (might be due to invalid IL or missing references)
//IL_0216: Unknown result type (might be due to invalid IL or missing references)
//IL_0200: Unknown result type (might be due to invalid IL or missing references)
//IL_0168: Unknown result type (might be due to invalid IL or missing references)
//IL_016d: Unknown result type (might be due to invalid IL or missing references)
//IL_021b: Unknown result type (might be due to invalid IL or missing references)
//IL_0251: Unknown result type (might be due to invalid IL or missing references)
//IL_0256: Unknown result type (might be due to invalid IL or missing references)
if (self.jetpackControls)
{
return new Color(0.3f, 0.3f, 0.3f, 0.3f);
}
Ray val = default(Ray);
((Ray)(ref val))..ctor(((Component)self.gameplayCamera).transform.position, ((Component)self.gameplayCamera).transform.forward);
RaycastHit val2 = default(RaycastHit);
if (Physics.Raycast(val, ref val2, self.grabDistance, interactableObjectsMask) && ((Component)((RaycastHit)(ref val2)).collider).gameObject.layer != 8)
{
if (((Component)((RaycastHit)(ref val2)).collider).tag == "InteractTrigger")
{
InteractTrigger component = ((Component)((RaycastHit)(ref val2)).transform).gameObject.GetComponent<InteractTrigger>();
if ((Object)(object)component != (Object)null)
{
return component.interactable ? new Color(0f, 1f, 1f) : new Color(0f, 0.33f, 0.33f);
}
}
if (((Component)((RaycastHit)(ref val2)).collider).tag == "PhysicsProp")
{
GrabbableObject component2 = ((Component)((RaycastHit)(ref val2)).transform).gameObject.GetComponent<GrabbableObject>();
if ((Object)(object)component2 != (Object)null && !component2.isHeld && !component2.isHeldByEnemy)
{
return new Color(0f, 1f, 0f);
}
}
}
if (Physics.Raycast(val, ref val2, self.grabDistance, 524288))
{
EnemyAICollisionDetect component3 = ((Component)((RaycastHit)(ref val2)).transform).GetComponent<EnemyAICollisionDetect>();
IHittable val3 = default(IHittable);
if ((Object)(object)component3 != (Object)null && (Object)(object)component3.mainScript != (Object)null && !component3.mainScript.isEnemyDead && ((Component)((RaycastHit)(ref val2)).transform).TryGetComponent<IHittable>(ref val3))
{
return component3.mainScript.enemyType.canDie ? new Color(1f, 0f, 0f) : new Color(0.4f, 0f, 0f);
}
if ((Object)(object)component3 != (Object)null && (Object)(object)component3.mainScript == (Object)null)
{
return new Color(0.4f, 0f, 0f);
}
}
if (Physics.Raycast(val, ref val2, self.grabDistance, StartOfRound.Instance.collidersAndRoomMaskAndDefault) && (((Component)((RaycastHit)(ref val2)).transform).gameObject.layer == 8 || ((Component)((RaycastHit)(ref val2)).transform).gameObject.layer == 11))
{
return new Color(0.6f, 0.6f, 0.6f);
}
return new Color(1f, 1f, 1f);
}
}