Decompiled source of ClaimChestOpen v1.0.2

Cjayride.ClaimChestOpen.dll

Decompiled 2 weeks 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 HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("assembly_valheim")]
[assembly: TargetFramework(".NETFramework,Version=v4.8.1", FrameworkDisplayName = ".NET Framework 4.8.1")]
[assembly: AssemblyCompany("Cjayride.ClaimChestOpen")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.2.0")]
[assembly: AssemblyInformationalVersion("1.0.2+16dfd3a5b89606430f02ab4b5bb568ec46caf4a2")]
[assembly: AssemblyProduct("Cjayride.ClaimChestOpen")]
[assembly: AssemblyTitle("Cjayride.ClaimChestOpen")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.2.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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 Cjayride.ClaimChestOpen
{
	[BepInPlugin("cjayride.ClaimChestOpen", "Claim Chest Open", "1.0.2")]
	public class Plugin : BaseUnityPlugin
	{
		public const string PluginGuid = "cjayride.ClaimChestOpen";

		public const string PluginName = "Claim Chest Open";

		public const string PluginVersion = "1.0.2";

		private void Awake()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			new Harmony("cjayride.ClaimChestOpen").PatchAll(typeof(ClaimOnInteract));
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Chests claim ownership on your client before they open, so a distant player in the same zone is not in the round trip.");
		}
	}
	[HarmonyPatch(typeof(Container), "Interact")]
	internal static class ClaimOnInteract
	{
		private static void Prefix(Container __instance, Humanoid character, bool hold)
		{
			if (!hold && !((Object)(object)__instance == (Object)null) && !((Object)(object)character == (Object)null) && !((Object)(object)Player.m_localPlayer == (Object)null) && !((Object)(object)character != (Object)(object)Player.m_localPlayer))
			{
				ZNetView nview = __instance.m_nview;
				if (!((Object)(object)nview == (Object)null) && nview.IsValid() && !nview.IsOwner() && !((Object)(object)__instance.m_wagon != (Object)null) && !((Object)(object)((Component)((Component)__instance).transform.root).GetComponent<Ship>() != (Object)null))
				{
					nview.ClaimOwnership();
				}
			}
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}