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.8.0")] [assembly: AssemblyInformationalVersion("1.0.8+3bb4d320c2170383889b1722db0e3bc4664fd35c")] [assembly: AssemblyProduct("com.github.LengSword.RemoteAliveHelper")] [assembly: AssemblyTitle("RemoteAliveHelper")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.8.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.8")] public class Plugin : 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; } internal static bool IsAllowUnconscious { get { if (Character.localCharacter.data.fullyPassedOut) { return !PluginConfig.AllowUnconsciousConfig.Value; } return false; } } public static string Name => "RemoteAliveHelper"; public static string Version => "1.0.8"; 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) && !IsAllowUnconscious) { if ((Object)(object)cameraMovement == (Object)null) { cameraMovement = Singleton.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 ToggleKeyConfig { get; private set; } internal static ConfigEntry SpectateLeftKeyConfig { get; private set; } internal static ConfigEntry SpectateRightKeyConfig { get; private set; } internal static ConfigEntry EnableRemoteModeConfig { get; private set; } internal static ConfigEntry ShowGhostConfig { get; private set; } internal static ConfigEntry AllowUnconsciousConfig { get; private set; } internal static ConfigEntry AllowSpectateDeadConfig { get; private set; } public static void Initialize(ConfigFile config, ManualLogSource logger) { ToggleKeyConfig = config.Bind("Keybinds", "KeyboardToggle", (KeyCode)291, "Keyboard key for toggling spectator mode on/off"); SpectateLeftKeyConfig = config.Bind("Keybinds", "SpectateLeft", (KeyCode)91, "Keyboard key for swapping the left spectator"); SpectateRightKeyConfig = config.Bind("Keybinds", "SpectateRight", (KeyCode)93, "Keyboard key for swapping the right spectator"); EnableRemoteModeConfig = config.Bind("General", "EnableRemoteMode", false, "Enable remote mode (can remote feeding)"); ShowGhostConfig = config.Bind("General", "ShowGhost", false, "Show your ghost on spectating (can talk with observed player)"); AllowUnconsciousConfig = config.Bind("General", "AllowUnconscious", false, "Allow unconscious players to spectate others"); AllowSpectateDeadConfig = config.Bind("General", "AllowSpectateDead", false, "Allow to spectate the dead player skelleton"); logger.LogInfo((object)"Plugin Config Loaded."); } } } namespace RemoteAliveHelper.Patches { [HarmonyPatch(typeof(MainCameraMovement), "LateUpdate")] internal sealed class MainCameraMovementLateUpdatePatch { private static IEnumerable Transpiler(IEnumerable 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 list = new List(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(Plugin), "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[])(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 (Plugin.IsManualSpectating && !GUIManager.instance.windowBlockingInput && (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 (Plugin.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(); 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(/*Could not decode attribute arguments.*/)] public class CharacterDataCanBeSpectatedPatch { private static bool Prefix(ref bool __result, CharacterData __instance) { if (!Plugin.IsManualSpectating) { return true; } __result = !__instance.dead || __instance.sinceDied < 5f || PluginConfig.AllowSpectateDeadConfig.Value; return false; } } [HarmonyPatch(typeof(CharacterInput), "Sample")] internal sealed class CharacterInputSamplePatch { private static void Prefix(ref bool playerMovementActive) { if (Plugin.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 (Plugin.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.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 (Plugin.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 (Plugin.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; } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } } [CompilerGenerated] internal sealed class <>z__ReadOnlyArray : IEnumerable, ICollection, IList, IEnumerable, IReadOnlyCollection, IReadOnlyList, ICollection, IList { 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.Count => _items.Length; T IReadOnlyList.this[int index] => _items[index]; int ICollection.Count => _items.Length; bool ICollection.IsReadOnly => true; T IList.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 IEnumerable.GetEnumerator() { return ((IEnumerable)_items).GetEnumerator(); } void ICollection.Add(T item) { throw new NotSupportedException(); } void ICollection.Clear() { throw new NotSupportedException(); } bool ICollection.Contains(T item) { return ((ICollection)_items).Contains(item); } void ICollection.CopyTo(T[] array, int arrayIndex) { ((ICollection)_items).CopyTo(array, arrayIndex); } bool ICollection.Remove(T item) { throw new NotSupportedException(); } int IList.IndexOf(T item) { return ((IList)_items).IndexOf(item); } void IList.Insert(int index, T item) { throw new NotSupportedException(); } void IList.RemoveAt(int index) { throw new NotSupportedException(); } }