using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Threading;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using BuddyClimb.Compatibility;
using BuddyClimb.Configuration;
using BuddyClimb.Gameplay;
using BuddyClimb.Localization;
using BuddyClimb.Patches;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using UnityEngine;
using Zorro.Core.Serizalization;
[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.LandmineHQ.BuddyClimb")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.1.7.0")]
[assembly: AssemblyInformationalVersion("0.1.7+4aea28341231126d4a40edfacd66511abb0542b0")]
[assembly: AssemblyProduct("com.github.LandmineHQ.BuddyClimb")]
[assembly: AssemblyTitle("BuddyClimb")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/LandmineHQ/PeakPunch")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.7.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.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]
[Microsoft.CodeAnalysis.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]
[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 BepInEx
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
[Conditional("CodeGeneration")]
[Microsoft.CodeAnalysis.Embedded]
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")]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class PatcherAutoPluginAttribute : Attribute
{
public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
{
}
}
}
namespace Microsoft.CodeAnalysis
{
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace BuddyClimb
{
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("com.github.LandmineHQ.BuddyClimb", "BuddyClimb", "0.1.7")]
public class Plugin : BaseUnityPlugin
{
public const string Id = "com.github.LandmineHQ.BuddyClimb";
internal static ManualLogSource Log { get; private set; }
public static string Name => "BuddyClimb";
public static string Version => "0.1.7";
private void Awake()
{
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
Log = ((BaseUnityPlugin)this).Logger;
BuddyClimbConfig.Bind(((BaseUnityPlugin)this).Config);
BuddyClimbConfig.EnableHotReload(((BaseUnityPlugin)this).Config);
new Harmony("com.github.LandmineHQ.BuddyClimb").PatchAll(typeof(Plugin).Assembly);
if (ModCompatibility.IsPiggybackLoaded)
{
Log.LogInfo((object)"Piggyback detected; BuddyClimb carry spectate patches are disabled.");
}
Log.LogInfo((object)("Plugin " + Name + " is loaded!"));
}
private void Update()
{
CarriedPlayerDropper.Update();
}
private void OnDestroy()
{
BuddyClimbConfig.DisableHotReload();
}
}
}
namespace BuddyClimb.Patches
{
[HarmonyPatch]
internal static class CarrySpectatePatch
{
[HarmonyPrepare]
private static bool Prepare()
{
return !ModCompatibility.IsPiggybackLoaded;
}
[HarmonyPatch(typeof(MainCameraMovement), "LateUpdate")]
[HarmonyPostfix]
private static void LateUpdatePostfix(MainCameraMovement __instance)
{
if (TryGetBuddyClimbSpectateTarget(out Character spectateTarget) && !__instance.isGodCam && !__instance.isSpectating)
{
MainCamera cam = __instance.cam;
if (!((Object)(object)cam == (Object)null) && !((Object)(object)cam.camOverride != (Object)null))
{
MainCameraMovement.specCharacter = spectateTarget;
__instance.Spectate();
__instance.isSpectating = true;
}
}
}
[HarmonyPatch(typeof(MainCameraMovement), "HandleSpecSelection")]
[HarmonyPrefix]
private static bool HandleSpecSelectionPrefix(MainCameraMovement __instance, ref bool __result)
{
if (!TryGetBuddyClimbSpectateTarget(out Character spectateTarget))
{
return true;
}
MainCameraMovement.specCharacter = spectateTarget;
__result = true;
return false;
}
private static bool TryGetBuddyClimbSpectateTarget(out Character spectateTarget)
{
spectateTarget = null;
Character localCharacter = Character.localCharacter;
if ((Object)(object)localCharacter == (Object)null || (Object)(object)localCharacter.data == (Object)null || !localCharacter.data.isCarried || (Object)(object)localCharacter.data.carrier == (Object)null || localCharacter.data.dead || localCharacter.data.fullyPassedOut || !CharacterCarryingPatch.IsBuddyClimbCarried(localCharacter))
{
return false;
}
spectateTarget = localCharacter;
return true;
}
}
[HarmonyPatch(typeof(CharacterCarrying))]
internal static class CharacterCarryingPatch
{
private static readonly HashSet<int> BuddyClimbCarriedViewIds = new HashSet<int>();
internal static bool IsBuddyClimbCarried(Character character)
{
if ((Object)(object)((character != null) ? ((MonoBehaviourPun)character).photonView : null) != (Object)null)
{
return BuddyClimbCarriedViewIds.Contains(((MonoBehaviourPun)character).photonView.ViewID);
}
return false;
}
[HarmonyPatch("Update")]
[HarmonyPrefix]
private static bool UpdatePrefix(CharacterCarrying __instance)
{
Character val = __instance.character ?? ((Component)__instance).GetComponent<Character>();
if ((Object)(object)val == (Object)null || (Object)(object)((MonoBehaviourPun)val).photonView == (Object)null)
{
return true;
}
Character carriedPlayer = val.data.carriedPlayer;
if ((Object)(object)carriedPlayer == (Object)null || !IsBuddyClimbCarried(carriedPlayer))
{
return true;
}
if ((carriedPlayer.data.dead || val.data.fullyPassedOut || val.data.dead) && val.refs.view.IsMine)
{
__instance.Drop(carriedPlayer);
}
return false;
}
[HarmonyPatch("RPCA_Drop")]
[HarmonyPrefix]
private static bool RPCA_DropPrefix(PhotonView targetView)
{
if ((Object)(object)targetView == (Object)null)
{
return true;
}
BuddyClimbCarriedViewIds.Remove(targetView.ViewID);
return true;
}
[HarmonyPatch("RPCA_Drop")]
[HarmonyPostfix]
private static void RPCA_DropPostfix(PhotonView targetView)
{
if ((Object)(object)targetView != (Object)null)
{
CarryInteractionProxy.Disable(((Component)targetView).GetComponent<Character>());
}
}
[HarmonyPatch("RPCA_StartCarry")]
[HarmonyPrefix]
private static bool RPCA_StartCarryPrefix(CharacterCarrying __instance, PhotonView targetView)
{
if ((Object)(object)targetView == (Object)null)
{
return false;
}
Character val = __instance.character ?? ((Component)__instance).GetComponent<Character>();
if ((Object)(object)val == (Object)null)
{
return false;
}
Character component = ((Component)targetView).GetComponent<Character>();
if ((Object)(object)component == (Object)null)
{
return false;
}
if (component.data.fullyPassedOut || component.data.dead)
{
return true;
}
if ((Object)(object)val.data.carriedPlayer != (Object)null)
{
__instance.Drop(val.data.carriedPlayer);
return false;
}
component.refs.carriying.ToggleCarryPhysics(true);
component.data.isCarried = true;
val.data.carriedPlayer = component;
component.data.carrier = val;
BuddyClimbCarriedViewIds.Add(((MonoBehaviourPun)component).photonView.ViewID);
foreach (Character allPlayerCharacter in PlayerHandler.GetAllPlayerCharacters())
{
allPlayerCharacter.refs.afflictions.UpdateWeight();
}
return false;
}
[HarmonyPatch("RPCA_StartCarry")]
[HarmonyPostfix]
private static void RPCA_StartCarryPostfix(PhotonView targetView)
{
if ((Object)(object)targetView != (Object)null)
{
Character component = ((Component)targetView).GetComponent<Character>();
if (component != null && component.data.isCarried)
{
CarryInteractionProxy.Enable(component);
}
}
}
}
[HarmonyPatch(typeof(CharacterInteractible))]
internal static class CharacterInteractiblePatch
{
[HarmonyPatch("GetInteractionText")]
[HarmonyPostfix]
private static void GetInteractionTextPatch(ref string __result, CharacterInteractible __instance)
{
Character localCharacter = Character.localCharacter;
if (IsBuddyClimbDropInteraction(__instance.character, localCharacter))
{
__result = string.Empty;
}
else if (!(__result != string.Empty) && CanStartClimb(__instance.character, localCharacter))
{
BuddyClimbTextKey key = (BackpackCarryTransfer.WillDropCarriedBackpack(__instance.character, localCharacter) ? BuddyClimbTextKey.ClimbOnTeammateDropBackpack : BuddyClimbTextKey.ClimbOnTeammate);
__result = BuddyClimbLocalization.Get(key);
}
}
[HarmonyPatch("Interact")]
[HarmonyPrefix]
private static bool InteractPatch(CharacterInteractible __instance, ref Character interactor)
{
if (IsBuddyClimbDropInteraction(__instance.character, interactor))
{
return false;
}
if (__instance.CarriedByLocalCharacter() || __instance.IsCannibal() || __instance.CanBeCarried())
{
return true;
}
return !TryStartClimb(__instance.character, interactor);
}
[HarmonyPatch("IsInteractible")]
[HarmonyPostfix]
private static void IsInteractiblePatch(CharacterInteractible __instance, ref bool __result, ref Character interactor)
{
if (IsBuddyClimbDropInteraction(__instance.character, interactor))
{
__result = false;
}
else if (!__result && CanStartClimb(__instance.character, interactor))
{
__result = true;
}
}
[HarmonyPatch("IsPrimaryInteractible")]
[HarmonyPostfix]
private static void IsPrimaryInteractiblePatch(CharacterInteractible __instance, ref bool __result, ref Character interactor)
{
if (IsBuddyClimbDropInteraction(__instance.character, interactor))
{
__result = false;
}
else if (!__result && CanStartClimb(__instance.character, interactor))
{
__result = true;
}
}
private static bool CanBeClimbed(Character character)
{
if ((Object)(object)character == (Object)null)
{
return false;
}
if (character.isBot)
{
return false;
}
if (character.IsLocal)
{
return false;
}
if (character.data.dead)
{
return false;
}
if (character.player.backpackSlot.hasBackpack && !BackpackCarryTransfer.AllowsCarrierBackpack)
{
return false;
}
if (IsCharacterDoingIllegalCarryActions(character))
{
return false;
}
if (character.data.IsCarryingCharacter)
{
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 ((Object)(object)character == (Object)null)
{
return false;
}
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 (character.data.isCarried)
{
return false;
}
if (character.refs.customization.isCannibalizable)
{
return false;
}
return true;
}
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;
}
private static bool TryStartClimb(Character character, Character interactor)
{
if (!CanStartClimb(character, interactor))
{
return false;
}
if (BackpackCarryTransfer.WillDropCarriedBackpack(character, interactor) && (!BackpackCarryTransfer.CanTransferCarrierBackpack(character, interactor) || !BackpackCarryTransfer.TryDropCarriedBackpackSnapshot(interactor)))
{
return false;
}
if (!BackpackCarryTransfer.TryTransferCarrierBackpack(character, interactor))
{
return false;
}
StartCarry(character, interactor);
return true;
}
private static bool CanStartClimb(Character carrier, Character carried)
{
if (CanBeClimbed(carrier) && CanClimb(carried))
{
return CanCreateCarryLink(carrier, carried);
}
return false;
}
private static bool CanCreateCarryLink(Character carrier, Character carried)
{
if ((Object)(object)carrier == (Object)null || (Object)(object)carried == (Object)null)
{
return false;
}
Character val = carrier;
while (true)
{
if ((Object)(object)val == (Object)(object)carried)
{
return false;
}
Character val2 = val.data?.carrier;
if (val2 == null)
{
break;
}
val = val2;
}
return true;
}
private static bool IsBuddyClimbDropInteraction(Character character, Character interactor)
{
if ((Object)(object)character != (Object)null && (Object)(object)interactor != (Object)null && (Object)(object)character.data.carrier == (Object)(object)interactor)
{
return CharacterCarryingPatch.IsBuddyClimbCarried(character);
}
return false;
}
private static void StartCarry(Character carrier, Character carried)
{
((MonoBehaviourPun)carrier).photonView.RPC("RPCA_StartCarry", (RpcTarget)0, new object[1] { ((MonoBehaviourPun)carried).photonView });
}
}
[HarmonyPatch(typeof(CharacterMovement))]
internal static class CharacterMovementPatch
{
[HarmonyPatch("TryToJump")]
[HarmonyPrefix]
private static bool TryToJumpPrefix(CharacterMovement __instance)
{
return !CarriedPlayerDropper.HandleJumpAttempt(__instance.character);
}
}
[HarmonyPatch(typeof(Character))]
internal static class CharacterPatch
{
[HarmonyPatch("Start")]
[HarmonyPostfix]
private static void StartPostfix(Character __instance)
{
BackpackSnapshotDropRpc.Ensure(__instance);
}
}
}
namespace BuddyClimb.Localization
{
internal enum BuddyClimbTextKey
{
ClimbOnTeammate,
ClimbOnTeammateDropBackpack
}
internal static class BuddyClimbLocalization
{
private enum SupportedLanguage
{
English,
Chinese
}
private static readonly IReadOnlyDictionary<BuddyClimbTextKey, string> EnglishText = new Dictionary<BuddyClimbTextKey, string>
{
[BuddyClimbTextKey.ClimbOnTeammate] = "Climb on!",
[BuddyClimbTextKey.ClimbOnTeammateDropBackpack] = "Climb on! (drop backpack)"
};
private static readonly IReadOnlyDictionary<BuddyClimbTextKey, string> ChineseText = new Dictionary<BuddyClimbTextKey, string>
{
[BuddyClimbTextKey.ClimbOnTeammate] = "爬上去!",
[BuddyClimbTextKey.ClimbOnTeammateDropBackpack] = "爬上去!(丢弃背包)"
};
internal static string Get(BuddyClimbTextKey key)
{
SupportedLanguage currentLanguage = GetCurrentLanguage();
IReadOnlyDictionary<BuddyClimbTextKey, string> readOnlyDictionary = ((currentLanguage != SupportedLanguage.Chinese) ? EnglishText : ChineseText);
IReadOnlyDictionary<BuddyClimbTextKey, string> readOnlyDictionary2 = readOnlyDictionary;
if (readOnlyDictionary2.TryGetValue(key, out var value))
{
return value;
}
return EnglishText[key];
}
private static SupportedLanguage GetCurrentLanguage()
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Invalid comparison between Unknown and I4
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Invalid comparison between Unknown and I4
Language cURRENT_LANGUAGE = LocalizedText.CURRENT_LANGUAGE;
if ((int)cURRENT_LANGUAGE != 9)
{
if ((int)cURRENT_LANGUAGE == 10)
{
return SupportedLanguage.Chinese;
}
return SupportedLanguage.English;
}
return SupportedLanguage.Chinese;
}
}
}
namespace BuddyClimb.Gameplay
{
internal static class BackpackCarryTransfer
{
private static readonly byte BackpackSlotIndex = 3;
internal static bool AllowsCarrierBackpack => BuddyClimbConfig.EnableBackpackTransfer.Value;
internal static bool WillDropCarriedBackpack(Character carrier, Character carried)
{
if (AllowsCarrierBackpack && (Object)(object)carrier != (Object)null && (Object)(object)carried != (Object)null && HasBackpack(carrier))
{
return HasBackpack(carried);
}
return false;
}
internal static bool CanTransferCarrierBackpack(Character carrier, Character carried)
{
if (!AllowsCarrierBackpack || (Object)(object)carrier == (Object)null || (Object)(object)carried == (Object)null || !HasBackpack(carrier))
{
return true;
}
Player player = carrier.player;
Player player2 = carried.player;
if (CanSyncInventory(player))
{
return CanSyncInventory(player2);
}
return false;
}
internal static bool TryDropCarriedBackpackSnapshot(Character carried)
{
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)carried == (Object)null || !HasBackpack(carried))
{
return true;
}
CharacterItems items = carried.refs.items;
if ((Object)(object)items == (Object)null || (Object)(object)items.photonView == (Object)null)
{
Plugin.Log.LogWarning((object)("Unable to drop " + carried.characterName + "'s backpack because CharacterItems is unavailable."));
return false;
}
BackpackSlot backpackSlot = carried.player.backpackSlot;
EnsureSnapshotDropRpc(carried).DropBackpackSnapshot(((ItemSlot)backpackSlot).GetPrefabName(), ((ItemSlot)backpackSlot).data, GetBackpackDropPosition(carried));
((ItemSlot)backpackSlot).EmptyOut();
carried.refs.afflictions.UpdateWeight();
return true;
}
internal static bool TryTransferCarrierBackpack(Character carrier, Character carried)
{
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Expected O, but got Unknown
if (!AllowsCarrierBackpack || (Object)(object)carrier == (Object)null || (Object)(object)carried == (Object)null || !HasBackpack(carrier))
{
return true;
}
Player player = carrier.player;
Player player2 = carried.player;
if (!CanSyncInventory(player) || !CanSyncInventory(player2))
{
Plugin.Log.LogWarning((object)"Skipping backpack transfer because a Player inventory reference is unavailable.");
return false;
}
if (HasBackpack(carried))
{
Plugin.Log.LogWarning((object)("Skipping backpack transfer because " + carried.characterName + " is still wearing a backpack."));
return false;
}
BackpackSlot backpackSlot = player.backpackSlot;
player2.backpackSlot = backpackSlot;
player.backpackSlot = new BackpackSlot(BackpackSlotIndex);
SyncInventory(player2);
SyncInventory(player);
return true;
}
private static bool HasBackpack(Character character)
{
return (character.player?.backpackSlot)?.hasBackpack ?? false;
}
private static Vector3 GetBackpackDropPosition(Character character)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
try
{
return character.Center + Vector3.up * 0.5f;
}
catch
{
return ((Component)character).transform.position + Vector3.up * 0.5f;
}
}
private static void SyncInventory(Player player)
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
byte[] array = IBinarySerializable.ToManagedArray<InventorySyncData>(new InventorySyncData(player.itemSlots, player.backpackSlot, player.tempFullSlot));
((MonoBehaviourPun)player).photonView.RPC("SyncInventoryRPC", (RpcTarget)0, new object[2] { array, true });
}
private static bool CanSyncInventory(Player player)
{
if ((Object)(object)player != (Object)null && (Object)(object)((MonoBehaviourPun)player).photonView != (Object)null && player.itemSlots != null && player.backpackSlot != null)
{
return player.tempFullSlot != null;
}
return false;
}
private static BackpackSnapshotDropRpc EnsureSnapshotDropRpc(Character character)
{
return BackpackSnapshotDropRpc.Ensure(character);
}
}
internal sealed class BackpackSnapshotDropRpc : MonoBehaviour
{
internal static BackpackSnapshotDropRpc Ensure(Character character)
{
BackpackSnapshotDropRpc backpackSnapshotDropRpc = ((Component)character).GetComponent<BackpackSnapshotDropRpc>();
if ((Object)(object)backpackSnapshotDropRpc == (Object)null)
{
backpackSnapshotDropRpc = ((Component)character).gameObject.AddComponent<BackpackSnapshotDropRpc>();
((MonoBehaviourPun)character).photonView.RefreshRpcMonoBehaviourCache();
}
return backpackSnapshotDropRpc;
}
internal void DropBackpackSnapshot(string prefabName, ItemInstanceData backpackData, Vector3 dropPosition)
{
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
PhotonView component = ((Component)this).GetComponent<PhotonView>();
if ((Object)(object)component == (Object)null)
{
Plugin.Log.LogWarning((object)"Unable to drop backpack snapshot because the character PhotonView is unavailable.");
return;
}
component.RPC("RPCA_DropBuddyClimbBackpackSnapshot", (RpcTarget)2, new object[3] { prefabName, backpackData, dropPosition });
}
[PunRPC]
private void RPCA_DropBuddyClimbBackpackSnapshot(string prefabName, ItemInstanceData backpackData, Vector3 dropPosition)
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
if (PhotonNetwork.IsMasterClient && !string.IsNullOrEmpty(prefabName))
{
PhotonView component = PhotonNetwork.Instantiate("0_Items/" + prefabName, dropPosition, Quaternion.identity, (byte)0, (object[])null).GetComponent<PhotonView>();
component.RPC("SetItemInstanceDataRPC", (RpcTarget)0, new object[1] { backpackData });
component.RPC("SetKinematicRPC", (RpcTarget)0, new object[3]
{
false,
((Component)component).transform.position,
((Component)component).transform.rotation
});
CharacterItems val = ((Component)this).GetComponent<Character>()?.refs.items;
if ((Object)(object)val != (Object)null)
{
val.droppedItems.Add(component);
}
}
}
}
internal static class CarriedPlayerDropper
{
private static int dropInputConsumedFrame = -1;
internal static void Update()
{
if (dropInputConsumedFrame != Time.frameCount && Input.GetKeyDown((KeyCode)32))
{
TryDropLocalPlayer(Character.localCharacter);
}
}
internal static bool HandleJumpAttempt(Character character)
{
if ((Object)(object)character == (Object)null || !character.IsLocal)
{
return false;
}
if (dropInputConsumedFrame == Time.frameCount)
{
ClearJumpInput(character);
return true;
}
return TryDropLocalPlayer(character);
}
private static bool TryDropLocalPlayer(Character localCharacter)
{
if (!CanRequestDrop(localCharacter))
{
return false;
}
CharacterCarrying carriying = localCharacter.data.carrier.refs.carriying;
if ((Object)(object)carriying == (Object)null)
{
return false;
}
ClearJumpInput(localCharacter);
carriying.Drop(localCharacter);
ClearJumpInput(localCharacter);
dropInputConsumedFrame = Time.frameCount;
return true;
}
private static bool CanRequestDrop(Character character)
{
if ((Object)(object)character != (Object)null && character.data.isCarried && (Object)(object)character.data.carrier != (Object)null && !character.data.dead && !character.data.passedOut && !character.data.fullyPassedOut)
{
return CharacterCarryingPatch.IsBuddyClimbCarried(character);
}
return false;
}
private static void ClearJumpInput(Character character)
{
if (!((Object)(object)character.input == (Object)null))
{
character.input.jumpWasPressed = false;
character.input.jumpIsPressed = false;
}
}
}
internal static class CarryInteractionProxy
{
private const string ProxyName = "BuddyClimbInteractionProxy";
private const float ProxyRadius = 0.75f;
internal static void Enable(Character character)
{
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Expected O, but got Unknown
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)character == (Object)null)
{
return;
}
Transform proxyParent = GetProxyParent(character);
if (!((Object)(object)proxyParent == (Object)null))
{
Transform val = proxyParent.Find("BuddyClimbInteractionProxy");
if ((Object)(object)val != (Object)null)
{
((Component)val).gameObject.SetActive(true);
return;
}
GameObject val2 = new GameObject("BuddyClimbInteractionProxy");
val2.transform.SetParent(proxyParent, false);
val2.transform.localPosition = Vector3.zero;
val2.transform.localRotation = Quaternion.identity;
val2.transform.localScale = Vector3.one;
int num = LayerMask.NameToLayer("Character");
val2.layer = ((num >= 0) ? num : ((Component)character).gameObject.layer);
SphereCollider val3 = val2.AddComponent<SphereCollider>();
((Collider)val3).isTrigger = true;
val3.radius = 0.75f;
}
}
internal static void Disable(Character character)
{
if (!((Object)(object)character == (Object)null))
{
Transform proxyParent = GetProxyParent(character);
Transform val = proxyParent.Find("BuddyClimbInteractionProxy");
if (val != null)
{
Object.Destroy((Object)(object)((Component)val).gameObject);
}
}
}
private static Transform GetProxyParent(Character character)
{
Bodypart bodypart = character.GetBodypart((BodypartType)2);
if ((Object)(object)bodypart != (Object)null)
{
return ((Component)bodypart).transform;
}
return ((Component)character).transform;
}
}
}
namespace BuddyClimb.Configuration
{
internal static class BuddyClimbConfig
{
private const int HotReloadDebounceMilliseconds = 250;
private static readonly object HotReloadLock = new object();
private static FileSystemWatcher? configWatcher;
private static ConfigFile? configFile;
private static Timer? reloadTimer;
internal static ConfigEntry<bool> EnableBackpackTransfer { get; private set; } = null;
internal static void Bind(ConfigFile config)
{
EnableBackpackTransfer = config.Bind<bool>("Backpack", "EnableBackpackTransfer", false, "Allow climbing onto players who are wearing a backpack. When enabled, the carrier's backpack is moved to the carried player; if the carried player already has a backpack, their old backpack is dropped first.");
}
internal static void EnableHotReload(ConfigFile config)
{
DisableHotReload();
configFile = config;
string directoryName = Path.GetDirectoryName(config.ConfigFilePath);
string fileName = Path.GetFileName(config.ConfigFilePath);
if (string.IsNullOrEmpty(directoryName) || string.IsNullOrEmpty(fileName) || !Directory.Exists(directoryName))
{
Plugin.Log.LogWarning((object)("Config hot reload is disabled because the config directory is unavailable: " + config.ConfigFilePath));
return;
}
reloadTimer = new Timer(ReloadConfigFromTimer);
configWatcher = new FileSystemWatcher(directoryName, fileName)
{
IncludeSubdirectories = false,
NotifyFilter = (NotifyFilters.FileName | NotifyFilters.Size | NotifyFilters.LastWrite | NotifyFilters.CreationTime)
};
configWatcher.Changed += OnConfigFileChanged;
configWatcher.Created += OnConfigFileChanged;
configWatcher.Renamed += OnConfigFileChanged;
configWatcher.EnableRaisingEvents = true;
}
internal static void DisableHotReload()
{
if (configWatcher != null)
{
configWatcher.EnableRaisingEvents = false;
configWatcher.Changed -= OnConfigFileChanged;
configWatcher.Created -= OnConfigFileChanged;
configWatcher.Renamed -= OnConfigFileChanged;
configWatcher.Dispose();
configWatcher = null;
}
lock (HotReloadLock)
{
reloadTimer?.Dispose();
reloadTimer = null;
configFile = null;
}
}
private static void OnConfigFileChanged(object sender, FileSystemEventArgs args)
{
lock (HotReloadLock)
{
reloadTimer?.Change(250, -1);
}
}
private static void ReloadConfigFromTimer(object? state)
{
ConfigFile val;
lock (HotReloadLock)
{
val = configFile;
}
if (val == null)
{
return;
}
try
{
val.Reload();
Plugin.Log.LogInfo((object)"Reloaded BuddyClimb config from disk.");
}
catch (Exception ex)
{
Plugin.Log.LogWarning((object)("Failed to reload BuddyClimb config: " + ex.Message));
}
}
}
}
namespace BuddyClimb.Compatibility
{
internal static class ModCompatibility
{
internal const string PiggybackPluginId = "nakazora.peak.piggyback";
internal static bool IsPiggybackLoaded => Chainloader.PluginInfos.ContainsKey("nakazora.peak.piggyback");
}
}
namespace System.Diagnostics.CodeAnalysis
{
[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class ConstantExpectedAttribute : Attribute
{
public object? Min { get; set; }
public object? Max { get; set; }
}
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Delegate, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class ExperimentalAttribute : Attribute
{
public string DiagnosticId { get; }
public string? UrlFormat { get; set; }
public ExperimentalAttribute(string diagnosticId)
{
DiagnosticId = diagnosticId;
}
}
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)]
[ExcludeFromCodeCoverage]
internal sealed class MemberNotNullAttribute : Attribute
{
public string[] Members { get; }
public MemberNotNullAttribute(string member)
{
Members = new string[1] { member };
}
public MemberNotNullAttribute(params string[] members)
{
Members = members;
}
}
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)]
[ExcludeFromCodeCoverage]
internal sealed class MemberNotNullWhenAttribute : Attribute
{
public bool ReturnValue { get; }
public string[] Members { get; }
public MemberNotNullWhenAttribute(bool returnValue, string member)
{
ReturnValue = returnValue;
Members = new string[1] { member };
}
public MemberNotNullWhenAttribute(bool returnValue, params string[] members)
{
ReturnValue = returnValue;
Members = members;
}
}
[AttributeUsage(AttributeTargets.Constructor, AllowMultiple = false, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class SetsRequiredMembersAttribute : Attribute
{
}
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class StringSyntaxAttribute : Attribute
{
public const string CompositeFormat = "CompositeFormat";
public const string DateOnlyFormat = "DateOnlyFormat";
public const string DateTimeFormat = "DateTimeFormat";
public const string EnumFormat = "EnumFormat";
public const string GuidFormat = "GuidFormat";
public const string Json = "Json";
public const string NumericFormat = "NumericFormat";
public const string Regex = "Regex";
public const string TimeOnlyFormat = "TimeOnlyFormat";
public const string TimeSpanFormat = "TimeSpanFormat";
public const string Uri = "Uri";
public const string Xml = "Xml";
public string Syntax { get; }
public object?[] Arguments { get; }
public StringSyntaxAttribute(string syntax)
{
Syntax = syntax;
Arguments = new object[0];
}
public StringSyntaxAttribute(string syntax, params object?[] arguments)
{
Syntax = syntax;
Arguments = arguments;
}
}
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class UnscopedRefAttribute : Attribute
{
}
}
namespace System.Runtime.Versioning
{
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Delegate, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class RequiresPreviewFeaturesAttribute : Attribute
{
public string? Message { get; }
public string? Url { get; set; }
public RequiresPreviewFeaturesAttribute()
{
}
public RequiresPreviewFeaturesAttribute(string? message)
{
Message = message;
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class CallerArgumentExpressionAttribute : Attribute
{
public string ParameterName { get; }
public CallerArgumentExpressionAttribute(string parameterName)
{
ParameterName = parameterName;
}
}
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Interface, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class CollectionBuilderAttribute : Attribute
{
public Type BuilderType { get; }
public string MethodName { get; }
public CollectionBuilderAttribute(Type builderType, string methodName)
{
BuilderType = builderType;
MethodName = methodName;
}
}
[AttributeUsage(AttributeTargets.All, AllowMultiple = true, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class CompilerFeatureRequiredAttribute : Attribute
{
public const string RefStructs = "RefStructs";
public const string RequiredMembers = "RequiredMembers";
public string FeatureName { get; }
public bool IsOptional { get; set; }
public CompilerFeatureRequiredAttribute(string featureName)
{
FeatureName = featureName;
}
}
[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class InterpolatedStringHandlerArgumentAttribute : Attribute
{
public string[] Arguments { get; }
public InterpolatedStringHandlerArgumentAttribute(string argument)
{
Arguments = new string[1] { argument };
}
public InterpolatedStringHandlerArgumentAttribute(params string[] arguments)
{
Arguments = arguments;
}
}
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, AllowMultiple = false, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class InterpolatedStringHandlerAttribute : Attribute
{
}
[EditorBrowsable(EditorBrowsableState.Never)]
[ExcludeFromCodeCoverage]
internal static class IsExternalInit
{
}
[AttributeUsage(AttributeTargets.Method, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class ModuleInitializerAttribute : Attribute
{
}
[AttributeUsage(AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property, AllowMultiple = false, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class OverloadResolutionPriorityAttribute : Attribute
{
public int Priority { get; }
public OverloadResolutionPriorityAttribute(int priority)
{
Priority = priority;
}
}
[AttributeUsage(AttributeTargets.Parameter, Inherited = true, AllowMultiple = false)]
[ExcludeFromCodeCoverage]
internal sealed class ParamCollectionAttribute : Attribute
{
}
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class RequiredMemberAttribute : Attribute
{
}
[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
[EditorBrowsable(EditorBrowsableState.Never)]
[ExcludeFromCodeCoverage]
internal sealed class RequiresLocationAttribute : Attribute
{
}
[AttributeUsage(AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Event | AttributeTargets.Interface, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class SkipLocalsInitAttribute : Attribute
{
}
}