using System;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using Configgy;
using HydraDynamics.CameraTools;
using Microsoft.CodeAnalysis;
using Ultracam.CameraTools;
using UnityEngine;
using UnityEngine.SceneManagement;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("Ultracam")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("A simple freecam mod")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+f9245008a805da3c3bfe0b85e05c9d22253e3ccb")]
[assembly: AssemblyProduct("Ultracam")]
[assembly: AssemblyTitle("Ultracam")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace HydraDynamics
{
[BepInPlugin("Hydraxous.ULTRAKILL.Ultracam", "Ultracam", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
private ConfigBuilder configBuilder;
public const string PLUGIN_NAME = "Ultracam";
public const string PLUGIN_VERSION = "1.0.0";
public const string PLUGIN_GUID = "Hydraxous.ULTRAKILL.Ultracam";
private void Awake()
{
//IL_0004: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Expected O, but got Unknown
configBuilder = new ConfigBuilder((string)null, (string)null);
configBuilder.Build();
((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin Ultracam is loaded!");
SceneManager.sceneLoaded += SceneManager_sceneLoaded;
}
private void SceneManager_sceneLoaded(Scene arg0, LoadSceneMode arg1)
{
if (!(SceneHelper.CurrentScene != "Main Menu"))
{
CameraHandler.Load();
}
}
}
}
namespace HydraDynamics.CameraTools
{
public class Freecam : MonoBehaviour
{
[Configgable("Binds/Control/StandardCamera", null, 0, null)]
private static ConfigKeybind toggleSmoothing = new ConfigKeybind((KeyCode)287);
[Configgable("Binds/Control/StandardCamera", null, 0, null)]
private static ConfigKeybind speedModifierButton = new ConfigKeybind((KeyCode)304);
[Configgable("Binds/Control/StandardCamera", null, 0, null)]
private static ConfigKeybind moveForward = new ConfigKeybind((KeyCode)119);
[Configgable("Binds/Control/StandardCamera", null, 0, null)]
private static ConfigKeybind moveBack = new ConfigKeybind((KeyCode)115);
[Configgable("Binds/Control/StandardCamera", null, 0, null)]
private static ConfigKeybind moveLeft = new ConfigKeybind((KeyCode)97);
[Configgable("Binds/Control/StandardCamera", null, 0, null)]
private static ConfigKeybind moveRight = new ConfigKeybind((KeyCode)100);
[Configgable("Binds/Control/StandardCamera", null, 0, null)]
private static ConfigKeybind moveUp = new ConfigKeybind((KeyCode)32);
[Configgable("Binds/Control/StandardCamera", null, 0, null)]
private static ConfigKeybind moveDown = new ConfigKeybind((KeyCode)306);
[Configgable("Binds/Control/StandardCamera", null, 0, null)]
private static ConfigKeybind rollLeft = new ConfigKeybind((KeyCode)113);
[Configgable("Binds/Control/StandardCamera", null, 0, null)]
private static ConfigKeybind rollRight = new ConfigKeybind((KeyCode)101);
[Configgable("Binds/Control/StandardCamera", null, 0, null)]
private static ConfigKeybind pitchUp = new ConfigKeybind((KeyCode)273);
[Configgable("Binds/Control/StandardCamera", null, 0, null)]
private static ConfigKeybind pitchDown = new ConfigKeybind((KeyCode)274);
[Configgable("Binds/Control/StandardCamera", null, 0, null)]
private static ConfigKeybind yawLeft = new ConfigKeybind((KeyCode)276);
[Configgable("Binds/Control/StandardCamera", null, 0, null)]
private static ConfigKeybind yawRight = new ConfigKeybind((KeyCode)275);
[Configgable("Binds/Control/StandardCamera", null, 0, null)]
private static ConfigKeybind zoomIn = new ConfigKeybind((KeyCode)61);
[Configgable("Binds/Control/StandardCamera", null, 0, null)]
private static ConfigKeybind zoomOut = new ConfigKeybind((KeyCode)45);
[Configgable("Settings/Control/StandardCamera", null, 0, null)]
private static ConfigInputField<float> zoomSpeed = new ConfigInputField<float>(60f, (Func<float, bool>)null, (Func<string, ValueTuple<bool, float>>)null);
[Configgable("Settings/Control/StandardCamera", null, 0, null)]
private static ConfigInputField<float> smoothingSpeed = new ConfigInputField<float>(1.5f, (Func<float, bool>)null, (Func<string, ValueTuple<bool, float>>)null);
[Configgable("Settings/Control/StandardCamera", null, 0, null)]
private static ConfigInputField<float> lookSpeed = new ConfigInputField<float>(128f, (Func<float, bool>)null, (Func<string, ValueTuple<bool, float>>)null);
[Configgable("Settings/Control/StandardCamera", null, 0, null)]
private static ConfigInputField<float> mouseLookSpeedMultiplier = new ConfigInputField<float>(1f, (Func<float, bool>)null, (Func<string, ValueTuple<bool, float>>)null);
[Configgable("Settings/Control/StandardCamera", null, 0, null)]
private static ConfigInputField<float> rollSpeed = new ConfigInputField<float>(40f, (Func<float, bool>)null, (Func<string, ValueTuple<bool, float>>)null);
[Configgable("Settings/Control/StandardCamera", null, 0, null)]
private static ConfigInputField<float> moveSpeed = new ConfigInputField<float>(12f, (Func<float, bool>)null, (Func<string, ValueTuple<bool, float>>)null);
[Configgable("Settings/Control/StandardCamera", null, 0, null)]
private static ConfigInputField<float> speedModifierMultiplier = new ConfigInputField<float>(2f, (Func<float, bool>)null, (Func<string, ValueTuple<bool, float>>)null);
private Transform cameraTransform;
private Camera camera;
private static float minZoom = 1E-05f;
private static float maxZoom = 179f;
private float currentZoom = 77f;
private Vector3 currentLocalRotation;
private Vector3 moveInput;
private Vector3 lookInput;
private float zoomInput;
private float smoothedZoom;
private bool speedModifierPressed = false;
private bool smoothing = false;
private Transform cameraTarget;
public void Init(CameraHandler handler)
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
cameraTransform = ((Component)this).transform;
camera = ((Component)this).GetComponent<Camera>();
cameraTarget = new GameObject("FreecamTarget").transform;
((Component)cameraTarget).transform.parent = ((Component)handler).transform;
}
private void Update()
{
GetInputs();
Look();
Move();
Zoom();
UpdateCameraTransform();
}
private void OnEnable()
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
if (((ConfigValueElement<bool>)(object)CameraHandler.positionFreecamToPlayerOnEnable).Value)
{
cameraTransform.position = ((Component)MonoSingleton<CameraController>.Instance).transform.position;
cameraTarget.position = ((Component)MonoSingleton<CameraController>.Instance).transform.position;
currentLocalRotation = ((Component)MonoSingleton<CameraController>.Instance).transform.eulerAngles;
cameraTarget.rotation = Quaternion.Euler(currentLocalRotation);
}
}
private void GetInputs()
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: 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)
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_0136: Unknown result type (might be due to invalid IL or missing references)
//IL_0145: Unknown result type (might be due to invalid IL or missing references)
//IL_014a: Unknown result type (might be due to invalid IL or missing references)
//IL_0151: Unknown result type (might be due to invalid IL or missing references)
//IL_0186: Unknown result type (might be due to invalid IL or missing references)
//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
if (CameraHandler.resetCameraPositionToPlayer.WasPeformed())
{
cameraTarget.position = ((Component)MonoSingleton<CameraController>.Instance).transform.position;
cameraTransform.position = ((Component)MonoSingleton<CameraController>.Instance).transform.position;
}
if (CameraHandler.resetCameraRotation.WasPeformed())
{
currentLocalRotation = Vector3.zero;
cameraTarget.rotation = Quaternion.identity;
}
if (toggleSmoothing.WasPeformed())
{
smoothing = !smoothing;
}
moveInput.z = (moveForward.IsPressed() ? 1 : 0) + (moveBack.IsPressed() ? (-1) : 0);
moveInput.x = (moveLeft.IsPressed() ? (-1) : 0) + (moveRight.IsPressed() ? 1 : 0);
moveInput.y = (moveUp.IsPressed() ? 1 : 0) + (moveDown.IsPressed() ? (-1) : 0);
speedModifierPressed = speedModifierButton.IsPressed();
Vector2 val = MonoSingleton<InputManager>.Instance.InputSource.Look.ReadValue<Vector2>() * ((ConfigValueElement<float>)(object)mouseLookSpeedMultiplier).Value;
lookInput.x = val.x + (float)(yawLeft.IsPressed() ? (-1) : 0) + (float)(yawRight.IsPressed() ? 1 : 0);
lookInput.y = 0f - val.y + (float)(pitchUp.IsPressed() ? (-1) : 0) + (float)(pitchDown.IsPressed() ? 1 : 0);
lookInput.z = (rollLeft.IsPressed() ? 1 : 0) + (rollRight.IsPressed() ? (-1) : 0);
zoomInput = 0f - Input.mouseScrollDelta.y + (float)((zoomIn.IsPressed() ? 1 : 0) + (zoomOut.IsPressed() ? (-1) : 0)) * 0.15f;
}
private void UpdateCameraTransform()
{
//IL_001c: 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_003c: 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_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: 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_0082: 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_0096: Unknown result type (might be due to invalid IL or missing references)
Vector3 position = (smoothing ? Vector3.Lerp(cameraTransform.position, cameraTarget.position, ((ConfigValueElement<float>)(object)smoothingSpeed).Value * Time.unscaledDeltaTime) : cameraTarget.position);
Quaternion rotation = (smoothing ? Quaternion.Slerp(cameraTransform.rotation, cameraTarget.rotation, ((ConfigValueElement<float>)(object)smoothingSpeed).Value * Time.unscaledDeltaTime) : cameraTarget.rotation);
cameraTransform.position = position;
cameraTransform.rotation = rotation;
}
private void Look()
{
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
currentLocalRotation.x += lookInput.y * ((ConfigValueElement<float>)(object)lookSpeed).Value * Time.unscaledDeltaTime;
currentLocalRotation.y += lookInput.x * ((ConfigValueElement<float>)(object)lookSpeed).Value * Time.unscaledDeltaTime;
currentLocalRotation.z += lookInput.z * ((ConfigValueElement<float>)(object)rollSpeed).Value * Time.unscaledDeltaTime;
cameraTarget.rotation = Quaternion.Euler(currentLocalRotation);
}
private void Move()
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: 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_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
Vector3 val = moveInput * ((ConfigValueElement<float>)(object)moveSpeed).Value * Time.unscaledDeltaTime * (speedModifierPressed ? ((ConfigValueElement<float>)(object)speedModifierMultiplier).Value : 1f);
Transform obj = cameraTarget;
obj.position += cameraTarget.rotation * val;
}
private void Zoom()
{
currentZoom = Mathf.Clamp(currentZoom + zoomInput * ((ConfigValueElement<float>)(object)zoomSpeed).Value * Time.unscaledDeltaTime, minZoom, maxZoom);
float num = 0f;
num = (smoothing ? (smoothedZoom = Mathf.Lerp(smoothedZoom, currentZoom, ((ConfigValueElement<float>)(object)smoothingSpeed).Value * Time.unscaledDeltaTime)) : currentZoom);
camera.fieldOfView = num;
}
private void OnGUI()
{
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
if (CameraHandler.ShowHelpMenu)
{
GUI.skin.box.fontSize = 35;
GUI.skin.box.normal.textColor = Color.white;
GUI.skin.box.alignment = (TextAnchor)0;
GUILayout.Box(GetHelpMenuText().TrimEnd('\n', '\r'), Array.Empty<GUILayoutOption>());
}
}
private string GetHelpMenuText()
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
//IL_0100: Unknown result type (might be due to invalid IL or missing references)
//IL_0112: Unknown result type (might be due to invalid IL or missing references)
//IL_0124: Unknown result type (might be due to invalid IL or missing references)
//IL_0145: Unknown result type (might be due to invalid IL or missing references)
//IL_0154: Unknown result type (might be due to invalid IL or missing references)
//IL_0174: Unknown result type (might be due to invalid IL or missing references)
//IL_0183: Unknown result type (might be due to invalid IL or missing references)
//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
//IL_020e: Unknown result type (might be due to invalid IL or missing references)
//IL_022e: Unknown result type (might be due to invalid IL or missing references)
string text = $"HUD TOGGLE - (<color=orange>{((ConfigValueElement<KeyCode>)(object)CameraHandler.toggleOnScreenDisplay).Value}</color>)\n";
text += $"SHOW BINDS: (<color=orange>{((ConfigValueElement<KeyCode>)(object)CameraHandler.displayAllBinds).Value}</color>)\n\n";
if (CameraHandler.displayAllBinds.IsPressed())
{
text += $"MOVE: ( <color=orange>{((ConfigValueElement<KeyCode>)(object)moveForward).Value}{((ConfigValueElement<KeyCode>)(object)moveLeft).Value}{((ConfigValueElement<KeyCode>)(object)moveBack).Value}{((ConfigValueElement<KeyCode>)(object)moveRight).Value}</color> )\n";
text += $"VERTICAL: ( <color=orange>-{((ConfigValueElement<KeyCode>)(object)moveDown).Value} {((ConfigValueElement<KeyCode>)(object)moveUp).Value}+</color> )\n";
text += $"LOOK: ( <color=orange>{((ConfigValueElement<KeyCode>)(object)pitchUp).Value}{((ConfigValueElement<KeyCode>)(object)yawLeft).Value}{((ConfigValueElement<KeyCode>)(object)pitchDown).Value}{((ConfigValueElement<KeyCode>)(object)yawRight).Value}</color> )\n";
text += $"ZOOM: ( +<color=orange>{((ConfigValueElement<KeyCode>)(object)zoomIn).Value} {((ConfigValueElement<KeyCode>)(object)zoomOut).Value}</color>- )\n";
text += $"ROLL: ( <color=orange><{((ConfigValueElement<KeyCode>)(object)rollLeft).Value} {((ConfigValueElement<KeyCode>)(object)rollRight).Value}></color> )\n";
text += $"SPEED MODIFIER: (<color=orange>{((ConfigValueElement<KeyCode>)(object)speedModifierButton).Value}</color>)\n";
text += $"SMOOTHING: <color=orange>{smoothing}</color> (<color=orange>{((ConfigValueElement<KeyCode>)(object)toggleSmoothing).Value}</color>)\n";
text += $"RESET ROTATION: (<color=orange>{((ConfigValueElement<KeyCode>)(object)CameraHandler.resetCameraRotation).Value}</color>)\n";
text += $"RESET POSITION: (<color=orange>{((ConfigValueElement<KeyCode>)(object)CameraHandler.resetCameraPositionToPlayer).Value}</color>)\n";
text += $"TOGGLE LIGHT: (<color=orange>{((ConfigValueElement<KeyCode>)(object)CameraHandler.toggleLight).Value}</color>)\n";
}
return text;
}
}
}
namespace Ultracam
{
public static class PluginInfo
{
public const string PLUGIN_GUID = "Ultracam";
public const string PLUGIN_NAME = "Ultracam";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace Ultracam.CameraTools
{
public class CameraHandler : MonoBehaviour
{
[Configgable("Binds", "Toggle Freecam Button", 0, null)]
public static ConfigKeybind toggleCameraEnabled = new ConfigKeybind((KeyCode)286);
[Configgable("Binds", "Toggle Light", 0, null)]
public static ConfigKeybind toggleLight = new ConfigKeybind((KeyCode)102);
[Configgable("Binds", null, 0, null)]
public static ConfigKeybind toggleOnScreenDisplay = new ConfigKeybind((KeyCode)59);
[Configgable("Binds", null, 0, null)]
public static ConfigKeybind resetCameraRotation = new ConfigKeybind((KeyCode)288);
[Configgable("Binds", "Reset Camera To Player Position", 0, null)]
public static ConfigKeybind resetCameraPositionToPlayer = new ConfigKeybind((KeyCode)289);
[Configgable("Binds", "Show all binds in OSD", 0, null)]
public static ConfigKeybind displayAllBinds = new ConfigKeybind((KeyCode)308);
[Configgable("Settings/Camera", null, 0, null)]
private static ConfigInputField<float> cameraNearClipPlane = new ConfigInputField<float>(0.01f, (Func<float, bool>)null, (Func<string, ValueTuple<bool, float>>)null);
[Configgable("Settings/Camera", null, 0, null)]
private static ConfigInputField<float> cameraFarClipPlane = new ConfigInputField<float>(1000f, (Func<float, bool>)null, (Func<string, ValueTuple<bool, float>>)null);
[Configgable("Settings/Camera", null, 0, null)]
private static ConfigInputField<float> cameraFieldOfView = new ConfigInputField<float>(77f, (Func<float, bool>)((float v) => v >= minZoom && v <= maxZoom), (Func<string, ValueTuple<bool, float>>)null);
[Configgable("Settings/Camera", null, 0, null)]
private static ConfigInputField<int> cameraCullingMask = new ConfigInputField<int>(-1, (Func<int, bool>)((int v) => v >= -1), (Func<string, ValueTuple<bool, int>>)null);
[Configgable("Settings/Camera", null, 0, null)]
private static ConfigToggle copyExistingCameraCullingMask = new ConfigToggle(true);
[Configgable("Settings/Light", null, 0, null)]
private static ConfigInputField<float> lightIntensity = new ConfigInputField<float>(1f, (Func<float, bool>)((float v) => v >= 0f), (Func<string, ValueTuple<bool, float>>)null);
[Configgable("Settings/Light", null, 0, null)]
private static ConfigColor lightColor = new ConfigColor(Color.white);
[Configgable("Settings/Light", null, 0, null)]
private static ConfigInputField<int> lightCullingMask = new ConfigInputField<int>(-1, (Func<int, bool>)((int v) => v >= -1), (Func<string, ValueTuple<bool, int>>)null);
[Configgable("Settings/General", null, 0, null)]
public static ConfigToggle stopTimeDuringFreecam = new ConfigToggle(true);
[Configgable("Settings/General", null, 0, null)]
private static ConfigDropdown<CameraType> cameraType = new ConfigDropdown<CameraType>(Enum.GetValues(typeof(CameraType)).Cast<CameraType>().ToArray(), (string[])null, 0);
[Configgable("Settings/General", "Position Freecam To Player On Enable", 0, null)]
public static ConfigToggle positionFreecamToPlayerOnEnable = new ConfigToggle(true);
private static float minZoom = 1E-05f;
private static float maxZoom = 179f;
private GameObject cameraObject;
private Camera camera;
private AudioListener listener;
private Light light;
private Freecam freecam;
private EditorCam sceneViewCam;
private static bool loaded;
private static FieldInfo hudCameraField = typeof(CameraController).GetField("hudCamera", BindingFlags.Instance | BindingFlags.NonPublic);
private static GameState camState;
public static bool Enabled { get; private set; }
public static bool ShowHelpMenu { get; private set; } = true;
public static void Load()
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Expected O, but got Unknown
if (loaded)
{
return;
}
loaded = true;
GameObject val = new GameObject("FreecamHandler");
Object.DontDestroyOnLoad((Object)(object)val);
CameraHandler cameraHandler = val.AddComponent<CameraHandler>();
cameraHandler.Init();
ConfigToggle obj = stopTimeDuringFreecam;
((ConfigValueElement<bool>)(object)obj).OnValueChanged = (Action<bool>)Delegate.Combine(((ConfigValueElement<bool>)(object)obj).OnValueChanged, (Action<bool>)delegate(bool v)
{
if (Enabled)
{
Time.timeScale = (v ? 0f : 1f);
}
});
}
private void Init()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
cameraObject = new GameObject("Camera");
cameraObject.transform.parent = ((Component)this).transform;
light = cameraObject.AddComponent<Light>();
light.type = (LightType)1;
light.intensity = ((ConfigValueElement<float>)(object)lightIntensity).Value;
ConfigInputField<float> obj = lightIntensity;
((ConfigValueElement<float>)(object)obj).OnValueChanged = (Action<float>)Delegate.Combine(((ConfigValueElement<float>)(object)obj).OnValueChanged, (Action<float>)delegate(float v)
{
light.intensity = v;
});
light.shadows = (LightShadows)0;
((Behaviour)light).enabled = false;
light.color = ((ConfigValueElement<Color>)(object)lightColor).Value;
ConfigColor obj2 = lightColor;
((ConfigValueElement<Color>)(object)obj2).OnValueChanged = (Action<Color>)Delegate.Combine(((ConfigValueElement<Color>)(object)obj2).OnValueChanged, (Action<Color>)delegate(Color v)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
light.color = v;
});
light.cullingMask = ((ConfigValueElement<int>)(object)lightCullingMask).Value;
ConfigInputField<int> obj3 = lightCullingMask;
((ConfigValueElement<int>)(object)obj3).OnValueChanged = (Action<int>)Delegate.Combine(((ConfigValueElement<int>)(object)obj3).OnValueChanged, (Action<int>)delegate(int v)
{
light.cullingMask = v;
});
listener = cameraObject.AddComponent<AudioListener>();
((Behaviour)listener).enabled = true;
camera = cameraObject.AddComponent<Camera>();
camera.fieldOfView = ((ConfigValueElement<float>)(object)cameraFieldOfView).Value;
ConfigInputField<float> obj4 = cameraFieldOfView;
((ConfigValueElement<float>)(object)obj4).OnValueChanged = (Action<float>)Delegate.Combine(((ConfigValueElement<float>)(object)obj4).OnValueChanged, (Action<float>)delegate(float v)
{
camera.fieldOfView = v;
});
camera.nearClipPlane = ((ConfigValueElement<float>)(object)cameraNearClipPlane).Value;
ConfigInputField<float> obj5 = cameraNearClipPlane;
((ConfigValueElement<float>)(object)obj5).OnValueChanged = (Action<float>)Delegate.Combine(((ConfigValueElement<float>)(object)obj5).OnValueChanged, (Action<float>)delegate(float v)
{
camera.nearClipPlane = v;
});
camera.farClipPlane = ((ConfigValueElement<float>)(object)cameraFarClipPlane).Value;
ConfigInputField<float> obj6 = cameraFarClipPlane;
((ConfigValueElement<float>)(object)obj6).OnValueChanged = (Action<float>)Delegate.Combine(((ConfigValueElement<float>)(object)obj6).OnValueChanged, (Action<float>)delegate(float v)
{
camera.farClipPlane = v;
});
camera.cullingMask = ((ConfigValueElement<int>)(object)cameraCullingMask).Value;
ConfigInputField<int> obj7 = cameraCullingMask;
((ConfigValueElement<int>)(object)obj7).OnValueChanged = (Action<int>)Delegate.Combine(((ConfigValueElement<int>)(object)obj7).OnValueChanged, (Action<int>)delegate(int v)
{
if (!((ConfigValueElement<bool>)(object)copyExistingCameraCullingMask).Value)
{
camera.cullingMask = v;
}
});
ConfigToggle obj8 = copyExistingCameraCullingMask;
((ConfigValueElement<bool>)(object)obj8).OnValueChanged = (Action<bool>)Delegate.Combine(((ConfigValueElement<bool>)(object)obj8).OnValueChanged, (Action<bool>)delegate(bool v)
{
if (v)
{
camera.cullingMask = MonoSingleton<CameraController>.Instance.cam.cullingMask;
}
else
{
camera.cullingMask = ((ConfigValueElement<int>)(object)cameraCullingMask).Value;
}
});
camera.depth = 1f;
camera.useOcclusionCulling = false;
((Component)camera).tag = "MainCamera";
((Behaviour)camera).enabled = true;
cameraObject.SetActive(false);
CameraType value = ((ConfigValueElement<CameraType>)(object)cameraType).Value;
freecam = cameraObject.AddComponent<Freecam>();
freecam.Init(this);
((Behaviour)freecam).enabled = false;
sceneViewCam = cameraObject.AddComponent<EditorCam>();
((Behaviour)sceneViewCam).enabled = false;
Action<CameraType> action = delegate(CameraType v)
{
Debug.Log((object)$"Changing Freecam to type {v}");
((Behaviour)freecam).enabled = false;
((Behaviour)sceneViewCam).enabled = false;
switch (v)
{
case CameraType.Standard:
((Behaviour)freecam).enabled = true;
break;
case CameraType.SceneView:
((Behaviour)sceneViewCam).enabled = true;
break;
}
};
ConfigDropdown<CameraType> obj9 = cameraType;
((ConfigValueElement<CameraType>)(object)obj9).OnValueChanged = (Action<CameraType>)Delegate.Combine(((ConfigValueElement<CameraType>)(object)obj9).OnValueChanged, action);
action(value);
}
private void Update()
{
Inputs();
if (Enabled)
{
Time.timeScale = (((ConfigValueElement<bool>)(object)stopTimeDuringFreecam).Value ? 0f : 1f);
}
}
private void Inputs()
{
if (toggleCameraEnabled.WasPeformed())
{
SetEnabled(!Enabled);
}
if (Enabled)
{
if (toggleLight.WasPeformed())
{
((Behaviour)light).enabled = !((Behaviour)light).enabled;
}
if (toggleOnScreenDisplay.WasPeformed())
{
ShowHelpMenu = !ShowHelpMenu;
}
}
}
public void SetEnabled(bool enabled)
{
SetExternalStates(!enabled);
cameraObject.SetActive(enabled);
Enabled = enabled;
Debug.LogWarning((object)("Freecam " + (Enabled ? "Enabled" : "Disabled")));
}
private void SetExternalStates(bool freeCamDisabled)
{
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Expected O, but got Unknown
//IL_00cf: 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_00d6: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: Unknown result type (might be due to invalid IL or missing references)
//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
//IL_00f9: Expected O, but got Unknown
((Behaviour)MonoSingleton<CameraController>.Instance.cam).enabled = freeCamDisabled;
((Behaviour)MonoSingleton<CameraController>.Instance).enabled = freeCamDisabled;
((Behaviour)((Component)MonoSingleton<CameraController>.Instance).gameObject.GetComponent<AudioListener>()).enabled = freeCamDisabled;
Camera val = (Camera)hudCameraField.GetValue(MonoSingleton<CameraController>.Instance);
((Behaviour)val).enabled = freeCamDisabled;
if (((ConfigValueElement<bool>)(object)copyExistingCameraCullingMask).Value)
{
camera.cullingMask = MonoSingleton<CameraController>.Instance.cam.cullingMask;
}
((Behaviour)MonoSingleton<NewMovement>.Instance).enabled = freeCamDisabled;
float alpha = (freeCamDisabled ? 1f : 0f);
CanvasGroup val2 = default(CanvasGroup);
if (!((Component)MonoSingleton<CanvasController>.Instance).TryGetComponent<CanvasGroup>(ref val2))
{
val2 = ((Component)MonoSingleton<CanvasController>.Instance).gameObject.AddComponent<CanvasGroup>();
}
val2.alpha = alpha;
if (camState == null)
{
camState = new GameState("Freecam")
{
cameraInputLock = (LockMode)1,
playerInputLock = (LockMode)1,
priority = 200,
cursorLock = (LockMode)1
};
}
if (freeCamDisabled)
{
GameStateManager.Instance.PopState("Freecam");
}
else
{
GameStateManager.Instance.RegisterState(camState);
}
if (((ConfigValueElement<bool>)(object)stopTimeDuringFreecam).Value)
{
Time.timeScale = (freeCamDisabled ? 1f : 0f);
}
}
}
public enum CameraType
{
Standard,
SceneView
}
public class EditorCam : MonoBehaviour
{
[Configgable("Binds/Control/SceneViewCamera", null, 0, null)]
private static ConfigKeybind unlockCamera = new ConfigKeybind((KeyCode)324);
[Configgable("Binds/Control/SceneViewCamera", null, 0, null)]
private static ConfigKeybind dragCamera = new ConfigKeybind((KeyCode)325);
[Configgable("Binds/Control/SceneViewCamera", null, 0, null)]
private static ConfigKeybind speedModifierButton = new ConfigKeybind((KeyCode)304);
[Configgable("Binds/Control/SceneViewCamera", null, 0, null)]
private static ConfigKeybind moveForward = new ConfigKeybind((KeyCode)119);
[Configgable("Binds/Control/SceneViewCamera", null, 0, null)]
private static ConfigKeybind moveBack = new ConfigKeybind((KeyCode)115);
[Configgable("Binds/Control/SceneViewCamera", null, 0, null)]
private static ConfigKeybind moveLeft = new ConfigKeybind((KeyCode)97);
[Configgable("Binds/Control/SceneViewCamera", null, 0, null)]
private static ConfigKeybind moveRight = new ConfigKeybind((KeyCode)100);
[Configgable("Binds/Control/SceneViewCamera", null, 0, null)]
private static ConfigKeybind moveUp = new ConfigKeybind((KeyCode)101);
[Configgable("Binds/Control/SceneViewCamera", null, 0, null)]
private static ConfigKeybind moveDown = new ConfigKeybind((KeyCode)113);
[Configgable("Binds/Control/SceneViewCamera", null, 0, null)]
private static ConfigKeybind zoomIn = new ConfigKeybind((KeyCode)61);
[Configgable("Binds/Control/SceneViewCamera", null, 0, null)]
private static ConfigKeybind zoomOut = new ConfigKeybind((KeyCode)45);
[Configgable("Settings/Control/SceneViewCamera", null, 0, null)]
private static ConfigInputField<float> zoomSensitivity = new ConfigInputField<float>(75f, (Func<float, bool>)null, (Func<string, ValueTuple<bool, float>>)null);
[Configgable("Settings/Control/SceneViewCamera", null, 0, null)]
private static ConfigInputField<float> lookSensitivity = new ConfigInputField<float>(256f, (Func<float, bool>)null, (Func<string, ValueTuple<bool, float>>)null);
[Configgable("Settings/Control/SceneViewCamera", null, 0, null)]
private static ConfigInputField<float> dragSensitivity = new ConfigInputField<float>(256f, (Func<float, bool>)null, (Func<string, ValueTuple<bool, float>>)null);
[Configgable("Settings/Control/SceneViewCamera", null, 0, null)]
private static ConfigInputField<float> maxMoveSpeed = new ConfigInputField<float>(20f, (Func<float, bool>)null, (Func<string, ValueTuple<bool, float>>)null);
[Configgable("Settings/Control/SceneViewCamera", null, 0, null)]
private static ConfigInputField<float> moveAcceleration = new ConfigInputField<float>(0.225f, (Func<float, bool>)null, (Func<string, ValueTuple<bool, float>>)null);
[Configgable("Settings/Control/SceneViewCamera", null, 0, null)]
private static ConfigInputField<float> moveDeceleration = new ConfigInputField<float>(3.5f, (Func<float, bool>)null, (Func<string, ValueTuple<bool, float>>)null);
[Configgable("Settings/Control/SceneViewCamera", null, 0, null)]
private static ConfigInputField<float> speedModifierMultiplier = new ConfigInputField<float>(2f, (Func<float, bool>)null, (Func<string, ValueTuple<bool, float>>)null);
private Vector3 lastMoveDirection;
private Vector3 currentLocalRotation;
private Vector3 moveInput;
private Vector3 lookInput;
private float zoomInput;
private bool speedModifierPressed = false;
private bool cameraLooking;
private bool cameraDragging;
private float currentSpeed;
private void Update()
{
GetInputs();
if (cameraDragging)
{
Cursor.lockState = (CursorLockMode)1;
Drag();
}
else if (cameraLooking)
{
Cursor.lockState = (CursorLockMode)1;
Look();
Move();
}
else
{
Cursor.lockState = (CursorLockMode)0;
}
Zoom();
}
private void GetInputs()
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_014d: Unknown result type (might be due to invalid IL or missing references)
//IL_0152: Unknown result type (might be due to invalid IL or missing references)
//IL_011f: Unknown result type (might be due to invalid IL or missing references)
//IL_0124: Unknown result type (might be due to invalid IL or missing references)
//IL_012b: 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_0159: Unknown result type (might be due to invalid IL or missing references)
if (CameraHandler.resetCameraPositionToPlayer.WasPeformed())
{
((Component)this).transform.position = ((Component)MonoSingleton<CameraController>.Instance).transform.position;
}
if (CameraHandler.resetCameraRotation.WasPeformed())
{
currentLocalRotation = Vector3.zero;
}
moveInput.z = (moveForward.IsPressed() ? 1 : 0) + (moveBack.IsPressed() ? (-1) : 0);
moveInput.x = (moveLeft.IsPressed() ? (-1) : 0) + (moveRight.IsPressed() ? 1 : 0);
moveInput.y = (moveUp.IsPressed() ? 1 : 0) + (moveDown.IsPressed() ? (-1) : 0);
speedModifierPressed = speedModifierButton.IsPressed();
cameraDragging = dragCamera.IsPressed();
cameraLooking = unlockCamera.IsPressed();
if (cameraDragging || cameraLooking)
{
Vector2 val = MonoSingleton<InputManager>.Instance.InputSource.Look.ReadValue<Vector2>();
lookInput.x = val.x;
lookInput.y = 0f - val.y;
}
else
{
lookInput = Vector3.zero;
}
zoomInput = Input.mouseScrollDelta.y + (float)((zoomIn.IsPressed() ? 1 : 0) + (zoomOut.IsPressed() ? (-1) : 0)) * 0.15f;
}
private void Look()
{
//IL_005e: 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)
currentLocalRotation.x += lookInput.y * ((ConfigValueElement<float>)(object)lookSensitivity).Value * Time.unscaledDeltaTime;
currentLocalRotation.y += lookInput.x * ((ConfigValueElement<float>)(object)lookSensitivity).Value * Time.unscaledDeltaTime;
((Component)this).transform.localRotation = Quaternion.Euler(currentLocalRotation);
}
private void Move()
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: 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_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: 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_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
Vector3 val = moveInput;
float num;
float num2;
if (((Vector3)(ref val)).magnitude > 0f)
{
lastMoveDirection = val;
num = ((ConfigValueElement<float>)(object)maxMoveSpeed).Value;
num2 = ((ConfigValueElement<float>)(object)moveAcceleration).Value * (speedModifierPressed ? ((ConfigValueElement<float>)(object)speedModifierMultiplier).Value : 1f);
}
else
{
num2 = ((ConfigValueElement<float>)(object)moveDeceleration).Value;
num = 0f;
}
currentSpeed = Mathf.MoveTowards(currentSpeed, num, Time.unscaledDeltaTime * num2);
Vector3 val2 = lastMoveDirection * currentSpeed;
Transform transform = ((Component)this).transform;
transform.position += ((Component)this).transform.rotation * val2;
}
private void Drag()
{
//IL_0007: 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_002d: 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_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: 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_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: 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)
Vector3 val = ((Component)this).transform.rotation * new Vector3(0f - lookInput.x, lookInput.y, 0f);
val *= ((ConfigValueElement<float>)(object)dragSensitivity).Value * Time.unscaledDeltaTime * (speedModifierPressed ? ((ConfigValueElement<float>)(object)speedModifierMultiplier).Value : 1f);
Transform transform = ((Component)this).transform;
transform.position += val;
}
private void Zoom()
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
if (zoomInput != 0f)
{
Transform transform = ((Component)this).transform;
transform.position += ((Component)this).transform.rotation * (new Vector3(0f, 0f, zoomInput) * Time.unscaledDeltaTime * ((ConfigValueElement<float>)(object)zoomSensitivity).Value);
}
}
private void OnEnable()
{
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: 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)
currentSpeed = 0f;
if (((ConfigValueElement<bool>)(object)CameraHandler.positionFreecamToPlayerOnEnable).Value)
{
((Component)this).transform.position = ((Component)MonoSingleton<CameraController>.Instance).transform.position;
currentLocalRotation = ((Component)MonoSingleton<CameraController>.Instance).transform.eulerAngles;
}
}
private void OnGUI()
{
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
if (CameraHandler.ShowHelpMenu)
{
GUI.skin.box.fontSize = 35;
GUI.skin.box.normal.textColor = Color.white;
GUI.skin.box.alignment = (TextAnchor)0;
GUILayout.Box(GetHelpMenuText().TrimEnd('\n', '\r'), Array.Empty<GUILayoutOption>());
}
}
private string GetHelpMenuText()
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: 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_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
//IL_0112: Unknown result type (might be due to invalid IL or missing references)
//IL_0121: Unknown result type (might be due to invalid IL or missing references)
//IL_0141: Unknown result type (might be due to invalid IL or missing references)
//IL_0161: Unknown result type (might be due to invalid IL or missing references)
//IL_0181: Unknown result type (might be due to invalid IL or missing references)
//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
string text = $"HUD TOGGLE - (<color=orange>{((ConfigValueElement<KeyCode>)(object)CameraHandler.toggleOnScreenDisplay).Value}</color>)\n";
text += $"TOGGLE CAMERA: (<color=orange>{((ConfigValueElement<KeyCode>)(object)CameraHandler.toggleCameraEnabled).Value}</color>)\n";
text += $"SHOW BINDS: (<color=orange>{((ConfigValueElement<KeyCode>)(object)CameraHandler.displayAllBinds).Value}</color>)\n\n";
if (CameraHandler.displayAllBinds.IsPressed())
{
text += $"TRANSLATE: ( <color=orange>{((ConfigValueElement<KeyCode>)(object)moveForward).Value}{((ConfigValueElement<KeyCode>)(object)moveLeft).Value}{((ConfigValueElement<KeyCode>)(object)moveBack).Value}{((ConfigValueElement<KeyCode>)(object)moveRight).Value}</color> )\n";
text += $"TRANSLATE VERTICAL: ( <color=orange>-{((ConfigValueElement<KeyCode>)(object)moveDown).Value} {((ConfigValueElement<KeyCode>)(object)moveUp).Value}+</color> )\n";
text += "LOOK: ( <color=orange>MOUSE</color> )\n";
text += $"ZOOM: ( +<color=orange>{((ConfigValueElement<KeyCode>)(object)zoomIn).Value} SCROLL {((ConfigValueElement<KeyCode>)(object)zoomOut).Value}</color>- )\n";
text += $"DRAG: ( <color=orange>{((ConfigValueElement<KeyCode>)(object)dragCamera).Value}</color> )\n";
text += $"SPEED MODIFIER: (<color=orange>{((ConfigValueElement<KeyCode>)(object)speedModifierButton).Value}</color>)\n";
text += $"RESET ROTATION: (<color=orange>{((ConfigValueElement<KeyCode>)(object)CameraHandler.resetCameraRotation).Value}</color>)\n";
text += $"RESET POSITION: (<color=orange>{((ConfigValueElement<KeyCode>)(object)CameraHandler.resetCameraPositionToPlayer).Value}</color>)\n";
text += $"TOGGLE LIGHT: (<color=orange>{((ConfigValueElement<KeyCode>)(object)CameraHandler.toggleLight).Value}</color>)\n";
}
return text;
}
}
}