using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalCompanyInputUtils.Api;
using LethalConfig;
using LethalConfig.ConfigItems;
using LethalConfig.ConfigItems.Options;
using SimpleFreeCam.Input;
using SimpleFreeCam.Patches;
using SimpleFreeCam.UI;
using TMPro;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.Rendering;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("SimpleFreeCam")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SimpleFreeCam")]
[assembly: AssemblyCopyright("Copyright © 2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("6649931a-a94b-4986-8489-8153ecf188f6")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace SimpleFreeCam
{
internal static class FreeCamClass
{
[CompilerGenerated]
private sealed class <SetupFreecam>d__18 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <SetupFreecam>d__18(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Expected O, but got Unknown
//IL_0108: Unknown result type (might be due to invalid IL or missing references)
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>2__current = (object)new WaitUntil((Func<bool>)(() => (Object)(object)StartOfRound.Instance.localPlayerController != (Object)null));
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
playerController = StartOfRound.Instance.localPlayerController;
HUDObject = ((Component)GameObject.Find("Systems").transform.Find("Rendering/PlayerHUDHelmetModel")).gameObject;
playerModel = ((Component)((Component)playerController).transform.Find("ScavengerModel/LOD1")).GetComponent<SkinnedMeshRenderer>();
mainCameraTransform = ((Component)playerController).transform.Find("ScavengerModel/metarig/CameraContainer/MainCamera");
freeCameraTransform = GameObject.Find("FreeCameraCinematic").transform;
FreeCam = StartOfRound.Instance.freeCinematicCamera;
playerAudioListener = ((Component)playerController).transform.Find("ScavengerModel/metarig/CameraContainer/MainCamera/PlayerAudioListener");
if ((Object)(object)FreeCamHUD.Instance == (Object)null)
{
new GameObject("SimpleFreeCamHUD").AddComponent<FreeCamHUD>();
}
return false;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
private static GameObject HUDObject;
private static SkinnedMeshRenderer playerModel;
private static Transform playerAudioListener;
private static PlayerControllerB playerController = null;
internal static bool shouldChangeFOV = false;
private static Transform mainCameraTransform;
private static Transform freeCameraTransform;
private static Camera FreeCam;
internal static bool lockFreeCam = false;
internal static bool isInFreeCam = false;
internal static bool isInMenu = true;
internal static float freecamSpeed = 5f;
private static bool hasChangedSpeed = false;
private static bool hasBootedAlready = false;
private static float PlayerSavedCameraUp = 0f;
public static float FreeCamSavedCameraUp = 0f;
private static float freecamFOV = 60f;
private static readonly FieldInfo cameraUpField = typeof(PlayerControllerB).GetField("cameraUp", BindingFlags.Instance | BindingFlags.NonPublic);
[IteratorStateMachine(typeof(<SetupFreecam>d__18))]
public static IEnumerator SetupFreecam()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <SetupFreecam>d__18(0);
}
public static void SetFreeCamera_performed(CallbackContext obj)
{
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
if (!((CallbackContext)(ref obj)).performed || isInMenu)
{
return;
}
typeof(PlayerControllerB).GetMethod("SetFreeCamera_performed", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(playerController, new object[1] { obj });
if (!playerController.inTerminalMenu && !playerController.isTypingChat)
{
if (isInFreeCam)
{
DisableFreecam();
}
else if (!playerController.isPlayerDead)
{
EnableFreecam();
}
}
}
public static void ToggleFOVSwitch_performed(bool isHeldDown)
{
if (!((Object)(object)playerController == (Object)null) && isInFreeCam)
{
shouldChangeFOV = isHeldDown;
}
}
public static void ToggleFreecamMovement_performed(CallbackContext obj)
{
if (((CallbackContext)(ref obj)).performed && !((Object)(object)playerController == (Object)null) && isInFreeCam)
{
lockFreeCam = !lockFreeCam;
DisableFreecamOnLock();
}
}
public static void ResetFOV_performed(CallbackContext obj)
{
if (((CallbackContext)(ref obj)).performed && !((Object)(object)playerController == (Object)null) && isInFreeCam)
{
freecamFOV = 60f;
FreeCam.fieldOfView = 60f;
}
}
public static void ResetFreeCam()
{
hasBootedAlready = false;
FreeCamSavedCameraUp = 0f;
}
public static void TeleportFreeCamToPlayer_performed(CallbackContext obj)
{
if (((CallbackContext)(ref obj)).performed && !((Object)(object)playerController == (Object)null) && isInFreeCam)
{
TeleportFreeCamToPlayer();
}
}
public static void SetFreecamLocation(Vector3 position)
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
if (isInFreeCam && !lockFreeCam)
{
freeCameraTransform.position = position;
StartOfRound.Instance.freeCinematicCameraTurnCompass.position = position;
}
}
public static void SetFreecamFOV(float fov)
{
freecamFOV = Mathf.Clamp(fov, 5f, 160f);
if (isInFreeCam)
{
FreeCam.fieldOfView = freecamFOV;
}
}
public static float GetFreecamFOV()
{
return freecamFOV;
}
public static void TeleportFreeCamToPlayer()
{
TeleportFreeCamToPlayer(-0.5f);
}
private static void ResetFreeCamRotation()
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: 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)
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
Quaternion rotation = (Quaternion)((!((Object)(object)playerController != (Object)null)) ? default(Quaternion) : Quaternion.LookRotation(GetPlayerForwardWithoutPitch()));
freeCameraTransform.rotation = rotation;
StartOfRound.Instance.freeCinematicCameraTurnCompass.rotation = rotation;
}
private static void ResetFreeCamTransform(float offset)
{
TeleportFreeCamToPlayer(offset);
ResetFreeCamRotation();
}
public static void TeleportFreeCamToPlayer(float offset)
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: 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_001f: Unknown result type (might be due to invalid IL or missing references)
SetFreecamLocation(((Component)playerController.gameplayCamera).transform.position + GetPlayerForwardWithoutPitch() * offset);
}
private static Vector3 GetPlayerForwardWithoutPitch()
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
Vector3 forward = ((Component)playerController.gameplayCamera).transform.forward;
forward.y = 0f;
return ((Vector3)(ref forward)).normalized;
}
private static void EnableFreecam()
{
//IL_0106: Unknown result type (might be due to invalid IL or missing references)
lockFreeCam = false;
isInFreeCam = true;
shouldChangeFOV = false;
FreeCam.cullingMask = playerController.gameplayCamera.cullingMask;
if (!hasBootedAlready)
{
hasBootedAlready = true;
freecamSpeed = SimpleFreeCamPatchBase.instance.FreeCamConfigEntryFloat.Value;
ResetFreeCamTransform(-1f);
}
if (SimpleFreeCamPatchBase.instance.FreeCamConfigEntryResetTransform.Value)
{
ResetFreeCamTransform(-1f);
}
else if (SimpleFreeCamPatchBase.instance.FreeCamConfigEntryResetDistance.Value && ShouldDistanceReset())
{
ResetFreeCamTransform(-1f);
}
if (SimpleFreeCamPatchBase.instance.FreeCamConfigEntry.Value)
{
freecamSpeed = SimpleFreeCamPatchBase.instance.FreeCamConfigEntryFloat.Value;
}
else if (!hasChangedSpeed)
{
freecamSpeed = SimpleFreeCamPatchBase.instance.FreeCamConfigEntryFloat.Value;
}
SwitchCameraUpField(switchToFreeCam: true);
FreeCam.fieldOfView = freecamFOV;
playerController.isFreeCamera = true;
StartOfRound.Instance.freeCinematicCameraTurnCompass.rotation = freeCameraTransform.rotation;
StartOfRound.Instance.SwitchCamera(FreeCam);
FreeCamHUD.ResetHideUI();
HUDObject.SetActive(false);
((Renderer)playerController.thisPlayerModelArms).enabled = false;
((Renderer)playerModel).shadowCastingMode = (ShadowCastingMode)1;
playerAudioListener.SetParent(freeCameraTransform, false);
if ((Object)(object)playerController.currentlyHeldObjectServer != (Object)null)
{
playerController.currentlyHeldObjectServer.parentObject = playerController.serverItemHolder;
}
HUDManager.Instance.HideHUD(true);
}
private static bool ShouldDistanceReset()
{
//IL_003c: 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_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
if (SimpleFreeCamPatchBase.instance.FreeCamConfigEntryResetDistance.Value)
{
float num = SimpleFreeCamPatchBase.instance.FreeCamConfigEntryInt.Value * SimpleFreeCamPatchBase.instance.FreeCamConfigEntryInt.Value;
Vector3 val = ((Component)playerController).transform.localPosition - ((Component)FreeCam).transform.localPosition;
return ((Vector3)(ref val)).sqrMagnitude > num;
}
return false;
}
public static void TickDistanceWarning()
{
FreeCamHUD.TriggerDistanceWarning(ShouldDistanceReset());
}
private static void SwitchCameraUpField(bool switchToFreeCam)
{
if (switchToFreeCam)
{
PlayerSavedCameraUp = (float)cameraUpField.GetValue(playerController);
cameraUpField.SetValue(playerController, FreeCamSavedCameraUp);
}
else
{
FreeCamSavedCameraUp = (float)cameraUpField.GetValue(playerController);
cameraUpField.SetValue(playerController, PlayerSavedCameraUp);
}
}
public static void DisableFreecam()
{
if (!lockFreeCam)
{
SwitchCameraUpField(switchToFreeCam: false);
}
lockFreeCam = false;
isInFreeCam = false;
playerController.isFreeCamera = false;
((Behaviour)StartOfRound.Instance.freeCinematicCamera).enabled = false;
StartOfRound.Instance.SwitchCamera(playerController.isPlayerDead ? StartOfRound.Instance.spectateCamera : playerController.gameplayCamera);
HUDObject.SetActive(true);
((Renderer)playerController.thisPlayerModelArms).enabled = true;
((Renderer)playerModel).shadowCastingMode = (ShadowCastingMode)3;
playerAudioListener.SetParent(mainCameraTransform, false);
if ((Object)(object)playerController.currentlyHeldObjectServer != (Object)null)
{
playerController.currentlyHeldObjectServer.parentObject = playerController.localItemHolder;
}
HUDManager.Instance.HideHUD(playerController.isPlayerDead);
}
public static void DisableFreecamOnLock()
{
isInFreeCam = true;
SwitchCameraUpField(!lockFreeCam);
playerController.isFreeCamera = !lockFreeCam;
}
internal static void AdjustSpeed(float scrollDelta)
{
if (isInFreeCam && !lockFreeCam)
{
freecamSpeed = Mathf.Clamp(freecamSpeed + ((scrollDelta > 0f) ? 0.5f : (-0.5f)), 0f, 50f);
if (!hasChangedSpeed)
{
hasChangedSpeed = true;
}
}
}
internal static void UpdateSpeed(float newSpeed)
{
if (!hasChangedSpeed)
{
freecamSpeed = newSpeed;
}
}
internal static bool IsInVehicle()
{
if ((Object)(object)playerController != (Object)null)
{
return playerController.inVehicleAnimation;
}
return false;
}
internal static float GetSpeed()
{
return freecamSpeed;
}
internal static void AdjustFOV(float delta)
{
if (isInFreeCam && !lockFreeCam)
{
SetFreecamFOV(freecamFOV + delta);
}
}
internal static float GetFOVSensitivityMultiplier()
{
return freecamFOV / 60f;
}
}
internal static class FreeCamFOVInfo
{
internal const float MinFOV = 5f;
internal const float MaxFOV = 160f;
internal const float ScrollStep = 1f;
internal const float DefaultFOV = 60f;
}
internal static class FreeCamSpeedInfo
{
internal const float MinSpeed = 0f;
internal const float MaxSpeed = 50f;
internal const float ScrollStep = 0.5f;
internal const float DefaultSpeed = 5f;
internal const float SprintMultiplier = 2f;
internal const float VehicleMinimumSpeed = 2f;
}
internal static class ModInfo
{
internal const string modGUID = "PixelIndieDev_SimpleFreeCam";
internal const string modName = "Simple Freecam";
internal const string modVersion = "1.4.0.0";
}
[BepInPlugin("PixelIndieDev_SimpleFreeCam", "Simple Freecam", "1.4.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class SimpleFreeCamPatchBase : BaseUnityPlugin
{
private readonly Harmony harmony = new Harmony("PixelIndieDev_SimpleFreeCam");
public static SimpleFreeCamPatchBase instance;
internal static SimpleFreeCamInputs InputActionsInstance;
internal ConfigEntry<bool> FreeCamConfigEntry;
internal ConfigEntry<float> FreeCamConfigEntryFloat;
internal ConfigEntry<int> FreeCamConfigEntryInt;
internal ConfigEntry<bool> FreeCamConfigEntryResetTransform;
internal ConfigEntry<bool> FreeCamConfigEntryResetDistance;
internal ConfigEntry<bool> FreeCamConfigEntryHideUI;
internal ConfigEntry<bool> FreeCamConfigEntryDefaultUIVisiblity;
internal ConfigEntry<float> FreeCamConfigEntryFloatOpacity;
internal ConfigEntry<bool> FreeCamConfigDisableShowWarningDistance;
internal ConfigEntry<bool> FreeCamConfigDisableShowWarningReset;
internal ManualLogSource logSource;
private void Awake()
{
//IL_0137: Unknown result type (might be due to invalid IL or missing references)
//IL_013c: Unknown result type (might be due to invalid IL or missing references)
//IL_0148: Expected O, but got Unknown
//IL_0143: Unknown result type (might be due to invalid IL or missing references)
//IL_014d: Expected O, but got Unknown
//IL_0174: Unknown result type (might be due to invalid IL or missing references)
//IL_0179: Unknown result type (might be due to invalid IL or missing references)
//IL_0185: Expected O, but got Unknown
//IL_0180: Unknown result type (might be due to invalid IL or missing references)
//IL_018a: Expected O, but got Unknown
//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
//IL_01bf: Expected O, but got Unknown
//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
//IL_01ca: Expected O, but got Unknown
//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
//IL_01d6: Expected O, but got Unknown
//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
//IL_01db: Expected O, but got Unknown
//IL_0202: Unknown result type (might be due to invalid IL or missing references)
//IL_0207: Unknown result type (might be due to invalid IL or missing references)
//IL_0213: Expected O, but got Unknown
//IL_020e: Unknown result type (might be due to invalid IL or missing references)
//IL_0218: Expected O, but got Unknown
//IL_027d: Unknown result type (might be due to invalid IL or missing references)
//IL_0282: Unknown result type (might be due to invalid IL or missing references)
//IL_028d: Expected O, but got Unknown
//IL_028d: Unknown result type (might be due to invalid IL or missing references)
//IL_0298: Expected O, but got Unknown
//IL_0298: Unknown result type (might be due to invalid IL or missing references)
//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
//IL_02af: Expected O, but got Unknown
//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
//IL_02b4: Expected O, but got Unknown
//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0306: Expected O, but got Unknown
//IL_0306: Unknown result type (might be due to invalid IL or missing references)
//IL_0311: Expected O, but got Unknown
//IL_0311: Unknown result type (might be due to invalid IL or missing references)
//IL_031c: Unknown result type (might be due to invalid IL or missing references)
//IL_0328: Expected O, but got Unknown
//IL_0323: Unknown result type (might be due to invalid IL or missing references)
//IL_032d: Expected O, but got Unknown
//IL_0354: Unknown result type (might be due to invalid IL or missing references)
//IL_0359: Unknown result type (might be due to invalid IL or missing references)
//IL_0365: Expected O, but got Unknown
//IL_0360: Unknown result type (might be due to invalid IL or missing references)
//IL_036a: Expected O, but got Unknown
//IL_0391: Unknown result type (might be due to invalid IL or missing references)
//IL_0396: Unknown result type (might be due to invalid IL or missing references)
//IL_03a2: Expected O, but got Unknown
//IL_039d: Unknown result type (might be due to invalid IL or missing references)
//IL_03a7: Expected O, but got Unknown
//IL_03ce: Unknown result type (might be due to invalid IL or missing references)
//IL_03d3: Unknown result type (might be due to invalid IL or missing references)
//IL_03df: Expected O, but got Unknown
//IL_03da: Unknown result type (might be due to invalid IL or missing references)
//IL_03e4: Expected O, but got Unknown
//IL_040b: Unknown result type (might be due to invalid IL or missing references)
//IL_0410: Unknown result type (might be due to invalid IL or missing references)
//IL_041c: Expected O, but got Unknown
//IL_0417: Unknown result type (might be due to invalid IL or missing references)
//IL_0421: Expected O, but got Unknown
logSource = Logger.CreateLogSource("PixelIndieDev_SimpleFreeCam");
if ((Object)(object)instance == (Object)null)
{
instance = this;
}
InputActionsInstance = new SimpleFreeCamInputs();
InputActionsInstance.PixelIndieDev_FreeCamKey.performed += FreeCamClass.SetFreeCamera_performed;
InputActionsInstance.PixelIndieDev_FreeCamMovementKey.performed += FreeCamClass.ToggleFreecamMovement_performed;
InputActionsInstance.PixelIndieDev_FreeCamFOVModifierKey.performed += delegate
{
FreeCamClass.ToggleFOVSwitch_performed(isHeldDown: true);
};
InputActionsInstance.PixelIndieDev_FreeCamFOVModifierKey.canceled += delegate
{
FreeCamClass.ToggleFOVSwitch_performed(isHeldDown: false);
};
InputActionsInstance.PixelIndieDev_FreeCamResetFOVKey.performed += FreeCamClass.ResetFOV_performed;
InputActionsInstance.PixelIndieDev_FreeCamTeleportToPlayerKey.performed += FreeCamClass.TeleportFreeCamToPlayer_performed;
InputActionsInstance.PixelIndieDev_FreeCamHideUI.performed += FreeCamHUD.HideUI_performed;
FreeCamConfigEntryResetTransform = ((BaseUnityPlugin)this).Config.Bind<bool>("Transform", "Reset freecam location and rotation on freecam", false, "When enabled, the freecam will teleport to the player's current position and rotation every time freecam is activated.");
LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(FreeCamConfigEntryResetTransform, new BoolCheckBoxOptions
{
RequiresRestart = false
}));
FreeCamConfigEntryResetDistance = ((BaseUnityPlugin)this).Config.Bind<bool>("Transform", "Reset freecam when too far away", false, "When enabled, the freecam will automatically teleport to the player's position and rotation if it exceeds the 'Max freecam distance'.");
LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(FreeCamConfigEntryResetDistance, new BoolCheckBoxOptions
{
RequiresRestart = false
}));
FreeCamConfigEntryInt = ((BaseUnityPlugin)this).Config.Bind<int>("Transform", "Max freecam distance", 100, "The maximum distance (in meters) the freecam can be from the player when activating freecam before it resets.");
ConfigEntry<int> freeCamConfigEntryInt = FreeCamConfigEntryInt;
IntSliderOptions val = new IntSliderOptions();
((BaseRangeOptions<int>)val).Min = 10;
((BaseRangeOptions<int>)val).Max = 300;
((BaseOptions)val).RequiresRestart = false;
LethalConfigManager.AddConfigItem((BaseConfigItem)new IntSliderConfigItem(freeCamConfigEntryInt, val));
FreeCamConfigEntry = ((BaseUnityPlugin)this).Config.Bind<bool>("Speed", "Reset speed on freecam", false, "When enabled, the freecam movement speed resets to the default speed every time freecam is activated.");
LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(FreeCamConfigEntry, new BoolCheckBoxOptions
{
RequiresRestart = false
}));
FreeCamConfigEntryFloat = ((BaseUnityPlugin)this).Config.Bind<float>("Speed", "Default freecam speed", 5f, $"The base movement speed of the freecam. Scroll while in freecam to adjust speed (range: {0f} - {50f}, in steps of {0.5f}).");
FreeCamConfigEntryFloat.SettingChanged += delegate
{
FreeCamClass.UpdateSpeed(FreeCamConfigEntryFloat.Value);
};
ConfigEntry<float> freeCamConfigEntryFloat = FreeCamConfigEntryFloat;
FloatStepSliderOptions val2 = new FloatStepSliderOptions();
((BaseRangeOptions<float>)val2).Min = 0f;
((BaseRangeOptions<float>)val2).Max = 50f;
val2.Step = 0.5f;
((BaseOptions)val2).RequiresRestart = false;
LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatStepSliderConfigItem(freeCamConfigEntryFloat, val2));
FreeCamConfigEntryFloatOpacity = ((BaseUnityPlugin)this).Config.Bind<float>("UI", "Opacity", 0.9f, "Controls the UI opacity while in freecam");
FreeCamConfigEntryFloatOpacity.SettingChanged += delegate
{
FreeCamHUD.UpdateOpacity(FreeCamConfigEntryFloatOpacity.Value);
};
ConfigEntry<float> freeCamConfigEntryFloatOpacity = FreeCamConfigEntryFloatOpacity;
FloatStepSliderOptions val3 = new FloatStepSliderOptions();
((BaseRangeOptions<float>)val3).Min = 0.05f;
((BaseRangeOptions<float>)val3).Max = 1f;
val3.Step = 0.05f;
((BaseOptions)val3).RequiresRestart = false;
LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatStepSliderConfigItem(freeCamConfigEntryFloatOpacity, val3));
FreeCamConfigEntryDefaultUIVisiblity = ((BaseUnityPlugin)this).Config.Bind<bool>("UI", "Is UI visible by default", true, "When enabled, the freecam UI will be visible by default.");
LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(FreeCamConfigEntryDefaultUIVisiblity, new BoolCheckBoxOptions
{
RequiresRestart = false
}));
FreeCamConfigEntryHideUI = ((BaseUnityPlugin)this).Config.Bind<bool>("UI", "Reset UI visibility on freecam", false, "When enabled, the freecam UI resets to the default visibility every time freecam is activated.");
LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(FreeCamConfigEntryHideUI, new BoolCheckBoxOptions
{
RequiresRestart = false
}));
FreeCamConfigDisableShowWarningReset = ((BaseUnityPlugin)this).Config.Bind<bool>("Warnings", "Disable showing reset transform warning", false, "When enabled, the freecam UI will never show the reset transform warning on screen.");
LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(FreeCamConfigDisableShowWarningReset, new BoolCheckBoxOptions
{
RequiresRestart = false
}));
FreeCamConfigDisableShowWarningDistance = ((BaseUnityPlugin)this).Config.Bind<bool>("Warnings", "Disable showing distance warning", false, "When enabled, the freecam UI will never show the far away distance warning on screen.");
LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(FreeCamConfigDisableShowWarningDistance, new BoolCheckBoxOptions
{
RequiresRestart = false
}));
harmony.PatchAll(typeof(SimpleFreeCamPatchBase));
harmony.PatchAll(typeof(StartOfRoundPatch));
harmony.PatchAll(typeof(PlayerControllerPatch));
harmony.PatchAll(typeof(VehicleControllerPatch));
harmony.PatchAll(typeof(HUDManagerPatch));
harmony.PatchAll(typeof(NetworkPatch));
logSource.LogInfo((object)"Simple Freecam (version - 1.4.0.0): patches applied successfully");
}
}
}
namespace SimpleFreeCam.UI
{
internal class FreeCamHUD : MonoBehaviour
{
internal enum WarningReason
{
None,
DistanceWarning,
ResetWarning
}
private GameObject hudCanvasObj;
private Image statsBorder;
private Image statsBackground;
private TextMeshProUGUI statsText;
private Image warningBorder;
private Image warningBackground;
private TextMeshProUGUI warningText;
private static float ColorAlpha = 1f;
private static Color Blackish_Background = new Color(0.04f, 0.04f, 0.04f, ColorAlpha);
private static Color Green_Outline = new Color(0.49f, 0.82f, 0.49f, ColorAlpha);
private static Color Green_Text = new Color(0.27f, 0.47f, 0.27f, ColorAlpha);
private static Color Orange_Outline;
private static Color Orange_Text;
private static Color Distance_Outline;
private static Color Distance_Text;
private static Color Reset_Outline;
private static Color Reset_Text;
private static bool ShowDistanceWarning = false;
private static bool ShouldHideUI = false;
private static WarningReason currentWarningReason = WarningReason.None;
private const float BoxWidth = 300f;
private const float BoxHeight = 112f;
private const float BottomMargin = 100f;
private const float BorderSize = 4f;
private const float Warning_BoxWidth = 540f;
private const float Warning_BoxHeight = 80f;
private const float Warning_BottomMargin = 250f;
private const float Warning_BorderSize = 2f;
private const int Text_Fontsize = 20;
private static readonly string[] WarningStrings = new string[3] { "! NO WARNING TO DISPLAY !\n<size=75%>! THIS MUST BE AN ERROR !</size>", "! FREECAM TOO FAR FROM PLAYER !\n<size=75%>! MOVE CLOSER OR THE FREECAM WILL TELEPORT TO THE PLAYER ON NEXT USE !</size>", "! RESET FREECAM TRANSFORM ENABLED !\n<size=75%>! THE FREECAM WILL TELEPORT TO THE PLAYER ON NEXT USE !</size>" };
internal static FreeCamHUD Instance { get; private set; }
private static void InitializeColors()
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: 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_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: 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_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: 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_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
Orange_Outline = ShiftHue(Green_Outline, 0.72f);
Orange_Text = ShiftHue(Green_Text, 0.72f);
Distance_Outline = ShiftHue(Green_Outline, 0.8f);
Distance_Text = ShiftHue(Green_Text, 0.8f);
Reset_Outline = ShiftHue(Green_Outline, 0.41f);
Reset_Text = ShiftHue(Green_Text, 0.41f);
}
private static Color ShiftHue(Color color, float hueShift)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
float num2 = default(float);
float num3 = default(float);
float num = default(float);
Color.RGBToHSV(color, ref num, ref num2, ref num3);
num = (num + hueShift) % 1f;
return Color.HSVToRGB(num, num2, num3);
}
public static void HideUI_performed(CallbackContext obj)
{
if (((CallbackContext)(ref obj)).performed && FreeCamClass.isInFreeCam)
{
ShouldHideUI = !ShouldHideUI;
}
}
private void Awake()
{
if ((Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this)
{
Object.Destroy((Object)(object)this);
return;
}
Instance = this;
Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
InitializeColors();
CreateTMPUI();
UpdateOpacity(SimpleFreeCamPatchBase.instance.FreeCamConfigEntryFloatOpacity.Value);
}
private void OnDestroy()
{
if ((Object)(object)Instance == (Object)(object)this)
{
Instance = null;
}
}
public static void TriggerDistanceWarning(bool doWarning)
{
ShowDistanceWarning = doWarning;
}
private static bool ShouldShowWarning()
{
if (!SimpleFreeCamPatchBase.instance.FreeCamConfigDisableShowWarningReset.Value && SimpleFreeCamPatchBase.instance.FreeCamConfigEntryResetTransform.Value)
{
currentWarningReason = WarningReason.ResetWarning;
return true;
}
if (!SimpleFreeCamPatchBase.instance.FreeCamConfigDisableShowWarningDistance.Value && ShowDistanceWarning)
{
currentWarningReason = WarningReason.DistanceWarning;
return true;
}
return false;
}
private void Update()
{
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
bool flag = FreeCamClass.isInFreeCam;
if (flag)
{
flag = ((!SimpleFreeCamPatchBase.instance.FreeCamConfigEntryDefaultUIVisiblity.Value) ? ShouldHideUI : (!ShouldHideUI));
}
if (hudCanvasObj.activeSelf != flag)
{
hudCanvasObj.SetActive(flag);
}
if (flag)
{
bool lockFreeCam = FreeCamClass.lockFreeCam;
((Graphic)statsBorder).color = (lockFreeCam ? Orange_Outline : Green_Outline);
((Graphic)statsBackground).color = Blackish_Background;
((Graphic)statsText).color = (lockFreeCam ? Orange_Text : Green_Text);
string arg = (lockFreeCam ? "LOCKED" : "UNLOCKED");
((TMP_Text)statsText).text = $"FOV: {FreeCamClass.GetFreecamFOV():F1}\nSpeed: {FreeCamClass.GetSpeed():F2}x\nFreecam {arg}";
bool flag2 = ShouldShowWarning();
UpdateWarningColorsAndText();
if (((Component)warningBorder).gameObject.activeSelf != flag2)
{
((Component)warningBorder).gameObject.SetActive(flag2);
}
}
}
public static void UpdateOpacity(float newOpacity)
{
UpdateOpacity(newOpacity, onlyWarning: false);
}
private static void UpdateOpacity(float newOpacity, bool onlyWarning)
{
if ((Object)(object)Instance != (Object)null)
{
Instance.UpdateStaticColors();
}
float a = newOpacity - 0.3f;
if (!onlyWarning)
{
ColorAlpha = newOpacity;
Blackish_Background.a = newOpacity;
Green_Outline.a = a;
Green_Text.a = newOpacity;
Orange_Outline.a = a;
Orange_Text.a = newOpacity;
}
Distance_Outline.a = a;
Distance_Text.a = newOpacity;
Reset_Outline.a = a;
Reset_Text.a = newOpacity;
}
public static void ResetHideUI()
{
if (SimpleFreeCamPatchBase.instance.FreeCamConfigEntryHideUI.Value)
{
ShouldHideUI = false;
}
}
private void UpdateWarningColorsAndText()
{
((TMP_Text)warningText).text = GetWarningText();
UpdateOpacity(SimpleFreeCamPatchBase.instance.FreeCamConfigEntryFloatOpacity.Value);
}
private static string GetWarningText()
{
int num = (int)currentWarningReason;
if (num >= 0 && num < WarningStrings.Length)
{
return WarningStrings[num];
}
return WarningStrings[0];
}
private static Color GetWarningColor(int index)
{
//IL_001b: 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_002a: 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_0044: Unknown result type (might be due to invalid IL or missing references)
bool flag = currentWarningReason == WarningReason.DistanceWarning;
switch (index)
{
case 0:
if (!flag)
{
return Reset_Outline;
}
return Distance_Outline;
case 1:
if (!flag)
{
return Reset_Text;
}
return Distance_Text;
default:
return new Color(0f, 0f, 0f, 0f);
}
}
private void CreateTMPUI()
{
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Expected O, but got Unknown
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
//IL_0107: Unknown result type (might be due to invalid IL or missing references)
//IL_011c: Unknown result type (might be due to invalid IL or missing references)
//IL_0130: Unknown result type (might be due to invalid IL or missing references)
//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
//IL_022c: Unknown result type (might be due to invalid IL or missing references)
TMP_FontAsset font = ((IEnumerable<TMP_FontAsset>)Resources.FindObjectsOfTypeAll<TMP_FontAsset>()).FirstOrDefault((Func<TMP_FontAsset, bool>)((TMP_FontAsset f) => ((Object)f).name.Contains("3270")));
hudCanvasObj = new GameObject("FreeCamTMPCanvas");
hudCanvasObj.transform.SetParent(((Component)this).transform);
Canvas obj = hudCanvasObj.AddComponent<Canvas>();
obj.renderMode = (RenderMode)0;
obj.sortingOrder = 100;
CanvasScaler obj2 = hudCanvasObj.AddComponent<CanvasScaler>();
obj2.uiScaleMode = (ScaleMode)1;
obj2.referenceResolution = new Vector2(1920f, 1080f);
obj2.matchWidthOrHeight = 1f;
statsBorder = CreateUIBox(hudCanvasObj.transform, "StatsBorder", 308f, 120f, 96f);
statsBackground = CreateUIBox(((Component)statsBorder).transform, "StatsBackground", 300f, 112f, 0f);
RectTransform component = ((Component)statsBackground).GetComponent<RectTransform>();
component.anchorMin = Vector2.zero;
component.anchorMax = Vector2.one;
component.offsetMin = new Vector2(4f, 4f);
component.offsetMax = new Vector2(-4f, -4f);
statsText = CreateUIText(((Component)statsBackground).transform, "StatsText", font);
warningBorder = CreateUIBox(hudCanvasObj.transform, "WarningBorder", 544f, 84f, 248f);
warningBackground = CreateUIBox(((Component)warningBorder).transform, "WarningBackground", 540f, 80f, 0f);
RectTransform component2 = ((Component)warningBackground).GetComponent<RectTransform>();
component2.anchorMin = Vector2.zero;
component2.anchorMax = Vector2.one;
component2.offsetMin = new Vector2(2f, 2f);
component2.offsetMax = new Vector2(-2f, -2f);
warningText = CreateUIText(((Component)warningBackground).transform, "WarningText", font);
((TMP_Text)warningText).text = WarningStrings[0];
((Graphic)warningBackground).color = Blackish_Background;
UpdateStaticColors();
hudCanvasObj.SetActive(false);
}
private void UpdateStaticColors()
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)warningBorder != (Object)null)
{
((Graphic)warningBorder).color = GetWarningColor(0);
}
if ((Object)(object)warningText != (Object)null)
{
((Graphic)warningText).color = GetWarningColor(1);
}
}
private Image CreateUIBox(Transform parent, string name, float width, float height, float yOffset)
{
//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_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: 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_004d: 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_0073: Unknown result type (might be due to invalid IL or missing references)
GameObject val = new GameObject(name);
val.transform.SetParent(parent, false);
Image result = val.AddComponent<Image>();
RectTransform component = val.GetComponent<RectTransform>();
component.sizeDelta = new Vector2(width, height);
component.anchorMin = new Vector2(0.5f, 0f);
component.anchorMax = new Vector2(0.5f, 0f);
component.pivot = new Vector2(0.5f, 0f);
component.anchoredPosition = new Vector2(0f, yOffset);
return result;
}
private TextMeshProUGUI CreateUIText(Transform parent, string name, TMP_FontAsset font)
{
//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_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
GameObject val = new GameObject(name);
val.transform.SetParent(parent, false);
TextMeshProUGUI val2 = val.AddComponent<TextMeshProUGUI>();
((TMP_Text)val2).alignment = (TextAlignmentOptions)544;
((TMP_Text)val2).fontSize = 20f;
((TMP_Text)val2).fontStyle = (FontStyles)1;
if ((Object)(object)font != (Object)null)
{
((TMP_Text)val2).font = font;
}
RectTransform component = val.GetComponent<RectTransform>();
component.anchorMin = Vector2.zero;
component.anchorMax = Vector2.one;
component.sizeDelta = Vector2.zero;
component.anchoredPosition = Vector2.zero;
return val2;
}
}
}
namespace SimpleFreeCam.Patches
{
[HarmonyPatch(typeof(HUDManager))]
internal static class HUDManagerPatch
{
private static MethodInfo MethodDisableScanElementsCached;
[HarmonyPatch("PingScan_performed")]
[HarmonyPrefix]
[HarmonyPriority(0)]
private static bool DisableScanning(HUDManager __instance)
{
if (!FreeCamClass.isInFreeCam || FreeCamClass.lockFreeCam)
{
return true;
}
return false;
}
[HarmonyPatch("Update")]
[HarmonyPostfix]
[HarmonyPriority(0)]
private static void DisableScanHUD(HUDManager __instance)
{
if (FreeCamClass.isInFreeCam)
{
if (MethodDisableScanElementsCached == null)
{
MethodDisableScanElementsCached = typeof(HUDManager).GetMethod("DisableAllScanElements", BindingFlags.Instance | BindingFlags.NonPublic);
}
MethodDisableScanElementsCached?.Invoke(__instance, null);
}
}
}
[HarmonyPatch(typeof(NetworkManager))]
internal static class NetworkPatch
{
[HarmonyPostfix]
[HarmonyPatch("SetSingleton")]
private static void RegisterPrefab()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Expected O, but got Unknown
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
GameObject val = new GameObject("PixelIndieDev_SimpleFreeCam Prefab");
((Object)val).hideFlags = (HideFlags)(((Object)val).hideFlags | 0x3D);
Object.DontDestroyOnLoad((Object)(object)val);
NetworkObject obj = val.AddComponent<NetworkObject>();
typeof(NetworkObject).GetField("GlobalObjectIdHash", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(obj, GetHash("PixelIndieDev_SimpleFreeCam"));
NetworkManager.Singleton.PrefabHandler.AddNetworkPrefab(val);
}
private static uint GetHash(string value)
{
return value?.Aggregate(17u, (uint current, char c) => (current * 31) ^ c) ?? 0;
}
}
[HarmonyPatch(typeof(PlayerControllerB))]
internal static class PlayerControllerPatch
{
[CompilerGenerated]
private sealed class <InjectMoveInputZero>d__3 : IEnumerable<CodeInstruction>, IEnumerable, IEnumerator<CodeInstruction>, IDisposable, IEnumerator
{
private int <>1__state;
private CodeInstruction <>2__current;
private int <>l__initialThreadId;
private IEnumerable<CodeInstruction> instructions;
public IEnumerable<CodeInstruction> <>3__instructions;
private FieldInfo <moveInputVectorField>5__2;
private MethodInfo <helperMethod>5__3;
private bool <patched>5__4;
private IEnumerator<CodeInstruction> <>7__wrap4;
private CodeInstruction <instruction>5__6;
CodeInstruction IEnumerator<CodeInstruction>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <InjectMoveInputZero>d__3(int <>1__state)
{
this.<>1__state = <>1__state;
<>l__initialThreadId = Environment.CurrentManagedThreadId;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
int num = <>1__state;
if (num == -3 || (uint)(num - 1) <= 2u)
{
try
{
}
finally
{
<>m__Finally1();
}
}
<moveInputVectorField>5__2 = null;
<helperMethod>5__3 = null;
<>7__wrap4 = null;
<instruction>5__6 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0128: Unknown result type (might be due to invalid IL or missing references)
//IL_0132: Expected O, but got Unknown
//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0109: Expected O, but got Unknown
try
{
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<moveInputVectorField>5__2 = AccessTools.Field(typeof(PlayerControllerB), "moveInputVector");
<helperMethod>5__3 = AccessTools.Method(typeof(PlayerControllerPatch), "ZeroMoveInputIfFreecam", (Type[])null, (Type[])null);
<patched>5__4 = false;
<>7__wrap4 = instructions.GetEnumerator();
<>1__state = -3;
break;
case 1:
<>1__state = -3;
if (!<patched>5__4 && <instruction>5__6.opcode == OpCodes.Stfld && (FieldInfo)<instruction>5__6.operand == <moveInputVectorField>5__2)
{
<>2__current = new CodeInstruction(OpCodes.Ldarg_0, (object)null);
<>1__state = 2;
return true;
}
goto IL_014c;
case 2:
<>1__state = -3;
<>2__current = new CodeInstruction(OpCodes.Call, (object)<helperMethod>5__3);
<>1__state = 3;
return true;
case 3:
{
<>1__state = -3;
<patched>5__4 = true;
goto IL_014c;
}
IL_014c:
<instruction>5__6 = null;
break;
}
if (<>7__wrap4.MoveNext())
{
<instruction>5__6 = <>7__wrap4.Current;
<>2__current = <instruction>5__6;
<>1__state = 1;
return true;
}
<>m__Finally1();
<>7__wrap4 = null;
return false;
}
catch
{
//try-fault
((IDisposable)this).Dispose();
throw;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
private void <>m__Finally1()
{
<>1__state = -1;
if (<>7__wrap4 != null)
{
<>7__wrap4.Dispose();
}
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
[DebuggerHidden]
IEnumerator<CodeInstruction> IEnumerable<CodeInstruction>.GetEnumerator()
{
<InjectMoveInputZero>d__3 <InjectMoveInputZero>d__;
if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
{
<>1__state = 0;
<InjectMoveInputZero>d__ = this;
}
else
{
<InjectMoveInputZero>d__ = new <InjectMoveInputZero>d__3(0);
}
<InjectMoveInputZero>d__.instructions = <>3__instructions;
return <InjectMoveInputZero>d__;
}
[DebuggerHidden]
IEnumerator IEnumerable.GetEnumerator()
{
return ((IEnumerable<CodeInstruction>)this).GetEnumerator();
}
}
private static int originalSensitivity = -1;
private static Vector3 compassPositionBeforeUpdate;
[HarmonyPatch("Update")]
[HarmonyPrefix]
[HarmonyPriority(0)]
private static void SaveCompassPosition(PlayerControllerB __instance)
{
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
if (((NetworkBehaviour)__instance).IsOwner && (Object)(object)__instance == (Object)(object)StartOfRound.Instance.localPlayerController && FreeCamClass.isInFreeCam)
{
compassPositionBeforeUpdate = StartOfRound.Instance.freeCinematicCameraTurnCompass.position;
}
}
[IteratorStateMachine(typeof(<InjectMoveInputZero>d__3))]
[HarmonyPatch("Update")]
[HarmonyTranspiler]
[HarmonyPriority(0)]
private static IEnumerable<CodeInstruction> InjectMoveInputZero(IEnumerable<CodeInstruction> instructions)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <InjectMoveInputZero>d__3(-2)
{
<>3__instructions = instructions
};
}
private static void ZeroMoveInputIfFreecam(PlayerControllerB instance)
{
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
if (instance.isFreeCamera)
{
instance.moveInputVector = Vector2.zero;
}
}
[HarmonyPatch("Update")]
[HarmonyPostfix]
[HarmonyPriority(0)]
private static void ApplyFreecamMovement(PlayerControllerB __instance)
{
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: 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)
//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
//IL_00da: Unknown result type (might be due to invalid IL or missing references)
//IL_00df: Unknown result type (might be due to invalid IL or missing references)
//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0127: Unknown result type (might be due to invalid IL or missing references)
//IL_012d: Unknown result type (might be due to invalid IL or missing references)
//IL_013d: Unknown result type (might be due to invalid IL or missing references)
//IL_0165: Unknown result type (might be due to invalid IL or missing references)
//IL_016b: Unknown result type (might be due to invalid IL or missing references)
//IL_017b: Unknown result type (might be due to invalid IL or missing references)
if (!((NetworkBehaviour)__instance).IsOwner || (Object)(object)__instance != (Object)(object)StartOfRound.Instance.localPlayerController || !FreeCamClass.isInFreeCam)
{
return;
}
if (__instance.inTerminalMenu || __instance.isTypingChat)
{
FreeCamClass.DisableFreecam();
return;
}
FreeCamClass.TickDistanceWarning();
if (FreeCamClass.lockFreeCam)
{
return;
}
Transform freeCinematicCameraTurnCompass = StartOfRound.Instance.freeCinematicCameraTurnCompass;
freeCinematicCameraTurnCompass.position = compassPositionBeforeUpdate;
Vector2 val = IngamePlayerSettings.Instance.playerInput.actions.FindAction("Move", false).ReadValue<Vector2>();
float num = IngamePlayerSettings.Instance.playerInput.actions.FindAction("Sprint", false).ReadValue<float>();
if (!(((Vector2)(ref val)).sqrMagnitude < 0.01f))
{
float num2 = FreeCamClass.GetSpeed();
if (num > 0.5f)
{
num2 *= 2f;
}
freeCinematicCameraTurnCompass.position += (freeCinematicCameraTurnCompass.right * val.x + freeCinematicCameraTurnCompass.forward * val.y) * num2 * Time.deltaTime;
((Component)StartOfRound.Instance.freeCinematicCamera).transform.position = Vector3.Lerp(((Component)StartOfRound.Instance.freeCinematicCamera).transform.position, freeCinematicCameraTurnCompass.position, 3f * Time.deltaTime);
((Component)StartOfRound.Instance.freeCinematicCamera).transform.rotation = Quaternion.Slerp(((Component)StartOfRound.Instance.freeCinematicCamera).transform.rotation, freeCinematicCameraTurnCompass.rotation, 3f * Time.deltaTime);
}
}
[HarmonyPatch("KillPlayer")]
[HarmonyPostfix]
[HarmonyPriority(0)]
private static void OnPlayerDeath(PlayerControllerB __instance)
{
if (((NetworkBehaviour)__instance).IsOwner && __instance.isFreeCamera)
{
FreeCamClass.DisableFreecam();
}
}
[HarmonyPatch("ScrollMouse_performed")]
[HarmonyPrefix]
[HarmonyPriority(0)]
private static bool InterceptScroll(PlayerControllerB __instance, CallbackContext context)
{
if (!((NetworkBehaviour)__instance).IsOwner || (Object)(object)__instance != (Object)(object)StartOfRound.Instance.localPlayerController)
{
return true;
}
if (!((CallbackContext)(ref context)).performed)
{
return true;
}
if (!FreeCamClass.isInFreeCam || FreeCamClass.lockFreeCam)
{
return true;
}
float num = Mathf.Clamp(((CallbackContext)(ref context)).ReadValue<float>(), -1f, 1f);
if (num == 0f)
{
return false;
}
if (FreeCamClass.shouldChangeFOV)
{
FreeCamClass.AdjustFOV((num > 0f) ? (-1f) : 1f);
}
else
{
FreeCamClass.AdjustSpeed(num);
}
return false;
}
[HarmonyPatch("LateUpdate")]
[HarmonyPostfix]
[HarmonyPriority(0)]
private static void FreecamLateUpdatePatch(PlayerControllerB __instance)
{
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
if (FreeCamClass.isInFreeCam && !FreeCamClass.lockFreeCam && !((Object)(object)__instance != (Object)(object)StartOfRound.Instance.localPlayerController))
{
Transform freeCinematicCameraTurnCompass = StartOfRound.Instance.freeCinematicCameraTurnCompass;
((Component)StartOfRound.Instance.freeCinematicCamera).transform.rotation = freeCinematicCameraTurnCompass.rotation;
((Component)StartOfRound.Instance.freeCinematicCamera).transform.position = freeCinematicCameraTurnCompass.position;
}
}
[HarmonyPatch("PlayerLookInput")]
[HarmonyPrefix]
[HarmonyPriority(0)]
private static void PlayerLookInputPatch(PlayerControllerB __instance)
{
if (!((Object)(object)__instance != (Object)(object)StartOfRound.Instance.localPlayerController) && FreeCamClass.isInFreeCam && !FreeCamClass.lockFreeCam)
{
originalSensitivity = IngamePlayerSettings.Instance.settings.lookSensitivity;
IngamePlayerSettings.Instance.settings.lookSensitivity = Mathf.Clamp(Mathf.RoundToInt((float)IngamePlayerSettings.Instance.settings.lookSensitivity * FreeCamClass.GetFOVSensitivityMultiplier()), 1, originalSensitivity);
}
}
[HarmonyPatch("PlayerLookInput")]
[HarmonyPostfix]
[HarmonyPriority(0)]
private static void Postfix(PlayerControllerB __instance)
{
if (!((Object)(object)__instance != (Object)(object)StartOfRound.Instance.localPlayerController) && FreeCamClass.isInFreeCam && !FreeCamClass.lockFreeCam)
{
IngamePlayerSettings.Instance.settings.lookSensitivity = originalSensitivity;
}
}
[HarmonyPatch("Crouch_performed")]
[HarmonyPrefix]
[HarmonyPriority(0)]
private static bool PatchCrouch(PlayerControllerB __instance)
{
if ((Object)(object)__instance != (Object)(object)StartOfRound.Instance.localPlayerController)
{
return true;
}
if (!FreeCamClass.isInFreeCam || FreeCamClass.lockFreeCam)
{
return true;
}
return false;
}
[HarmonyPatch("Jump_performed")]
[HarmonyPrefix]
[HarmonyPriority(0)]
private static bool PatchJump(PlayerControllerB __instance)
{
if ((Object)(object)__instance != (Object)(object)StartOfRound.Instance.localPlayerController)
{
return true;
}
if (!FreeCamClass.isInFreeCam || FreeCamClass.lockFreeCam)
{
return true;
}
return false;
}
[HarmonyPatch("Interact_performed")]
[HarmonyPrefix]
[HarmonyPriority(0)]
private static bool PatchInteract(PlayerControllerB __instance)
{
if ((Object)(object)__instance != (Object)(object)StartOfRound.Instance.localPlayerController)
{
return true;
}
if (!FreeCamClass.isInFreeCam || FreeCamClass.lockFreeCam)
{
return true;
}
return false;
}
[HarmonyPatch("ClickHoldInteraction")]
[HarmonyPrefix]
[HarmonyPriority(0)]
private static bool BlockHoldInteract(PlayerControllerB __instance)
{
if ((Object)(object)__instance != (Object)(object)StartOfRound.Instance.localPlayerController)
{
return true;
}
if (!FreeCamClass.isInFreeCam || FreeCamClass.lockFreeCam)
{
return true;
}
return false;
}
[HarmonyPatch("ItemSecondaryUse_performed")]
[HarmonyPrefix]
[HarmonyPriority(0)]
private static bool PatchItemSecUSe(PlayerControllerB __instance)
{
if ((Object)(object)__instance != (Object)(object)StartOfRound.Instance.localPlayerController)
{
return true;
}
if (!FreeCamClass.isInFreeCam || FreeCamClass.lockFreeCam)
{
return true;
}
return false;
}
[HarmonyPatch("ItemTertiaryUse_performed")]
[HarmonyPrefix]
[HarmonyPriority(0)]
private static bool PatchTertiary(PlayerControllerB __instance)
{
if ((Object)(object)__instance != (Object)(object)StartOfRound.Instance.localPlayerController)
{
return true;
}
if (!FreeCamClass.isInFreeCam || FreeCamClass.lockFreeCam)
{
return true;
}
return false;
}
[HarmonyPatch("ActivateItem_performed")]
[HarmonyPrefix]
[HarmonyPriority(0)]
private static bool PatchActivateItemPerf(PlayerControllerB __instance)
{
if ((Object)(object)__instance != (Object)(object)StartOfRound.Instance.localPlayerController)
{
return true;
}
if (!FreeCamClass.isInFreeCam || FreeCamClass.lockFreeCam)
{
return true;
}
return false;
}
[HarmonyPatch("ActivateItem_canceled")]
[HarmonyPrefix]
[HarmonyPriority(0)]
private static bool PatchActivateItemCanc(PlayerControllerB __instance)
{
if ((Object)(object)__instance != (Object)(object)StartOfRound.Instance.localPlayerController)
{
return true;
}
if (!FreeCamClass.isInFreeCam || FreeCamClass.lockFreeCam)
{
return true;
}
return false;
}
[HarmonyPatch("Discard_performed")]
[HarmonyPrefix]
[HarmonyPriority(0)]
private static bool PatchDiscard(PlayerControllerB __instance)
{
if ((Object)(object)__instance != (Object)(object)StartOfRound.Instance.localPlayerController)
{
return true;
}
if (!FreeCamClass.isInFreeCam || FreeCamClass.lockFreeCam)
{
return true;
}
return false;
}
[HarmonyPatch("ScrollMouse_performed")]
[HarmonyPrefix]
[HarmonyPriority(0)]
private static bool PatchScroll(PlayerControllerB __instance)
{
if ((Object)(object)__instance != (Object)(object)StartOfRound.Instance.localPlayerController)
{
return true;
}
if (!FreeCamClass.isInFreeCam || FreeCamClass.lockFreeCam)
{
return true;
}
return false;
}
[HarmonyPatch("InspectItem_performed")]
[HarmonyPrefix]
[HarmonyPriority(0)]
private static bool PatchInspect(PlayerControllerB __instance)
{
if ((Object)(object)__instance != (Object)(object)StartOfRound.Instance.localPlayerController)
{
return true;
}
if (!FreeCamClass.isInFreeCam || FreeCamClass.lockFreeCam)
{
return true;
}
return false;
}
[HarmonyPatch("Emote1_performed")]
[HarmonyPrefix]
[HarmonyPriority(0)]
private static bool PatchEmote1(PlayerControllerB __instance)
{
if ((Object)(object)__instance != (Object)(object)StartOfRound.Instance.localPlayerController)
{
return true;
}
if (!FreeCamClass.isInFreeCam || FreeCamClass.lockFreeCam)
{
return true;
}
return false;
}
[HarmonyPatch("Emote2_performed")]
[HarmonyPrefix]
[HarmonyPriority(0)]
private static bool PatchEmote2(PlayerControllerB __instance)
{
if ((Object)(object)__instance != (Object)(object)StartOfRound.Instance.localPlayerController)
{
return true;
}
if (!FreeCamClass.isInFreeCam || FreeCamClass.lockFreeCam)
{
return true;
}
return false;
}
[HarmonyPatch("UseUtilitySlot_performed")]
[HarmonyPrefix]
[HarmonyPriority(0)]
private static bool PatchUtility(PlayerControllerB __instance)
{
if ((Object)(object)__instance != (Object)(object)StartOfRound.Instance.localPlayerController)
{
return true;
}
if (!FreeCamClass.isInFreeCam || FreeCamClass.lockFreeCam)
{
return true;
}
return false;
}
[HarmonyPatch("SetHoverTipAndCurrentInteractTrigger")]
[HarmonyPrefix]
[HarmonyPriority(0)]
private static bool BlockHoverTip(PlayerControllerB __instance)
{
if ((Object)(object)__instance != (Object)(object)StartOfRound.Instance.localPlayerController)
{
return true;
}
if (!FreeCamClass.isInFreeCam || FreeCamClass.lockFreeCam)
{
return true;
}
if ((Object)(object)__instance.hoveringOverTrigger != (Object)null)
{
__instance.hoveringOverTrigger.StopInteraction();
__instance.previousHoveringOverTrigger = __instance.hoveringOverTrigger;
__instance.hoveringOverTrigger = null;
}
((Behaviour)__instance.cursorIcon).enabled = false;
((TMP_Text)__instance.cursorTip).text = "";
return false;
}
}
[HarmonyPatch(typeof(StartOfRound))]
internal static class StartOfRoundPatch
{
[HarmonyPatch("Start")]
[HarmonyPostfix]
[HarmonyPriority(0)]
private static void OnGameEntered(StartOfRound __instance)
{
((MonoBehaviour)__instance).StartCoroutine(FreeCamClass.SetupFreecam());
}
[HarmonyPatch("ChangeLevel")]
[HarmonyPostfix]
[HarmonyPriority(0)]
private static void OnChangeLevel(StartOfRound __instance)
{
FreeCamClass.isInMenu = false;
FreeCamClass.ResetFreeCam();
}
[HarmonyPatch("OnLocalDisconnect")]
[HarmonyPostfix]
[HarmonyPriority(0)]
private static void OnDisconnect(StartOfRound __instance)
{
FreeCamClass.isInMenu = true;
FreeCamClass.DisableFreecam();
}
}
[HarmonyPatch(typeof(VehicleController))]
internal static class VehicleControllerPatch
{
[HarmonyPatch("GetVehicleInput")]
[HarmonyPrefix]
[HarmonyPriority(0)]
private static bool BlockVehicleInput(VehicleController __instance)
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
if (!__instance.localPlayerInControl)
{
return true;
}
if (!FreeCamClass.isInFreeCam)
{
return true;
}
if (!FreeCamClass.lockFreeCam)
{
__instance.moveInputVector = Vector2.zero;
__instance.drivePedalPressed = false;
__instance.brakePedalPressed = false;
return false;
}
return true;
}
[HarmonyPatch("DoTurboBoost")]
[HarmonyPrefix]
[HarmonyPriority(0)]
private static bool BlockTurboBoost(VehicleController __instance)
{
if (!__instance.localPlayerInControl)
{
return true;
}
if (!FreeCamClass.isInFreeCam || FreeCamClass.lockFreeCam)
{
return true;
}
return false;
}
}
}
namespace SimpleFreeCam.Input
{
public class SimpleFreeCamInputs : LcInputActions
{
[InputAction(/*Could not decode attribute arguments.*/)]
public InputAction PixelIndieDev_FreeCamKey { get; set; }
[InputAction(/*Could not decode attribute arguments.*/)]
public InputAction PixelIndieDev_FreeCamMovementKey { get; set; }
[InputAction(/*Could not decode attribute arguments.*/)]
public InputAction PixelIndieDev_FreeCamTeleportToPlayerKey { get; set; }
[InputAction(/*Could not decode attribute arguments.*/)]
public InputAction PixelIndieDev_FreeCamFOVModifierKey { get; set; }
[InputAction(/*Could not decode attribute arguments.*/)]
public InputAction PixelIndieDev_FreeCamResetFOVKey { get; set; }
[InputAction(/*Could not decode attribute arguments.*/)]
public InputAction PixelIndieDev_FreeCamHideUI { get; set; }
}
}