using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using UnityEngine;
using UnityEngine.InputSystem;
using Zorro.Core;
[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.LengSword.RemoteAliveHelper")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.5.0")]
[assembly: AssemblyInformationalVersion("1.0.5+9b2613493b88db35c6d6f58e0499667276f63f26")]
[assembly: AssemblyProduct("com.github.LengSword.RemoteAliveHelper")]
[assembly: AssemblyTitle("RemoteAliveHelper")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.5.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.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")]
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 RemoteAliveHelper
{
[BepInPlugin("com.github.LengSword.RemoteAliveHelper", "RemoteAliveHelper", "1.0.5")]
public class RemoteAliveHelperPlugin : BaseUnityPlugin
{
private MainCameraMovement? cameraMovement;
public const string Id = "com.github.LengSword.RemoteAliveHelper";
internal static ManualLogSource Logger { get; private set; }
internal static bool IsManualSpectating { get; private set; }
public static string Name => "RemoteAliveHelper";
public static string Version => "1.0.5";
private void Awake()
{
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Expected O, but got Unknown
Logger = ((BaseUnityPlugin)this).Logger;
Logger.LogInfo((object)("Plugin " + Name + " is loaded!"));
PluginConfig.Initialize(((BaseUnityPlugin)this).Config, Logger);
Harmony val = new Harmony("com.github.LengSword.RemoteAliveHelper");
val.PatchAll();
}
private void Update()
{
if (IsTogglePressed() && !((Object)(object)Character.localCharacter == (Object)null) && !((Object)(object)Character.localCharacter.data == (Object)null) && !Character.localCharacter.data.fullyPassedOut)
{
if ((Object)(object)cameraMovement == (Object)null)
{
cameraMovement = Singleton<MainCameraMovement>.Instance;
}
if (!((Object)(object)cameraMovement == (Object)null))
{
IsManualSpectating = !IsManualSpectating;
}
}
}
private bool IsTogglePressed()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
return Input.GetKeyDown(PluginConfig.ToggleKeyConfig.Value);
}
}
public static class PluginConfig
{
internal static ConfigEntry<KeyCode> ToggleKeyConfig { get; private set; }
internal static ConfigEntry<KeyCode> SpectateLeftKeyConfig { get; private set; }
internal static ConfigEntry<KeyCode> SpectateRightKeyConfig { get; private set; }
internal static ConfigEntry<bool> EnableRemoteModeConfig { get; private set; }
internal static ConfigEntry<bool> ShowGhostConfig { get; private set; }
public static void Initialize(ConfigFile config, ManualLogSource logger)
{
ToggleKeyConfig = config.Bind<KeyCode>("Keybinds", "KeyboardToggle", (KeyCode)291, "Keyboard key for toggling spectator mode on/off");
SpectateLeftKeyConfig = config.Bind<KeyCode>("Keybinds", "SpectateLeft", (KeyCode)91, "Keyboard key for swapping the left spectator");
SpectateRightKeyConfig = config.Bind<KeyCode>("Keybinds", "SpectateRight", (KeyCode)93, "Keyboard key for swapping the right spectator");
EnableRemoteModeConfig = config.Bind<bool>("General", "EnableRemoteMode", false, "Enable remote mode (can remote feeding)");
ShowGhostConfig = config.Bind<bool>("General", "ShowGhost", false, "Show your ghost on spectating (can talk with observed player)");
logger.LogInfo((object)"Plugin Config Loaded.");
}
}
}
namespace RemoteAliveHelper.Patches
{
[HarmonyPatch(typeof(MainCameraMovement), "LateUpdate")]
internal sealed class MainCameraMovementLateUpdatePatch
{
private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
{
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: Expected O, but got Unknown
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: Expected O, but got Unknown
List<CodeInstruction> list = new List<CodeInstruction>(instructions);
FieldInfo fieldInfo = AccessTools.Field(typeof(Character), "localCharacter");
FieldInfo fieldInfo2 = AccessTools.Field(typeof(Character), "data");
FieldInfo fieldInfo3 = AccessTools.Field(typeof(CharacterData), "fullyPassedOut");
MethodInfo methodInfo = AccessTools.PropertyGetter(typeof(RemoteAliveHelperPlugin), "IsManualSpectating");
for (int i = 0; i < list.Count - 4; i++)
{
if (CodeInstructionExtensions.LoadsField(list[i], fieldInfo, false) && CodeInstructionExtensions.LoadsField(list[i + 1], fieldInfo2, false) && CodeInstructionExtensions.LoadsField(list[i + 2], fieldInfo3, false))
{
list.InsertRange(i + 3, new <>z__ReadOnlyArray<CodeInstruction>((CodeInstruction[])(object)new CodeInstruction[2]
{
new CodeInstruction(OpCodes.Call, (object)methodInfo),
new CodeInstruction(OpCodes.Or, (object)null)
}));
break;
}
}
return list;
}
}
[HarmonyPatch(typeof(MainCameraMovement), "HandleSpecSelection")]
internal sealed class MainCameraMovementHandleSpecSelectionPatch
{
private static void Postfix(ref bool __result, MainCameraMovement __instance)
{
if (RemoteAliveHelperPlugin.IsManualSpectating && (Object)(object)MainCameraMovement.specCharacter == (Object)(object)Character.localCharacter)
{
if (Character.localCharacter.input.spectateLeftWasPressed && __instance.sinceSwitch > 0.2f)
{
Transitions.instance.PlayTransition((TransitionType)3, (Action)__instance.SwapSpecPlayerLeft, 5f, 5f);
__instance.sinceSwitch = 0f;
}
if (Character.localCharacter.input.spectateRightWasPressed && __instance.sinceSwitch > 0.2f)
{
Transitions.instance.PlayTransition((TransitionType)3, (Action)__instance.SwapSpecPlayerRight, 5f, 5f);
__instance.sinceSwitch = 0f;
}
__result = (Object)(object)MainCameraMovement.specCharacter != (Object)null;
}
}
}
[HarmonyPatch(typeof(MainCameraMovement), "Spectate")]
internal sealed class MainCameraMovementSpectateGhostPatch
{
internal static bool IsShowGhostActive
{
get
{
if (RemoteAliveHelperPlugin.IsManualSpectating)
{
return PluginConfig.ShowGhostConfig.Value;
}
return false;
}
}
private static void Postfix()
{
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
if (IsShowGhostActive && !((Object)(object)MainCameraMovement.specCharacter == (Object)(object)Character.localCharacter) && !Character.localCharacter.data.dead)
{
PlayerGhost val = Character.localCharacter.Ghost;
if ((Object)(object)val == (Object)null)
{
val = PhotonNetwork.Instantiate("PlayerGhost", Vector3.zero, Quaternion.identity, (byte)0, (object[])null).GetComponent<PlayerGhost>();
val.m_view.RPC("RPCA_InitGhost", (RpcTarget)3, new object[2]
{
Character.localCharacter.refs.view,
MainCameraMovement.specCharacter.refs.view
});
}
if ((Object)(object)val.m_target != (Object)(object)MainCameraMovement.specCharacter)
{
val.m_view.RPC("RPCA_SetTarget", (RpcTarget)3, new object[1] { MainCameraMovement.specCharacter.refs.view });
}
}
}
}
[HarmonyPatch(typeof(CharacterInput), "Sample")]
internal sealed class CharacterInputSamplePatch
{
private static void Prefix(ref bool playerMovementActive)
{
if (RemoteAliveHelperPlugin.IsManualSpectating)
{
playerMovementActive = false;
}
}
private static void Postfix(CharacterInput __instance)
{
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: 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_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 (RemoteAliveHelperPlugin.IsManualSpectating)
{
__instance.ResetInput();
if (InteractionPatches.IsRemoteModeActive)
{
__instance.useSecondaryIsPressed = CharacterInput.action_useSecondary.IsPressed();
__instance.useSecondaryWasReleased = CharacterInput.action_useSecondary.WasReleasedThisFrame();
}
InputAction action_look = CharacterInput.action_look;
__instance.lookInput = ((action_look != null) ? action_look.ReadValue<Vector2>() : Vector2.zero);
__instance.spectateLeftWasPressed = Input.GetKeyDown(PluginConfig.SpectateLeftKeyConfig.Value);
__instance.spectateRightWasPressed = Input.GetKeyDown(PluginConfig.SpectateRightKeyConfig.Value);
__instance.scrollInput = Input.mouseScrollDelta.y;
}
}
}
[HarmonyPatch(typeof(GUIManager), "UpdateSpectate")]
internal sealed class GUIManagerUpdateSpectatePatch
{
private static void Postfix(GUIManager __instance)
{
if (RemoteAliveHelperPlugin.IsManualSpectating && Object.op_Implicit((Object)(object)__instance.currentSpecCharacter))
{
__instance.spectatingObject.SetActive(true);
__instance.spectatingInputs.SetActive(true);
}
}
}
[HarmonyPatch]
internal sealed class InteractionPatches
{
private static float originalDistance;
internal static bool IsRemoteModeActive
{
get
{
if (RemoteAliveHelperPlugin.IsManualSpectating)
{
return PluginConfig.EnableRemoteModeConfig.Value;
}
return false;
}
}
[HarmonyPatch(typeof(Interaction), "DoInteractableRaycasts")]
[HarmonyPrefix]
private static bool DoInteractableRaycastsPrefix(Interaction __instance)
{
if (!IsRemoteModeActive)
{
return true;
}
originalDistance = __instance.distance;
__instance.distance = float.MaxValue;
return true;
}
[HarmonyPatch(typeof(Interaction), "DoInteractableRaycasts")]
[HarmonyPostfix]
private static void DoInteractableRaycastsPostfix(Interaction __instance)
{
if (IsRemoteModeActive)
{
__instance.distance = originalDistance;
}
}
[HarmonyPatch(typeof(CharacterInteractible), "IsSecondaryInteractible")]
[HarmonyPrefix]
private static bool IsSecondaryInteractiblePrefix(ref bool __result, CharacterInteractible __instance)
{
if (!IsRemoteModeActive)
{
return true;
}
if ((Object)(object)__instance.character != (Object)(object)MainCameraMovement.specCharacter)
{
__result = false;
return false;
}
if (!__instance.HasItemCanUseOnFriend())
{
__result = false;
return false;
}
__result = true;
return false;
}
[HarmonyPatch(typeof(BackpackWheel), "Update")]
[HarmonyPrefix]
private static bool DisableDistanceCheck(BackpackWheel __instance)
{
//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
//IL_0102: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
if (!IsRemoteModeActive)
{
return true;
}
if (!Character.localCharacter.input.interactIsPressed)
{
__instance.Choose();
GUIManager.instance.CloseBackpackWheel();
return false;
}
if (__instance.chosenSlice.IsSome && !__instance.chosenSlice.Value.isBackpackWear && !((Behaviour)__instance.slices[__instance.chosenSlice.Value.slotID + 1].image).enabled)
{
((Component)__instance.currentlyHeldItem).transform.position = Vector3.Lerp(((Component)__instance.currentlyHeldItem).transform.position, ((Component)__instance.slices[__instance.chosenSlice.Value.slotID + 1]).transform.GetChild(0).GetChild(0).position, Time.deltaTime * 20f);
}
else
{
((Component)__instance.currentlyHeldItem).transform.localPosition = Vector3.Lerp(((Component)__instance.currentlyHeldItem).transform.localPosition, Vector3.zero, Time.deltaTime * 20f);
}
return false;
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}
[CompilerGenerated]
internal sealed class <>z__ReadOnlyArray<T> : IEnumerable, ICollection, IList, IEnumerable<T>, IReadOnlyCollection<T>, IReadOnlyList<T>, ICollection<T>, IList<T>
{
int ICollection.Count => _items.Length;
bool ICollection.IsSynchronized => false;
object ICollection.SyncRoot => this;
object IList.this[int index]
{
get
{
return _items[index];
}
set
{
throw new NotSupportedException();
}
}
bool IList.IsFixedSize => true;
bool IList.IsReadOnly => true;
int IReadOnlyCollection<T>.Count => _items.Length;
T IReadOnlyList<T>.this[int index] => _items[index];
int ICollection<T>.Count => _items.Length;
bool ICollection<T>.IsReadOnly => true;
T IList<T>.this[int index]
{
get
{
return _items[index];
}
set
{
throw new NotSupportedException();
}
}
public <>z__ReadOnlyArray(T[] items)
{
_items = items;
}
IEnumerator IEnumerable.GetEnumerator()
{
return ((IEnumerable)_items).GetEnumerator();
}
void ICollection.CopyTo(Array array, int index)
{
((ICollection)_items).CopyTo(array, index);
}
int IList.Add(object value)
{
throw new NotSupportedException();
}
void IList.Clear()
{
throw new NotSupportedException();
}
bool IList.Contains(object value)
{
return ((IList)_items).Contains(value);
}
int IList.IndexOf(object value)
{
return ((IList)_items).IndexOf(value);
}
void IList.Insert(int index, object value)
{
throw new NotSupportedException();
}
void IList.Remove(object value)
{
throw new NotSupportedException();
}
void IList.RemoveAt(int index)
{
throw new NotSupportedException();
}
IEnumerator<T> IEnumerable<T>.GetEnumerator()
{
return ((IEnumerable<T>)_items).GetEnumerator();
}
void ICollection<T>.Add(T item)
{
throw new NotSupportedException();
}
void ICollection<T>.Clear()
{
throw new NotSupportedException();
}
bool ICollection<T>.Contains(T item)
{
return ((ICollection<T>)_items).Contains(item);
}
void ICollection<T>.CopyTo(T[] array, int arrayIndex)
{
((ICollection<T>)_items).CopyTo(array, arrayIndex);
}
bool ICollection<T>.Remove(T item)
{
throw new NotSupportedException();
}
int IList<T>.IndexOf(T item)
{
return ((IList<T>)_items).IndexOf(item);
}
void IList<T>.Insert(int index, T item)
{
throw new NotSupportedException();
}
void IList<T>.RemoveAt(int index)
{
throw new NotSupportedException();
}
}