Decompiled source of OneHandWeaponOnTheHip v1.0.0

OneHandWeaponOnTheHip.dll

Decompiled 4 days ago
using System;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("OneHandWeaponOnTheHip")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("blacks7ar")]
[assembly: AssemblyProduct("OneHandWeaponOnTheHip")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("E3CFC249-0C39-4BAA-82FC-031A350D83CE")]
[assembly: AssemblyFileVersion("1.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[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 OneHandWeaponOnTheHip
{
	[BepInPlugin("blacks7ar.OneHandWeaponOnTheHip", "OneHandWeaponOnTheHip", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		[HarmonyPatch]
		private static class Patch
		{
			[HarmonyPostfix]
			[HarmonyPatch(typeof(ObjectDB), "Awake")]
			private static void Awake_Postfix(ObjectDB __instance)
			{
				//IL_008c: Unknown result type (might be due to invalid IL or missing references)
				if ((Object)(object)__instance == (Object)null || __instance.m_items.Count <= 0 || !_enableMod.Value)
				{
					return;
				}
				foreach (ItemDrop item in from item in __instance.m_items
					select item.GetComponent<ItemDrop>() into component
					where (Object)(object)component != (Object)null && (int)component.m_itemData.m_shared.m_itemType == 3 && (int)component.m_itemData.m_shared.m_skillType != 5
					select component)
				{
					item.m_itemData.m_shared.m_attachOverride = (ItemType)19;
				}
			}

			[HarmonyPostfix]
			[HarmonyPatch(typeof(VisEquipment), "AttachBackItem")]
			private static void AttachBackItem_Postfix(VisEquipment __instance, ref int hash)
			{
				//IL_0044: Unknown result type (might be due to invalid IL or missing references)
				//IL_0056: Unknown result type (might be due to invalid IL or missing references)
				//IL_005d: Invalid comparison between Unknown and I4
				//IL_0075: Unknown result type (might be due to invalid IL or missing references)
				//IL_0099: Unknown result type (might be due to invalid IL or missing references)
				if ((Object)(object)__instance == (Object)null || !__instance.m_isPlayer)
				{
					return;
				}
				GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(hash);
				if (!((Object)(object)itemPrefab == (Object)null))
				{
					ItemDrop component = itemPrefab.GetComponent<ItemDrop>();
					if (!((Object)(object)component == (Object)null) && (int)component.m_itemData.m_shared.m_attachOverride != 0 && (int)component.m_itemData.m_shared.m_attachOverride == 19)
					{
						__instance.m_backTool.localPosition = new Vector3(0.00221f, 0.00275f, 0.00103f);
						__instance.m_backTool.localRotation = new Quaternion(0.59913f, 0.73131f, -0.19993f, 0.25742f);
					}
				}
			}
		}

		private const string modGUID = "blacks7ar.OneHandWeaponOnTheHip";

		public const string modName = "OneHandWeaponOnTheHip";

		public const string modAuthor = "blacks7ar";

		public const string modVersion = "1.0.0";

		public const string modLink = "";

		private static readonly Harmony _harmony = new Harmony("blacks7ar.OneHandWeaponOnTheHip");

		private static ConfigEntry<bool> _enableMod;

		public void Awake()
		{
			((BaseUnityPlugin)this).Config.SaveOnConfigSet = false;
			_enableMod = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enable Mod", true, "Enable/Disables the mod.");
			((BaseUnityPlugin)this).Config.SaveOnConfigSet = true;
			((BaseUnityPlugin)this).Config.Save();
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			_harmony.PatchAll(executingAssembly);
		}

		private void OnDestroy()
		{
			((BaseUnityPlugin)this).Config.Save();
		}
	}
}