Decompiled source of CruiserSideAttach v1.1.0

BepInEx/plugins/V56 Cruiser item attachment.dll

Decompiled 7 months ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using GameNetcodeStuff;
using HarmonyLib;
using LethalConfig;
using LethalConfig.ConfigItems;
using LethalConfig.ConfigItems.Options;
using Unity.Netcode;
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("V56 Cruiser item attachment")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("V56 Cruiser item attachment")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("1c0258a2-dd58-44a4-8b86-df663fc3713c")]
[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("Debil.cruiser.sideattach", "Cruiser Side Attach", "10.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class CruiserSideAttach : BaseUnityPlugin
{
	internal static ConfigEntry<int> MaxDistanceConfig;

	internal static ConfigEntry<bool> AllowUndersideConfig;

	private void Awake()
	{
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0052: Expected O, but got Unknown
		//IL_0053: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Expected O, but got Unknown
		//IL_0061: Expected O, but got Unknown
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: Expected O, but got Unknown
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Expected O, but got Unknown
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		MaxDistanceConfig = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Max distance", 0, "Sets max distance for placing items on cruiser (0 = use vanilla grab distance)");
		AllowUndersideConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Allow underside placement", false, "If enabled, allows placing items on ceilings or underside surfaces.");
		ConfigEntry<int> maxDistanceConfig = MaxDistanceConfig;
		IntSliderOptions val = new IntSliderOptions();
		((BaseRangeOptions<int>)val).Min = 0;
		((BaseRangeOptions<int>)val).Max = 100;
		IntSliderConfigItem val2 = new IntSliderConfigItem(maxDistanceConfig, val);
		BoolCheckBoxConfigItem val3 = new BoolCheckBoxConfigItem(AllowUndersideConfig);
		LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val2);
		LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val3);
		new Harmony("Debil.cruiser.sideattach").PatchAll();
	}
}
[HarmonyPatch(typeof(GrabbableObject), "GetPhysicsRegionOfDroppedObject")]
internal class CruiserRegionPatch
{
	private static bool Prefix(GrabbableObject __instance, PlayerControllerB playerDropping, ref NetworkObject __result, ref Vector3 hitPoint)
	{
		//IL_0075: 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_00bc: 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_016f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0176: Unknown result type (might be due to invalid IL or missing references)
		//IL_017b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0180: Unknown result type (might be due to invalid IL or missing references)
		//IL_0190: Unknown result type (might be due to invalid IL or missing references)
		//IL_0195: Unknown result type (might be due to invalid IL or missing references)
		//IL_019a: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)playerDropping == (Object)null)
		{
			return true;
		}
		int mask = LayerMask.GetMask(new string[3] { "Default", "Environment", "Vehicle" });
		float num = ((CruiserSideAttach.MaxDistanceConfig.Value <= 0) ? playerDropping.grabDistance : Mathf.Clamp((float)CruiserSideAttach.MaxDistanceConfig.Value, 0f, 100f));
		RaycastHit val = default(RaycastHit);
		if (!Physics.Raycast(((Component)playerDropping.gameplayCamera).transform.position, ((Component)playerDropping.gameplayCamera).transform.forward, ref val, num, mask, (QueryTriggerInteraction)1))
		{
			return true;
		}
		if (!CruiserSideAttach.AllowUndersideConfig.Value && ((RaycastHit)(ref val)).normal.y < 0.1f)
		{
			return true;
		}
		Transform val2 = ((Component)((RaycastHit)(ref val)).collider).transform;
		while ((Object)(object)val2 != (Object)null && !((Object)val2).name.ToLower().Contains("cruiser"))
		{
			val2 = val2.parent;
		}
		if ((Object)(object)val2 == (Object)null)
		{
			return true;
		}
		PlayerPhysicsRegion componentInChildren = ((Component)val2).GetComponentInChildren<PlayerPhysicsRegion>(true);
		if ((Object)(object)componentInChildren == (Object)null || (Object)(object)componentInChildren.parentNetworkObject == (Object)null)
		{
			return true;
		}
		float num2 = 0.03f;
		Vector3 val3 = ((RaycastHit)(ref val)).point + ((RaycastHit)(ref val)).normal * num2 + Vector3.up * __instance.itemProperties.verticalOffset;
		hitPoint = componentInChildren.physicsTransform.InverseTransformPoint(val3);
		__result = componentInChildren.parentNetworkObject;
		return false;
	}
}