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 BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
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;
}
}
}
namespace FPSSpectate
{
[BepInPlugin("5Bit.FPSSpectate", "FPSSpectate", "1.0.2")]
public class FPSSpectate : BaseUnityPlugin
{
public const string modGUID = "5Bit.FPSSpectate";
public const string modName = "FPSSpectate";
public const string modVersion = "1.0.2";
public readonly Harmony harmony = new Harmony("5Bit.FPSSpectate");
public static FPSSpectate Instance;
public static ManualLogSource mls;
public static ConfigEntry<Key> fpsKeyBind { get; set; }
public static ConfigEntry<bool> defaultViewConfig { get; set; }
public static ConfigEntry<bool> hideModelInFPSMode { get; set; }
private void Awake()
{
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
fpsKeyBind = ((BaseUnityPlugin)this).Config.Bind<Key>("Settings", "Keybind", (Key)36, "Which key to press to switch between third and first person.");
defaultViewConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "Default to first person", true, "Whether or not to default to first person when spectating");
hideModelInFPSMode = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "Hide Model", false, "Hide the model in first person while spectating.");
mls = Logger.CreateLogSource("5Bit.FPSSpectate");
harmony.PatchAll();
}
}
}
namespace FPSSpectate.Patches
{
[HarmonyPatch(typeof(PlayerControllerB))]
internal class FPSSpectatePatch
{
public const float SPECTATE_OFFSET = 1.5f;
public static bool debounced = false;
public static bool firstPerson = FPSSpectate.defaultViewConfig.Value;
[HarmonyPatch("LateUpdate")]
[HarmonyPostfix]
private static void LateUpdate(PlayerControllerB __instance)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
//IL_010a: Unknown result type (might be due to invalid IL or missing references)
//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
Key value = FPSSpectate.fpsKeyBind.Value;
if (((ButtonControl)Keyboard.current[value]).wasPressedThisFrame && !debounced)
{
firstPerson = !firstPerson;
debounced = true;
}
if (((ButtonControl)Keyboard.current[value]).wasReleasedThisFrame)
{
debounced = false;
}
if ((Object)(object)__instance.spectatedPlayerScript != (Object)null && firstPerson)
{
if (FPSSpectate.hideModelInFPSMode.Value)
{
Transform[] bodyParts = __instance.spectatedPlayerScript.bodyParts;
bodyParts[0].localScale = new Vector3(0f, 0f, 0f);
}
Transform transform = ((Component)__instance.spectateCameraPivot).transform;
Transform transform2 = ((Component)__instance.spectatedPlayerScript.visorCamera).transform;
Vector3 position = transform2.position;
Vector3 forward = transform2.forward;
transform.position = position + ((Vector3)(ref forward)).normalized * 1.5f;
transform.rotation = transform2.rotation;
}
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}