using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
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 HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.Rendering;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("com.github.WillowPunch.SBG_FreeCam")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+1b010fae67b0b71653ffb1599fa37a08ccad20ad")]
[assembly: AssemblyProduct("com.github.WillowPunch.SBG_FreeCam")]
[assembly: AssemblyTitle("SBG_FreeCam")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
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")]
[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")]
[Embedded]
internal sealed class PatcherAutoPluginAttribute : Attribute
{
public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
{
}
}
}
namespace Microsoft.CodeAnalysis
{
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace SBG_FreeCam
{
[BepInPlugin("com.github.WillowPunch.SBG_FreeCam", "SBG_FreeCam", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
private const int FreeCameraInputMode = 4096;
private ConfigEntry<bool> simpleMode;
private ConfigEntry<float> rollDegreesPerSecond;
private ConfigEntry<KeyCode> toggleKey;
private ConfigEntry<float> speed;
private ConfigEntry<float> lookSpeed;
private ConfigEntry<KeyCode> rollLeft;
private ConfigEntry<KeyCode> rollRight;
private ConfigEntry<bool> invertX;
private ConfigEntry<bool> invertY;
private ConfigEntry<KeyCode> cinematicToggleKey;
private ConfigEntry<KeyCode> resetRollToggleKey;
private ConfigEntry<float> cinematicSmoothnessAmount;
private ConfigEntry<KeyCode> movementSmoothToggleKey;
private ConfigEntry<float> movementSmoothnessAmount;
private bool active;
private bool movementSmoothingActive;
private Vector3 movementVelocity;
private Vector3 movementSmoothVelocity;
private bool inputApiWarningLogged;
private Type? inputManagerType;
private Type? inputModeType;
private CursorLockMode previousCursorLockState;
private bool previousCursorVisible;
private Vector3 pos;
private float yaw;
private float pitch;
private float targetYaw;
private float targetPitch;
private float yawVelocity;
private float pitchVelocity;
private float roll;
private bool cinematicCameraActive;
private float speedMul = 1f;
private static Plugin? instance;
private Harmony? hudUpdateHarmony;
public const string Id = "com.github.WillowPunch.SBG_FreeCam";
internal static ManualLogSource Log { get; private set; }
public static string Name => "SBG_FreeCam";
public static string Version => "1.0.0";
private void Awake()
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Expected O, but got Unknown
//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
//IL_00f0: Expected O, but got Unknown
//IL_0124: Unknown result type (might be due to invalid IL or missing references)
//IL_012e: Expected O, but got Unknown
//IL_0162: Unknown result type (might be due to invalid IL or missing references)
//IL_016c: Expected O, but got Unknown
//IL_0276: Unknown result type (might be due to invalid IL or missing references)
//IL_0280: Expected O, but got Unknown
//IL_02d9: Unknown result type (might be due to invalid IL or missing references)
//IL_02e3: Expected O, but got Unknown
//IL_0309: Unknown result type (might be due to invalid IL or missing references)
Log = ((BaseUnityPlugin)this).Logger;
instance = this;
hudUpdateHarmony = new Harmony("com.github.WillowPunch.SBG_FreeCam");
PatchHudCameraUpdate("WorldspaceIconUi", "OnPostPostLateBUpdate");
PatchHudCameraUpdate("NameTagUi", "OnPostPostLateBUpdate");
PatchHudCameraUpdate("TextPopupUi", "UpdateSize");
inputManagerType = FindGameType("InputManager");
inputModeType = FindGameType("InputMode");
simpleMode = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "SimpleMode", true, "Disable controls in the AdvancedControls section.");
toggleKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Controls", "ToggleKey", (KeyCode)256, "Key that switches free camera on and off.");
speed = ((BaseUnityPlugin)this).Config.Bind<float>("Controls", "Speed", 15f, new ConfigDescription("Flying speed in metres per second (Shift = 4x, Alt = 0.25x).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 1000f), Array.Empty<object>()));
rollDegreesPerSecond = ((BaseUnityPlugin)this).Config.Bind<float>("AdvancedControls", "RollDegreesPerSecond", 90f, new ConfigDescription("Camera roll speed while holding a roll key, in degrees per second.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 360f), Array.Empty<object>()));
lookSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Controls", "MouseSensitivity", 0.12f, new ConfigDescription("Degrees turned per pixel of mouse movement.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.01f, 1f), Array.Empty<object>()));
invertX = ((BaseUnityPlugin)this).Config.Bind<bool>("Controls", "Invert X-axis", false, "Should the input of X-axis be inverted.");
invertY = ((BaseUnityPlugin)this).Config.Bind<bool>("Controls", "Invert Y-axis", false, "Should the input of Y-axis be inverted.");
rollRight = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("AdvancedControls", "RollCounterclockwise", (KeyCode)260, "Key that tilts camera on the Z-axis counterclockwise.");
rollLeft = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("AdvancedControls", "RollClockwise", (KeyCode)262, "Key that tilts camera on the Z-axis clockwise.");
cinematicToggleKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("AdvancedControls", "CinematicToggle", (KeyCode)261, "Toggle for smooth camera panning (Minecraft-style).");
resetRollToggleKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("AdvancedControls", "ResetRollToggle", (KeyCode)265, "Press to immediately snap roll to 0.");
cinematicSmoothnessAmount = ((BaseUnityPlugin)this).Config.Bind<float>("AdvancedControls", "CinematicSmoothness", 1f, new ConfigDescription("Camera rotation smoothing time in seconds; higher values produce slower, smoother movement.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.01f, 4f), Array.Empty<object>()));
movementSmoothToggleKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("AdvancedControls", "MovementSmoothToggle", (KeyCode)264, "Toggle smooth acceleration and deceleration for camera movement.");
movementSmoothnessAmount = ((BaseUnityPlugin)this).Config.Bind<float>("AdvancedControls", "MovementSmoothness", 1f, new ConfigDescription("Camera movement smoothing time in seconds; higher values produce slower acceleration and deceleration.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.01f, 4f), Array.Empty<object>()));
RenderPipelineManager.beginCameraRendering += OnBeginCamera;
Log.LogInfo((object)$"FreeCam ready: press {toggleKey.Value}.");
}
private void OnDestroy()
{
RenderPipelineManager.beginCameraRendering -= OnBeginCamera;
Stop();
Harmony? obj = hudUpdateHarmony;
if (obj != null)
{
obj.UnpatchSelf();
}
if ((Object)(object)instance == (Object)(object)this)
{
instance = null;
}
}
private void Update()
{
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0101: Unknown result type (might be due to invalid IL or missing references)
//IL_0106: Unknown result type (might be due to invalid IL or missing references)
//IL_010c: Unknown result type (might be due to invalid IL or missing references)
//IL_0111: Unknown result type (might be due to invalid IL or missing references)
//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
//IL_0324: Unknown result type (might be due to invalid IL or missing references)
//IL_0329: Unknown result type (might be due to invalid IL or missing references)
//IL_032a: Unknown result type (might be due to invalid IL or missing references)
//IL_032f: Unknown result type (might be due to invalid IL or missing references)
//IL_0209: Unknown result type (might be due to invalid IL or missing references)
//IL_033d: Unknown result type (might be due to invalid IL or missing references)
//IL_033e: Unknown result type (might be due to invalid IL or missing references)
//IL_033f: Unknown result type (might be due to invalid IL or missing references)
//IL_0344: Unknown result type (might be due to invalid IL or missing references)
//IL_0349: Unknown result type (might be due to invalid IL or missing references)
//IL_034e: Unknown result type (might be due to invalid IL or missing references)
//IL_035c: Unknown result type (might be due to invalid IL or missing references)
//IL_035d: Unknown result type (might be due to invalid IL or missing references)
//IL_035e: Unknown result type (might be due to invalid IL or missing references)
//IL_0363: Unknown result type (might be due to invalid IL or missing references)
//IL_0368: Unknown result type (might be due to invalid IL or missing references)
//IL_036d: Unknown result type (might be due to invalid IL or missing references)
//IL_024a: Unknown result type (might be due to invalid IL or missing references)
//IL_037b: Unknown result type (might be due to invalid IL or missing references)
//IL_037c: Unknown result type (might be due to invalid IL or missing references)
//IL_037d: Unknown result type (might be due to invalid IL or missing references)
//IL_0382: Unknown result type (might be due to invalid IL or missing references)
//IL_0387: Unknown result type (might be due to invalid IL or missing references)
//IL_038c: Unknown result type (might be due to invalid IL or missing references)
//IL_039a: Unknown result type (might be due to invalid IL or missing references)
//IL_039b: Unknown result type (might be due to invalid IL or missing references)
//IL_039c: Unknown result type (might be due to invalid IL or missing references)
//IL_03a1: Unknown result type (might be due to invalid IL or missing references)
//IL_03a6: Unknown result type (might be due to invalid IL or missing references)
//IL_03ab: Unknown result type (might be due to invalid IL or missing references)
//IL_03c6: Unknown result type (might be due to invalid IL or missing references)
//IL_03c7: Unknown result type (might be due to invalid IL or missing references)
//IL_03cc: Unknown result type (might be due to invalid IL or missing references)
//IL_03d1: Unknown result type (might be due to invalid IL or missing references)
//IL_03ec: Unknown result type (might be due to invalid IL or missing references)
//IL_03ed: Unknown result type (might be due to invalid IL or missing references)
//IL_03f2: Unknown result type (might be due to invalid IL or missing references)
//IL_03f7: Unknown result type (might be due to invalid IL or missing references)
//IL_04ab: Unknown result type (might be due to invalid IL or missing references)
//IL_04b0: Unknown result type (might be due to invalid IL or missing references)
//IL_04b6: Unknown result type (might be due to invalid IL or missing references)
//IL_04bb: Unknown result type (might be due to invalid IL or missing references)
//IL_04c2: Unknown result type (might be due to invalid IL or missing references)
//IL_04c9: Unknown result type (might be due to invalid IL or missing references)
//IL_04d0: Unknown result type (might be due to invalid IL or missing references)
//IL_04d7: Unknown result type (might be due to invalid IL or missing references)
//IL_04dc: Unknown result type (might be due to invalid IL or missing references)
//IL_04e1: Unknown result type (might be due to invalid IL or missing references)
//IL_0451: Unknown result type (might be due to invalid IL or missing references)
//IL_0458: Unknown result type (might be due to invalid IL or missing references)
//IL_045d: Unknown result type (might be due to invalid IL or missing references)
//IL_0461: Unknown result type (might be due to invalid IL or missing references)
//IL_0466: Unknown result type (might be due to invalid IL or missing references)
//IL_0480: Unknown result type (might be due to invalid IL or missing references)
//IL_0485: Unknown result type (might be due to invalid IL or missing references)
//IL_048c: Unknown result type (might be due to invalid IL or missing references)
//IL_0492: Unknown result type (might be due to invalid IL or missing references)
//IL_0499: Unknown result type (might be due to invalid IL or missing references)
//IL_049e: Unknown result type (might be due to invalid IL or missing references)
//IL_04a3: Unknown result type (might be due to invalid IL or missing references)
Keyboard current = Keyboard.current;
if (current == null)
{
if (active)
{
Stop();
}
return;
}
if (ToggleKeyPressed(current, toggleKey) && !IsTyping())
{
if (active)
{
Stop();
}
else
{
Start_();
}
}
if (simpleMode.Value)
{
cinematicCameraActive = false;
movementSmoothingActive = false;
movementVelocity = Vector3.zero;
movementSmoothVelocity = Vector3.zero;
roll = 0f;
}
else
{
if (ToggleKeyPressed(current, cinematicToggleKey) && !IsTyping())
{
cinematicCameraActive = !cinematicCameraActive;
targetYaw = yaw;
targetPitch = pitch;
yawVelocity = 0f;
pitchVelocity = 0f;
}
if (ToggleKeyPressed(current, movementSmoothToggleKey) && !IsTyping())
{
movementSmoothingActive = !movementSmoothingActive;
movementVelocity = Vector3.zero;
movementSmoothVelocity = Vector3.zero;
}
}
if (!active)
{
return;
}
if ((Object)(object)Camera.main == (Object)null)
{
Stop();
return;
}
if (!simpleMode.Value)
{
if (ToggleKeyPressed(current, resetRollToggleKey))
{
roll = 0f;
}
else
{
float num = (IsKeyPressed(current, rollRight) ? 1f : 0f) - (IsKeyPressed(current, rollLeft) ? 1f : 0f);
roll += num * rollDegreesPerSecond.Value * Time.unscaledDeltaTime;
}
}
Mouse current2 = Mouse.current;
if (current2 != null)
{
Vector2 val = ((InputControl<Vector2>)(object)((Pointer)current2).delta).ReadValue();
targetYaw += val.x * lookSpeed.Value * (float)((!invertX.Value) ? 1 : (-1));
targetPitch = Mathf.Clamp(targetPitch - val.y * lookSpeed.Value * (float)((!invertY.Value) ? 1 : (-1)), -89f, 89f);
float y = ((InputControl<Vector2>)(object)current2.scroll).ReadValue().y;
if (y != 0f)
{
speedMul = Mathf.Clamp(speedMul * ((y > 0f) ? 1.2f : (5f / 6f)), 0.05f, 20f);
}
}
if (cinematicCameraActive)
{
float value = cinematicSmoothnessAmount.Value;
float unscaledDeltaTime = Time.unscaledDeltaTime;
yaw = Mathf.SmoothDamp(yaw, targetYaw, ref yawVelocity, value, float.PositiveInfinity, unscaledDeltaTime);
pitch = Mathf.SmoothDamp(pitch, targetPitch, ref pitchVelocity, value, float.PositiveInfinity, unscaledDeltaTime);
}
else
{
yaw = targetYaw;
pitch = targetPitch;
}
Quaternion val2 = Quaternion.Euler(pitch, yaw, roll);
Vector3 val3 = Vector3.zero;
if (((ButtonControl)current.wKey).isPressed)
{
val3 += val2 * Vector3.forward;
}
if (((ButtonControl)current.sKey).isPressed)
{
val3 -= val2 * Vector3.forward;
}
if (((ButtonControl)current.dKey).isPressed)
{
val3 += val2 * Vector3.right;
}
if (((ButtonControl)current.aKey).isPressed)
{
val3 -= val2 * Vector3.right;
}
if (((ButtonControl)current.spaceKey).isPressed || ((ButtonControl)current.eKey).isPressed)
{
val3 += Vector3.up;
}
if (((ButtonControl)current.leftCtrlKey).isPressed || ((ButtonControl)current.qKey).isPressed)
{
val3 -= Vector3.up;
}
float num2 = speed.Value * speedMul * (((ButtonControl)current.leftShiftKey).isPressed ? 4f : 1f) * (((ButtonControl)current.leftAltKey).isPressed ? 0.25f : 1f);
float unscaledDeltaTime2 = Time.unscaledDeltaTime;
if (movementSmoothingActive)
{
Vector3 val4 = ((Vector3)(ref val3)).normalized * num2;
movementVelocity = Vector3.SmoothDamp(movementVelocity, val4, ref movementSmoothVelocity, movementSmoothnessAmount.Value, float.PositiveInfinity, unscaledDeltaTime2);
pos += movementVelocity * unscaledDeltaTime2;
}
else
{
movementVelocity = Vector3.zero;
movementSmoothVelocity = Vector3.zero;
pos += ((Vector3)(ref val3)).normalized * num2 * unscaledDeltaTime2;
}
ApplyCameraTransform(Camera.main);
Cursor.lockState = (CursorLockMode)1;
Cursor.visible = false;
}
private bool ToggleKeyPressed(Keyboard keyboard, ConfigEntry<KeyCode> toggleOrCinematicToggleKey)
{
if (!TryGetKeyControl(keyboard, toggleOrCinematicToggleKey, out KeyControl keyControl))
{
return false;
}
return ((ButtonControl)keyControl).wasPressedThisFrame;
}
private bool IsKeyPressed(Keyboard keyboard, ConfigEntry<KeyCode> configuredKey)
{
if (TryGetKeyControl(keyboard, configuredKey, out KeyControl keyControl))
{
return ((ButtonControl)keyControl).isPressed;
}
return false;
}
private bool TryGetKeyControl(Keyboard keyboard, ConfigEntry<KeyCode> configuredKey, out KeyControl keyControl)
{
//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_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
string text = ((object)configuredKey.Value/*cast due to .constrained prefix*/).ToString();
if (text.StartsWith("Alpha", StringComparison.Ordinal))
{
text = "Digit" + text.Substring(5);
}
else if (text.StartsWith("Keypad", StringComparison.Ordinal))
{
text = "Numpad" + text.Substring(6);
}
if (!Enum.TryParse<Key>(text, ignoreCase: true, out Key result) || (int)result == 0)
{
keyControl = null;
return false;
}
keyControl = keyboard[result];
return keyControl != null;
}
private void PatchHudCameraUpdate(string typeName, string methodName)
{
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: Expected O, but got Unknown
Type type = FindGameType(typeName);
if (type == null)
{
Log.LogWarning((object)("Couldn't find " + typeName + "; its UI won't receive the free-camera pose before updating."));
return;
}
MethodInfo method = typeof(Plugin).GetMethod("BeforeHudCameraUpdate", BindingFlags.Static | BindingFlags.NonPublic);
int num = 0;
MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
foreach (MethodInfo methodInfo in methods)
{
if (!(methodInfo.Name != methodName))
{
try
{
hudUpdateHarmony.Patch((MethodBase)methodInfo, new HarmonyMethod(method), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
num++;
}
catch (Exception ex)
{
Log.LogWarning((object)("Couldn't hook " + typeName + "." + methodName + ": " + ex.GetBaseException().Message));
}
}
}
if (num == 0)
{
Log.LogWarning((object)("Couldn't find " + typeName + "." + methodName + "; its UI won't receive the free-camera pose before updating."));
}
else
{
Log.LogInfo((object)$"Hooked {num} {typeName}.{methodName} method(s) to update the free-camera pose before UI positioning.");
}
}
private static void BeforeHudCameraUpdate()
{
if ((Object)(object)instance != (Object)null && instance.active)
{
instance.ApplyCameraTransform(Camera.main);
}
}
private void OnBeginCamera(ScriptableRenderContext context, Camera camera)
{
if (active && (Object)(object)camera == (Object)(object)Camera.main)
{
ApplyCameraTransform(camera);
}
}
private void ApplyCameraTransform(Camera camera)
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)camera != (Object)null)
{
((Component)camera).transform.SetPositionAndRotation(pos, Quaternion.Euler(pitch, yaw, roll));
}
}
private void Start_()
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: 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_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: 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_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
Camera main = Camera.main;
if (!((Object)(object)main == (Object)null))
{
Transform transform = ((Component)main).transform;
pos = transform.position;
Vector3 eulerAngles = transform.eulerAngles;
yaw = eulerAngles.y;
pitch = ((eulerAngles.x > 180f) ? (eulerAngles.x - 360f) : eulerAngles.x);
targetYaw = yaw;
targetPitch = pitch;
yawVelocity = 0f;
pitchVelocity = 0f;
movementVelocity = Vector3.zero;
movementSmoothVelocity = Vector3.zero;
previousCursorLockState = Cursor.lockState;
previousCursorVisible = Cursor.visible;
active = true;
cinematicCameraActive = false;
ApplyCameraTransform(main);
SetGameInput(on: false);
Log.LogInfo((object)"Free camera on.");
}
}
private void Stop()
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: 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_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
if (active)
{
active = false;
movementVelocity = Vector3.zero;
movementSmoothVelocity = Vector3.zero;
SetGameInput(on: true);
Cursor.lockState = previousCursorLockState;
Cursor.visible = previousCursorVisible;
Log.LogInfo((object)"Free camera off.");
}
}
private void SetGameInput(bool on)
{
if (!TryGetInputTypes(out Type managerType, out Type type))
{
return;
}
string text = (on ? "DisableMode" : "EnableMode");
MethodInfo method = managerType.GetMethod(text, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[1] { type }, null);
if (method == null)
{
WarnInputApi("Game input API method '" + text + "' was not found.");
return;
}
try
{
method.Invoke(null, new object[1] { Enum.ToObject(type, 4096) });
}
catch (Exception ex)
{
Log.LogWarning((object)("Couldn't switch game input: " + ex.GetBaseException().Message));
}
}
private bool IsTyping()
{
if (!TryGetInputTypes(out Type managerType, out Type _))
{
return false;
}
PropertyInfo property = managerType.GetProperty("CurrentMode", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
if (property == null)
{
WarnInputApi("Game input API property 'CurrentMode' was not found.");
return false;
}
try
{
object value = property.GetValue(null);
return value != null && (Convert.ToInt32(value) & 0x3E0) != 0;
}
catch (Exception ex)
{
WarnInputApi("Couldn't read the game input mode: " + ex.GetBaseException().Message);
return false;
}
}
private bool TryGetInputTypes(out Type managerType, out Type inputModeType)
{
if (inputManagerType != null && this.inputModeType != null)
{
managerType = inputManagerType;
inputModeType = this.inputModeType;
return true;
}
managerType = null;
inputModeType = null;
WarnInputApi("Game input types 'InputManager' or 'InputMode' were not found; game input integration is unavailable.");
return false;
}
private static Type? FindGameType(string typeName)
{
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
foreach (Assembly assembly in assemblies)
{
Type type = assembly.GetType(typeName, throwOnError: false);
if (type != null)
{
return type;
}
}
return null;
}
private void WarnInputApi(string message)
{
if (!inputApiWarningLogged)
{
inputApiWarningLogged = true;
Log.LogWarning((object)message);
}
}
}
}
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
{
}
}