using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Unity.IL2CPP;
using Bossa.Cinematika;
using HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Microsoft.CodeAnalysis;
using UnityEngine;
using WildSkies.Service;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("kruft")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Filters interaction options using the cursor.")]
[assembly: AssemblyFileVersion("0.3.1.0")]
[assembly: AssemblyInformationalVersion("0.3.1+6ee6468f5e6fd124cd2fcb6dba7033259555bbb7")]
[assembly: AssemblyProduct("Point To Interact")]
[assembly: AssemblyTitle("kruft.PointToInteract")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/kruftt/LostSkiesMods/tree/main/PointToInteract")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.3.1.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 PointToInteract
{
internal class PointToInteractPatch
{
private static CameraManager _cameraManager;
private static int[] _colliderIDs = new int[10];
[HarmonyPrefix]
[HarmonyPatch(typeof(CharacterInteract), "UpdateInteractionDetectionList")]
private static void FilterNearbyInteractables(CharacterInteract __instance, ref int resultCount)
{
//IL_0032: 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_003d: 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_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: 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_009a: Unknown result type (might be due to invalid IL or missing references)
if (resultCount <= 1)
{
return;
}
Transform transform = ((Component)_cameraManager.Camera).gameObject.transform;
Il2CppStructArray<RaycastHit> occlusionCheckBuffer = __instance._occlusionCheckBuffer;
Il2CppReferenceArray<Collider> interactablesNearby = __instance._interactablesNearby;
int num = Physics.RaycastNonAlloc(new Ray(transform.position, transform.forward), occlusionCheckBuffer, __instance._interactRadius + Vector3.Distance(transform.position, __instance._character.WorldCenterOfMass), LayerMask.op_Implicit(__instance._interactableLayerMask), (QueryTriggerInteraction)2);
if (num <= 0)
{
return;
}
int num2 = 0;
for (int i = 0; i < num; i++)
{
int[] colliderIDs = _colliderIDs;
int num3 = i;
RaycastHit val = ((Il2CppArrayBase<RaycastHit>)(object)occlusionCheckBuffer)[i];
colliderIDs[num3] = ((RaycastHit)(ref val)).colliderInstanceID;
}
for (int j = 0; j < resultCount; j++)
{
if (num <= 0)
{
break;
}
Collider val2 = ((Il2CppArrayBase<Collider>)(object)interactablesNearby)[j];
int instanceID = ((Object)val2).GetInstanceID();
for (int k = 0; k < num; k++)
{
if (_colliderIDs[k] == instanceID)
{
((Il2CppArrayBase<Collider>)(object)interactablesNearby)[num2] = val2;
num2++;
num--;
_colliderIDs[k] = _colliderIDs[num];
break;
}
}
}
if (num2 > 0)
{
resultCount = num2;
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(PlayersService), "RegisterLocalPlayer")]
private static void SetCamera(PlayersService __instance)
{
_cameraManager = __instance.LocalPlayer.CameraManager;
}
[HarmonyPostfix]
[HarmonyPatch(typeof(PlayersService), "UnregisterLocalPlayer")]
private static void UnsetCamera(PlayersService __instance)
{
_cameraManager = null;
}
}
[BepInPlugin("kruft.PointToInteract", "Point To Interact", "0.3.1")]
public class PointToInteractPlugin : BasePlugin
{
public override void Load()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Expected O, but got Unknown
Harmony val = new Harmony("kruft.PointToInteract");
val.PatchAll(typeof(PointToInteractPatch));
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "kruft.PointToInteract";
public const string PLUGIN_NAME = "Point To Interact";
public const string PLUGIN_VERSION = "0.3.1";
}
}