Decompiled source of PeakClimbTeammates v1.1.0

plugins/com.github.Alobal.PeakClimbTeammates.dll

Decompiled a day ago
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("com.github.Alobal.PeakClimbTeammates")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyInformationalVersion("1.1.0+8b42054079ab874de12d79b4c229623e8e5cb476")]
[assembly: AssemblyProduct("com.github.Alobal.PeakClimbTeammates")]
[assembly: AssemblyTitle("PeakClimbTeammates")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[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 BepInEx
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class BepInAutoPluginAttribute : Attribute
	{
		public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace BepInEx.Preloader.Core.Patching
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class PatcherAutoPluginAttribute : Attribute
	{
		public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace PeakPunch
{
	[BepInPlugin("com.github.Alobal.PeakClimbTeammates", "PeakClimbTeammates", "1.1.0")]
	public class Plugin : BaseUnityPlugin
	{
		private readonly Harmony _harmony = new Harmony("com.github.Alobal.PeakClimbTeammates");

		public const string Id = "com.github.Alobal.PeakClimbTeammates";

		internal static ManualLogSource Log { get; private set; }

		public static string Name => "PeakClimbTeammates";

		public static string Version => "1.1.0";

		private void Awake()
		{
			Log = ((BaseUnityPlugin)this).Logger;
			Log.LogInfo((object)("Plugin " + Name + " 加载成功!!!!!!!!!!"));
			_harmony.PatchAll();
		}
	}
}
namespace PeakPunch.Properties
{
	[GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
	[DebuggerNonUserCode]
	[CompilerGenerated]
	internal class Resources
	{
		private static ResourceManager resourceMan;

		private static CultureInfo resourceCulture;

		[EditorBrowsable(EditorBrowsableState.Advanced)]
		internal static ResourceManager ResourceManager
		{
			get
			{
				if (resourceMan == null)
				{
					ResourceManager resourceManager = new ResourceManager("PeakPunch.Properties.Resources", typeof(Resources).Assembly);
					resourceMan = resourceManager;
				}
				return resourceMan;
			}
		}

		[EditorBrowsable(EditorBrowsableState.Advanced)]
		internal static CultureInfo Culture
		{
			get
			{
				return resourceCulture;
			}
			set
			{
				resourceCulture = value;
			}
		}

		internal Resources()
		{
		}
	}
}
namespace PeakPunch.patches
{
	[HarmonyPatch(typeof(CharacterInteractible))]
	internal class CharacterInteractiblePatch
	{
		private static readonly Dictionary<int, int> ActiveClimbCarries = new Dictionary<int, int>();

		[HarmonyPatch("GetInteractionText")]
		[HarmonyPostfix]
		private static void GetInteractionTextPatch(ref string __result, CharacterInteractible __instance)
		{
			if (!(__result != "") && CanBeClimbed(__instance.character))
			{
				__result = "爬上去!";
			}
		}

		[HarmonyPatch("Interact")]
		[HarmonyPostfix]
		private static void InteractPatch(CharacterInteractible __instance, ref Character interactor)
		{
			if (!__instance.CarriedByLocalCharacter() && (__instance.IsCannibal() || !__instance.CanBeCarried()) && CanBeClimbed(__instance.character) && CanClimb(interactor))
			{
				__instance.character.refs.carriying.StartCarry(interactor);
			}
		}

		[HarmonyPatch("IsPrimaryInteractible")]
		[HarmonyPostfix]
		private static void IsPrimaryInteractiblePatch(CharacterInteractible __instance, ref bool __result, ref Character interactor)
		{
			if (!__result && CanBeClimbed(__instance.character) && CanClimb(interactor))
			{
				__result = true;
			}
		}

		private static bool CanBeClimbed(Character ___character)
		{
			if (___character.IsLocal)
			{
				return false;
			}
			if (___character.data.dead)
			{
				return false;
			}
			if (___character.player.backpackSlot.hasBackpack)
			{
				return false;
			}
			if (IsCharacterDoingIllegalCarryActions(___character))
			{
				return false;
			}
			if (Object.op_Implicit((Object)(object)___character.data.carriedPlayer))
			{
				return false;
			}
			if (Object.op_Implicit((Object)(object)___character.data.carrier))
			{
				return false;
			}
			if (Object.op_Implicit((Object)(object)___character.data.currentItem) && ___character.data.currentItem.canUseOnFriend)
			{
				return false;
			}
			if (___character.refs.customization.isCannibalizable)
			{
				return false;
			}
			return true;
		}

		private static bool CanClimb(Character ___character)
		{
			if (___character.refs.interactible.CanBeCarried())
			{
				return true;
			}
			if (!___character.IsLocal)
			{
				return false;
			}
			if (___character.data.dead)
			{
				return false;
			}
			if (Object.op_Implicit((Object)(object)___character.data.currentItem))
			{
				return false;
			}
			if (Object.op_Implicit((Object)(object)___character.data.carrier))
			{
				return false;
			}
			if (Object.op_Implicit((Object)(object)___character.data.currentItem) && ___character.data.currentItem.canUseOnFriend)
			{
				return false;
			}
			if (___character.refs.customization.isCannibalizable)
			{
				return false;
			}
			return true;
		}

		[HarmonyPatch(typeof(CharacterCarrying), "RPCA_StartCarry")]
		[HarmonyPostfix]
		private static void RPCA_StartCarryPostfix(Character ___character, PhotonView targetView)
		{
			Character component = ((Component)targetView).GetComponent<Character>();
			if (!((Object)(object)component == (Object)null) && !((Object)(object)___character == (Object)null) && !component.data.fullyPassedOut && !component.data.dead && (Object)(object)component.data.carrier == (Object)(object)___character && (Object)(object)___character.data.carriedPlayer == (Object)(object)component)
			{
				ActiveClimbCarries[((MonoBehaviourPun)component).photonView.ViewID] = ((MonoBehaviourPun)___character).photonView.ViewID;
			}
		}

		[HarmonyPatch(typeof(CharacterCarrying), "Update")]
		[HarmonyPrefix]
		private static bool CharacterCarryingUpdatePrefix(Character ___character)
		{
			Character val = ___character?.data.carriedPlayer;
			if ((Object)(object)val == (Object)null || (Object)(object)___character == (Object)null || !IsClimbCarry(___character, val))
			{
				return true;
			}
			if ((Object)(object)val.data.carrier != (Object)(object)___character || (Object)(object)___character.data.carriedPlayer != (Object)(object)val)
			{
				ForgetClimbCarry(val);
				return true;
			}
			if (val.data.fullyPassedOut)
			{
				ForgetClimbCarry(val);
				return true;
			}
			if (val.data.dead || ___character.data.fullyPassedOut || ___character.data.dead)
			{
				ForgetClimbCarry(val);
				if (___character.refs.view.IsMine)
				{
					___character.refs.carriying.Drop(val);
				}
			}
			return false;
		}

		[HarmonyPatch(typeof(CharacterCarrying), "RPCA_Drop")]
		[HarmonyPostfix]
		private static void RPCA_DropPostfix(PhotonView targetView)
		{
			Character component = ((Component)targetView).GetComponent<Character>();
			if ((Object)(object)component != (Object)null)
			{
				ForgetClimbCarry(component);
			}
		}

		private static bool IsClimbCarry(Character carrier, Character carried)
		{
			if (ActiveClimbCarries.TryGetValue(((MonoBehaviourPun)carried).photonView.ViewID, out var value))
			{
				return value == ((MonoBehaviourPun)carrier).photonView.ViewID;
			}
			return false;
		}

		private static void ForgetClimbCarry(Character carried)
		{
			ActiveClimbCarries.Remove(((MonoBehaviourPun)carried).photonView.ViewID);
		}

		private static bool IsCharacterDoingIllegalCarryActions(Character character)
		{
			if (!character.data.isSprinting && !character.data.isJumping && !character.data.isClimbingAnything && !character.data.isCrouching)
			{
				return character.data.isReaching;
			}
			return true;
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}