Decompiled source of WolfCanTakeItem v1.0.1

plugins/WolfCanTakeItem/WolfCanTakeItem.dll

Decompiled 7 months ago
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.Logging;
using Fusion;
using Managers;
using Microsoft.CodeAnalysis;
using On;
using UnityEngine;
using WolfCanTakeItem.Patch;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("WolfCanTakeItem")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+4467a1c16c9bc21046c68733317e1103fe3b5261")]
[assembly: AssemblyProduct("WolfCanTakeItem")]
[assembly: AssemblyTitle("WolfCanTakeItem")]
[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 WolfCanTakeItem
{
	internal static class Log
	{
		private static ManualLogSource _logSource;

		internal static void Init(ManualLogSource logSource)
		{
			_logSource = logSource;
		}

		internal static void Debug(object data)
		{
			_logSource.LogDebug(data);
		}

		internal static void Error(object data)
		{
			_logSource.LogError(data);
		}

		internal static void Fatal(object data)
		{
			_logSource.LogFatal(data);
		}

		internal static void Info(object data)
		{
			_logSource.LogInfo(data);
		}

		internal static void Message(object data)
		{
			_logSource.LogMessage(data);
		}

		internal static void Warning(object data)
		{
			_logSource.LogWarning(data);
		}
	}
	[BepInPlugin("LloydHawkeye.ThirstyWolf", "ThirstyWolf", "1.0.0")]
	[BepInProcess("Lycans.exe")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class WolfCanTakeItem : BaseUnityPlugin
	{
		public const string PLUGIN_GUID = "LloydHawkeye.ThirstyWolf";

		public const string PLUGIN_AUTHOR = "LloydHawkeye";

		public const string PLUGIN_NAME = "ThirstyWolf";

		public const string PLUGIN_VERSION = "1.0.0";

		private void Awake()
		{
			Log.Init(((BaseUnityPlugin)this).Logger);
			PlayerControllerPatch.Patch();
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "WolfCanTakeItem";

		public const string PLUGIN_NAME = "WolfCanTakeItem";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace WolfCanTakeItem.Patch
{
	internal class PlayerControllerPatch
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_CheckItemRayCast <0>__PlayerController_CheckItemRayCast;

			public static hook_UseItem <1>__PlayerController_UseItem;
		}

		public static void Patch()
		{
			//IL_0011: 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_001c: Expected O, but got Unknown
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Expected O, but got Unknown
			object obj = <>O.<0>__PlayerController_CheckItemRayCast;
			if (obj == null)
			{
				hook_CheckItemRayCast val = PlayerController_CheckItemRayCast;
				<>O.<0>__PlayerController_CheckItemRayCast = val;
				obj = (object)val;
			}
			PlayerController.CheckItemRayCast += (hook_CheckItemRayCast)obj;
			object obj2 = <>O.<1>__PlayerController_UseItem;
			if (obj2 == null)
			{
				hook_UseItem val2 = PlayerController_UseItem;
				<>O.<1>__PlayerController_UseItem = val2;
				obj2 = (object)val2;
			}
			PlayerController.UseItem += (hook_UseItem)obj2;
		}

		private static void PlayerController_UseItem(orig_UseItem orig, PlayerController self)
		{
			//IL_0006: 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_001d: Invalid comparison between Unknown and I4
			//IL_002e: 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)
			if (!NetworkBool.op_Implicit(GameManager.LightingManager.IsTransition) && (int)GameManager.State.Current == 2 && (Object)(object)self.Item != (Object)null && !NetworkBool.op_Implicit(self.IsClimbing) && NetworkBool.op_Implicit(self.CanMoveAnimation))
			{
				self.Item.Use();
			}
		}

		private static bool PlayerController_CheckItemRayCast(orig_CheckItemRayCast orig, PlayerController self, Item targetItem)
		{
			//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_0025: Unknown result type (might be due to invalid IL or missing references)
			if (targetItem.Owner == PlayerRef.None)
			{
				GameManager.Instance.gameUI.UpdateInteraction("UI_LOOT_ITEM", Color.white, (InputActionName)0, Array.Empty<object>());
				return true;
			}
			return false;
		}
	}
}