using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Unity.IL2CPP;
using BepInEx.Unity.IL2CPP.Hook;
using HarmonyLib;
using Il2CppSystem.Collections.Generic;
using Microsoft.CodeAnalysis;
using ModernCamera.Behaviours;
using ModernCamera.Enums;
using ModernCamera.Hooks;
using ModernCamera.Structs;
using ModernCamera.Utils;
using ProjectM;
using ProjectM.Sequencer;
using ProjectM.UI;
using Silkworm.API;
using Silkworm.Core.KeyBinding;
using Silkworm.Core.Options;
using Silkworm.Utils;
using Unity.Entities;
using UnityEngine;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("VRising")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Makes the camera more like a mmo camera and removes the limits")]
[assembly: AssemblyFileVersion("1.5.6.0")]
[assembly: AssemblyInformationalVersion("1.5.6+14518f253fa428f7c3bca513503b9dfeb68960d7")]
[assembly: AssemblyProduct("ModernCamera")]
[assembly: AssemblyTitle("ModernCamera")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.5.6.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace ModernCamera
{
public class ModernCamera : MonoBehaviour
{
private static GameObject CrosshairPrefab;
private static GameObject Crosshair;
private static CanvasScaler CanvasScaler;
private static bool ShouldGatherSystems = true;
private static ZoomModifierSystem ZoomModifierSystem;
private static PrefabCollectionSystem PrefabCollectionSystem;
private static UIDataSystem UIDataSystem;
private static Camera GameCamera;
private static bool GameFocused;
public static void Enabled(bool enabled)
{
Settings.Enabled = enabled;
UpdateEnabled(enabled);
}
public static void ActionMode(bool enabled)
{
ModernCameraState.IsMouseLocked = enabled;
ModernCameraState.IsActionMode = enabled;
}
private static void UpdateEnabled(bool enabled)
{
if (ZoomModifierSystem != null)
{
((ComponentSystemBase)ZoomModifierSystem).Enabled = !enabled;
}
if ((Object)(object)Crosshair != (Object)null)
{
Crosshair.active = enabled && Settings.AlwaysShowCrosshair && !ModernCameraState.InBuildMode;
}
if (!enabled)
{
Cursor.visible = true;
ActionMode(enabled: false);
}
}
private static void UpdateFieldOfView(float fov)
{
if ((Object)(object)GameCamera != (Object)null)
{
GameCamera.fieldOfView = fov;
}
}
private static void ToggleUI()
{
ModernCameraState.IsUIHidden = !ModernCameraState.IsUIHidden;
DisableUISettings.SetHideHUD(ModernCameraState.IsUIHidden, WorldUtils.ClientWorld);
}
private void Awake()
{
ModernCameraState.RegisterCameraBehaviour(new FirstPersonCameraBehaviour());
ModernCameraState.RegisterCameraBehaviour(new ThirdPersonCameraBehaviour());
Settings.AddEnabledListener(UpdateEnabled);
Settings.AddFieldOfViewListener(UpdateFieldOfView);
}
private void Update()
{
if (!GameFocused || !Settings.Enabled)
{
return;
}
if ((Object)(object)CrosshairPrefab == (Object)null)
{
BuildCrosshair();
}
if (WorldUtils.ClientWorldExists)
{
if ((Object)(object)GameCamera == (Object)null)
{
GameObject val = GameObject.Find("Main_GameToolCamera(Clone)");
if ((Object)(object)val != (Object)null)
{
GameCamera = val.GetComponent<Camera>();
UpdateFieldOfView(Settings.FieldOfView);
}
}
if (ShouldGatherSystems)
{
GatherSystems();
}
UpdateSystems();
UpdateCrosshair();
}
else
{
ShouldGatherSystems = true;
Cursor.visible = true;
}
}
private void OnApplicationFocus(bool hasFocus)
{
GameFocused = hasFocus;
}
private void BuildCrosshair()
{
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Expected O, but got Unknown
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
//IL_00c1: 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_00f2: Unknown result type (might be due to invalid IL or missing references)
//IL_010d: Unknown result type (might be due to invalid IL or missing references)
//IL_014c: Unknown result type (might be due to invalid IL or missing references)
//IL_015b: Unknown result type (might be due to invalid IL or missing references)
try
{
if (CursorController._CursorDatas != null)
{
CursorData val = ((IEnumerable<CursorData>)CursorController._CursorDatas).First((CursorData x) => (int)x.CursorType == 0);
if (val != null)
{
CrosshairPrefab = new GameObject("Crosshair");
CrosshairPrefab.active = false;
CrosshairPrefab.AddComponent<CanvasRenderer>();
RectTransform val2 = CrosshairPrefab.AddComponent<RectTransform>();
((Component)val2).transform.SetSiblingIndex(1);
val2.pivot = new Vector2(0.5f, 0.5f);
val2.anchorMin = new Vector2(0.5f, 0.5f);
val2.anchorMax = new Vector2(0.5f, 0.5f);
val2.sizeDelta = new Vector2(32f, 32f);
((Transform)val2).localScale = new Vector3(1.2f, 1.2f, 1.2f);
((Transform)val2).localPosition = new Vector3(0f, 0f, 0f);
Image val3 = CrosshairPrefab.AddComponent<Image>();
val3.sprite = Sprite.Create(val.Texture, new Rect(0f, 0f, (float)((Texture)val.Texture).width, (float)((Texture)val.Texture).height), new Vector2(0.5f, 0.5f), 100f);
CrosshairPrefab.active = false;
}
}
}
catch (Exception ex)
{
LogUtils.LogDebugError((object)ex);
}
}
private void GatherSystems()
{
ZoomModifierSystem = WorldUtils.ClientWorld.GetExistingSystemManaged<ZoomModifierSystem>();
if (ZoomModifierSystem != null)
{
((ComponentSystemBase)ZoomModifierSystem).Enabled = false;
}
PrefabCollectionSystem = WorldUtils.ClientWorld.GetExistingSystemManaged<PrefabCollectionSystem>();
UIDataSystem = WorldUtils.ClientWorld.GetExistingSystemManaged<UIDataSystem>();
ShouldGatherSystems = false;
}
private void UpdateSystems()
{
//IL_0080: 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_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_0162: Unknown result type (might be due to invalid IL or missing references)
if (UIDataSystem == null || PrefabCollectionSystem == null)
{
return;
}
try
{
if ((Object)(object)UIDataSystem.UI.BuffBarParent != (Object)null)
{
ModernCameraState.IsShapeshifted = false;
ModernCameraState.ShapeshiftName = "";
Enumerator<Data> enumerator = UIDataSystem.UI.BuffBarParent.BuffsSelectionGroup.Entries.GetEnumerator();
while (enumerator.MoveNext())
{
Data current = enumerator.Current;
if (!PrefabCollectionSystem.PrefabGuidToNameDictionary.ContainsKey(current.PrefabGUID))
{
continue;
}
string text = PrefabCollectionSystem.PrefabGuidToNameDictionary[current.PrefabGUID];
if (text != null)
{
ModernCameraState.IsShapeshifted = text.Contains("shapeshift", StringComparison.OrdinalIgnoreCase);
if (ModernCameraState.IsShapeshifted)
{
ModernCameraState.ShapeshiftName = text.Trim();
break;
}
}
}
}
if (!((Object)(object)UIDataSystem.UI.AbilityBar != (Object)null))
{
return;
}
ModernCameraState.IsMounted = false;
Enumerator<AbilityBarEntry> enumerator2 = UIDataSystem.UI.AbilityBar.Entries.GetEnumerator();
while (enumerator2.MoveNext())
{
AbilityBarEntry current2 = enumerator2.Current;
if (!PrefabCollectionSystem.PrefabGuidToNameDictionary.ContainsKey(current2.AbilityId))
{
continue;
}
string text2 = PrefabCollectionSystem.PrefabGuidToNameDictionary[current2.AbilityId];
if (text2 != null)
{
ModernCameraState.IsMounted = text2.Contains("mounted", StringComparison.OrdinalIgnoreCase);
if (ModernCameraState.IsMounted)
{
break;
}
}
}
}
catch (Exception ex)
{
LogUtils.LogDebugError((object)ex);
}
}
private void UpdateCrosshair()
{
//IL_014a: Unknown result type (might be due to invalid IL or missing references)
//IL_0180: Unknown result type (might be due to invalid IL or missing references)
//IL_019d: Unknown result type (might be due to invalid IL or missing references)
//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
try
{
bool visible = true;
bool flag = false;
if ((Object)(object)Crosshair == (Object)null && (Object)(object)CrosshairPrefab != (Object)null)
{
GameObject val = GameObject.Find("HUDCanvas(Clone)/Canvas");
if ((Object)(object)val == (Object)null)
{
return;
}
CanvasScaler = val.GetComponent<CanvasScaler>();
Crosshair = Object.Instantiate<GameObject>(CrosshairPrefab, val.transform);
Crosshair.active = true;
}
if (ModernCameraState.ValidGameplayInputState && (ModernCameraState.IsMouseLocked || ((InputState)(ref ModernCameraState.GameplayInputState)).IsInputPressed((ButtonInputAction)500)) && !ModernCameraState.IsMenuOpen)
{
if (ModernCameraState.IsActionMode || ModernCameraState.IsFirstPerson || Settings.CameraAimMode == CameraAimMode.Forward)
{
Mouse.SetCursorPosition(Screen.width / 2 + Settings.AimOffsetX, Screen.height / 2 - Settings.AimOffsetY);
}
flag = ModernCameraState.IsFirstPerson || (ModernCameraState.IsActionMode && Settings.ActionModeCrosshair);
visible = false;
}
if ((Object)(object)Crosshair != (Object)null)
{
Crosshair.active = (flag || Settings.AlwaysShowCrosshair) && !ModernCameraState.InBuildMode;
if (ModernCameraState.IsFirstPerson)
{
Crosshair.transform.localPosition = Vector3.zero;
}
else if ((Object)(object)CanvasScaler != (Object)null)
{
Crosshair.transform.localPosition = new Vector3((float)Settings.AimOffsetX * (CanvasScaler.referenceResolution.x / (float)Screen.width), (float)Settings.AimOffsetY * (CanvasScaler.referenceResolution.y / (float)Screen.height), 0f);
}
}
Cursor.visible = visible;
}
catch (Exception ex)
{
LogUtils.LogDebugError((object)ex);
}
}
}
internal static class ModernCameraState
{
internal static bool IsUIHidden;
internal static bool IsFirstPerson;
internal static bool IsActionMode;
internal static bool IsMouseLocked;
internal static bool IsShapeshifted;
internal static bool IsMounted;
internal static bool InBuildMode;
internal static string ShapeshiftName;
internal static BehaviourType CurrentBehaviourType = BehaviourType.Default;
internal static Dictionary<BehaviourType, CameraBehaviour> CameraBehaviours = new Dictionary<BehaviourType, CameraBehaviour>();
internal static bool ValidGameplayInputState;
internal static InputState GameplayInputState;
private static int _menusOpen;
internal static bool IsMenuOpen
{
get
{
return _menusOpen > 0;
}
set
{
_menusOpen = (value ? (_menusOpen + 1) : Mathf.Max(0, _menusOpen - 1));
}
}
internal static CameraBehaviour CurrentCameraBehaviour
{
get
{
if (CameraBehaviours.ContainsKey(CurrentBehaviourType))
{
return CameraBehaviours[CurrentBehaviourType];
}
return null;
}
}
internal static void RegisterCameraBehaviour(CameraBehaviour behaviour)
{
CameraBehaviours.Add(behaviour.BehaviourType, behaviour);
}
internal static void Reset()
{
IsUIHidden = false;
IsFirstPerson = false;
IsActionMode = false;
IsMouseLocked = false;
IsShapeshifted = false;
IsMounted = false;
InBuildMode = false;
ShapeshiftName = "";
ValidGameplayInputState = false;
CurrentCameraBehaviour?.Deactivate();
CurrentBehaviourType = BehaviourType.Default;
}
}
[BepInProcess("VRising.exe")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("VRising.ModernCamera", "ModernCamera", "1.5.6")]
public class Plugin : BasePlugin
{
private static Harmony Harmony;
public override void Load()
{
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Expected O, but got Unknown
LogUtils.Init(((BasePlugin)this).Log);
Settings.Init();
((BasePlugin)this).AddComponent<ModernCamera>();
TopdownCameraSystem_Hook.CreateAndApply();
Harmony = new Harmony("VRising.ModernCamera");
Harmony.PatchAll();
LogUtils.LogInfo((object)"Plugin VRising.ModernCamera v1.5.6 is loaded!");
}
public override bool Unload()
{
Harmony.UnpatchSelf();
TopdownCameraSystem_Hook.Dispose();
return true;
}
}
internal static class Settings
{
[Serializable]
[CompilerGenerated]
private sealed class <>c
{
public static readonly <>c <>9 = new <>c();
public static OnChange<float> <>9__93_0;
public static OnChange<float> <>9__93_1;
public static OnChange<float> <>9__93_2;
public static OnChange<float> <>9__93_3;
public static KeyEvent <>9__94_0;
public static KeyEvent <>9__94_1;
internal void <SetupOptions>b__93_0(float value)
{
if (value + ZoomOffset > MaxZoom && value + ZoomOffset < MaxZoomOption.MaxValue)
{
((Option<float>)(object)MaxZoomOption).SetValue(value + ZoomOffset);
}
else if (value + ZoomOffset > MaxZoomOption.MaxValue)
{
((Option<float>)(object)MinZoomOption).SetValue(MaxZoomOption.MaxValue - ZoomOffset);
}
}
internal void <SetupOptions>b__93_1(float value)
{
if (value - ZoomOffset < MinZoom && value - ZoomOffset > MinZoomOption.MinValue)
{
((Option<float>)(object)MinZoomOption).SetValue(value - ZoomOffset);
}
else if (value - ZoomOffset < MinZoomOption.MinValue)
{
((Option<float>)(object)MaxZoomOption).SetValue(MinZoomOption.MinValue + ZoomOffset);
}
}
internal void <SetupOptions>b__93_2(float value)
{
if (value > ((Option<float>)(object)MaxPitchOption).Value && value < MaxPitchOption.MaxValue)
{
((Option<float>)(object)MaxPitchOption).SetValue(value);
}
else if (value > MaxPitchOption.MaxValue)
{
((Option<float>)(object)MinPitchOption).SetValue(MaxPitchOption.MaxValue);
}
}
internal void <SetupOptions>b__93_3(float value)
{
if (value < ((Option<float>)(object)MinPitchOption).Value && value > MinPitchOption.MinValue)
{
((Option<float>)(object)MinPitchOption).SetValue(value);
}
else if (value < MinPitchOption.MinValue)
{
((Option<float>)(object)MaxPitchOption).SetValue(MinPitchOption.MinValue);
}
}
internal void <SetupKeybinds>b__94_0()
{
((Option<bool>)(object)EnabledOption).SetValue(!Enabled);
}
internal void <SetupKeybinds>b__94_1()
{
if (Enabled && !ModernCameraState.IsFirstPerson)
{
ModernCameraState.IsMouseLocked = !ModernCameraState.IsMouseLocked;
ModernCameraState.IsActionMode = !ModernCameraState.IsActionMode;
}
}
}
internal static float FirstPersonForwardOffset = 1.65f;
internal static float MountedOffset = 1.6f;
internal static float HeadHeightOffset = 1.05f;
internal static float ShoulderRightOffset = 0.8f;
internal static Dictionary<string, Vector2> FirstPersonShapeshiftOffsets = new Dictionary<string, Vector2>
{
{
"AB_Shapeshift_Bat_Buff",
new Vector2(0f, 2.5f)
},
{
"AB_Shapeshift_Bear_Buff",
new Vector2(0.25f, 5f)
},
{
"AB_Shapeshift_Bear_Skin01_Buff",
new Vector2(0.25f, 5f)
},
{
"AB_Shapeshift_Human_Grandma_Skin01_Buff",
new Vector2(-0.1f, 1.55f)
},
{
"AB_Shapeshift_Human_Buff",
new Vector2(0.5f, 1.4f)
},
{
"AB_Shapeshift_Rat_Buff",
new Vector2(-1.85f, 2f)
},
{
"AB_Shapeshift_Toad_Buff",
new Vector2(-0.6f, 4.2f)
},
{
"AB_Shapeshift_Wolf_Buff",
new Vector2(-0.25f, 4.3f)
},
{
"AB_Shapeshift_Wolf_Skin01_Buff",
new Vector2(-0.25f, 4.3f)
}
};
private static float ZoomOffset = 2f;
private static ToggleOption EnabledOption;
private static SliderOption FieldOfViewOption;
private static ToggleOption AlwaysShowCrosshairOption;
private static ToggleOption ActionModeCrosshairOption;
private static ToggleOption FirstPersonEnabledOption;
private static ToggleOption DefaultBuildModeOption;
private static DropdownOption CameraAimModeOption;
private static SliderOption AimOffsetXOption;
private static SliderOption AimOffsetYOption;
private static ToggleOption LockCameraZoomOption;
private static SliderOption LockCameraZoomDistanceOption;
private static SliderOption MinZoomOption;
private static SliderOption MaxZoomOption;
private static ToggleOption LockCameraPitchOption;
private static SliderOption LockCameraPitchAngleOption;
private static SliderOption MinPitchOption;
private static SliderOption MaxPitchOption;
private static ToggleOption OverTheShoulderOption;
private static SliderOption OverTheShoulderXOption;
private static SliderOption OverTheShoulderYOption;
private static Keybinding EnabledKeybind;
private static Keybinding ActionModeKeybind;
private static Keybinding HideUIKeybind;
internal static bool Enabled
{
get
{
return ((Option<bool>)(object)EnabledOption).Value;
}
set
{
((Option<bool>)(object)EnabledOption).SetValue(value);
}
}
internal static bool FirstPersonEnabled
{
get
{
return ((Option<bool>)(object)FirstPersonEnabledOption).Value;
}
set
{
((Option<bool>)(object)FirstPersonEnabledOption).SetValue(value);
}
}
internal static bool DefaultBuildMode
{
get
{
return ((Option<bool>)(object)DefaultBuildModeOption).Value;
}
set
{
((Option<bool>)(object)DefaultBuildModeOption).SetValue(value);
}
}
internal static bool AlwaysShowCrosshair
{
get
{
return ((Option<bool>)(object)AlwaysShowCrosshairOption).Value;
}
set
{
((Option<bool>)(object)AlwaysShowCrosshairOption).SetValue(value);
}
}
internal static bool ActionModeCrosshair
{
get
{
return ((Option<bool>)(object)ActionModeCrosshairOption).Value;
}
set
{
((Option<bool>)(object)ActionModeCrosshairOption).SetValue(value);
}
}
internal static float FieldOfView
{
get
{
return ((Option<float>)(object)FieldOfViewOption).Value;
}
set
{
((Option<float>)(object)FieldOfViewOption).SetValue(value);
}
}
internal static int AimOffsetX
{
get
{
return (int)((float)Screen.width * (((Option<float>)(object)AimOffsetXOption).Value / 100f));
}
set
{
((Option<float>)(object)AimOffsetXOption).SetValue((float)Mathf.Clamp(value / Screen.width, -25, 25));
}
}
internal static int AimOffsetY
{
get
{
return (int)((float)Screen.height * (((Option<float>)(object)AimOffsetYOption).Value / 100f));
}
set
{
((Option<float>)(object)AimOffsetYOption).SetValue((float)Mathf.Clamp(value / Screen.width, -25, 25));
}
}
internal static CameraAimMode CameraAimMode
{
get
{
return CameraAimModeOption.GetEnumValue<CameraAimMode>();
}
set
{
((Option<int>)(object)CameraAimModeOption).SetValue((int)value);
}
}
internal static bool LockZoom
{
get
{
return ((Option<bool>)(object)LockCameraZoomOption).Value;
}
set
{
((Option<bool>)(object)LockCameraZoomOption).SetValue(value);
}
}
internal static float LockZoomDistance
{
get
{
return ((Option<float>)(object)LockCameraZoomDistanceOption).Value;
}
set
{
((Option<float>)(object)LockCameraZoomDistanceOption).SetValue(value);
}
}
internal static float MinZoom
{
get
{
return ((Option<float>)(object)MinZoomOption).Value;
}
set
{
((Option<float>)(object)MinZoomOption).SetValue(value);
}
}
internal static float MaxZoom
{
get
{
return ((Option<float>)(object)MaxZoomOption).Value;
}
set
{
((Option<float>)(object)MaxZoomOption).SetValue(value);
}
}
internal static bool LockPitch
{
get
{
return ((Option<bool>)(object)LockCameraPitchOption).Value;
}
set
{
((Option<bool>)(object)LockCameraPitchOption).SetValue(value);
}
}
internal static float LockPitchAngle
{
get
{
return ((Option<float>)(object)LockCameraPitchAngleOption).Value * ((float)Math.PI / 180f);
}
set
{
((Option<float>)(object)LockCameraPitchAngleOption).SetValue(Mathf.Clamp(value * 57.29578f, 0f, 90f));
}
}
internal static float MinPitch
{
get
{
return ((Option<float>)(object)MinPitchOption).Value * ((float)Math.PI / 180f);
}
set
{
((Option<float>)(object)MinPitchOption).SetValue(Mathf.Clamp(value * 57.29578f, 0f, 90f));
}
}
internal static float MaxPitch
{
get
{
return ((Option<float>)(object)MaxPitchOption).Value * ((float)Math.PI / 180f);
}
set
{
((Option<float>)(object)MaxPitchOption).SetValue(Mathf.Clamp(value * 57.29578f, 0f, 90f));
}
}
internal static bool OverTheShoulder
{
get
{
return ((Option<bool>)(object)OverTheShoulderOption).Value;
}
set
{
((Option<bool>)(object)OverTheShoulderOption).SetValue(value);
}
}
internal static float OverTheShoulderX
{
get
{
return ((Option<float>)(object)OverTheShoulderXOption).Value;
}
set
{
((Option<float>)(object)OverTheShoulderXOption).SetValue(value);
}
}
internal static float OverTheShoulderY
{
get
{
return ((Option<float>)(object)OverTheShoulderYOption).Value;
}
set
{
((Option<float>)(object)OverTheShoulderYOption).SetValue(value);
}
}
internal static void Init()
{
SetupOptions();
SetupKeybinds();
}
internal static void AddEnabledListener(OnChange<bool> action)
{
((Option<bool>)(object)EnabledOption).AddListener(action);
}
internal static void AddFieldOfViewListener(OnChange<float> action)
{
((Option<float>)(object)FieldOfViewOption).AddListener(action);
}
internal static void AddHideUIListener(KeyEvent action)
{
HideUIKeybind.AddKeyDownListener(action);
}
private static void SetupOptions()
{
OptionCategory val = OptionsManager.AddCategory("Modern Camera");
EnabledOption = val.AddToggle("moderncamera.enabled", "Enabled", true);
FirstPersonEnabledOption = val.AddToggle("moderncamera.firstperson", "Enable First Person", true);
DefaultBuildModeOption = val.AddToggle("moderncamera.defaultbuildmode", "Use Default Build Mode Camera", true);
AlwaysShowCrosshairOption = val.AddToggle("moderncamera.alwaysshowcrosshair", "Always show Crosshair", false);
ActionModeCrosshairOption = val.AddToggle("moderncamera.actionmodecrosshair", "Show Crosshair in Action Mode", false);
FieldOfViewOption = val.AddSlider("moderncamera.fieldofview", "Field of View", 50f, 90f, 60f, 0, 0f);
val.AddDivider("Third Person Aiming");
CameraAimModeOption = val.AddDropdown("moderncamera.aimmode", "Aim Mode", 0, Enum.GetNames(typeof(CameraAimMode)));
AimOffsetXOption = val.AddSlider("moderncamera.aimoffsetx", "Screen X% Offset ", -25f, 25f, 0f, 0, 0f);
AimOffsetYOption = val.AddSlider("moderncamera.aimoffsety", "Screen Y% Offset", -25f, 25f, 0f, 0, 0f);
val.AddDivider("Third Person Zoom");
MinZoomOption = val.AddSlider("moderncamera.minzoom", "Min Zoom", 1f, 18f, 2f, 0, 0f);
MaxZoomOption = val.AddSlider("moderncamera.maxzoom", "Max Zoom", 3f, 20f, 18f, 0, 0f);
LockCameraZoomOption = val.AddToggle("moderncamera.lockzoom", "Lock Camera Zoom", false);
LockCameraZoomDistanceOption = val.AddSlider("moderncamera.lockzoomdistance", "Locked Camera Zoom Distance", 6f, 20f, 15f, 0, 0f);
val.AddDivider("Third Person Pitch");
MinPitchOption = val.AddSlider("moderncamera.minpitch", "Min Pitch", 0f, 90f, 9f, 0, 0f);
MaxPitchOption = val.AddSlider("moderncamera.maxpitch", "Max Pitch", 0f, 90f, 90f, 0, 0f);
LockCameraPitchOption = val.AddToggle("moderncamera.lockpitch", "Lock Camera Pitch", false);
LockCameraPitchAngleOption = val.AddSlider("moderncamera.lockpitchangle", "Locked Camera Pitch Angle", 0f, 90f, 60f, 0, 0f);
val.AddDivider("Over the Shoulder");
OverTheShoulderOption = val.AddToggle("moderncamera.overtheshoulder", "Use Over the Shoulder Offset", false);
OverTheShoulderXOption = val.AddSlider("moderncamera.overtheshoulderx", "X Offset", 0.5f, 4f, 1f, 0, 0f);
OverTheShoulderYOption = val.AddSlider("moderncamera.overtheshouldery", "Y Offset", 1f, 8f, 1f, 0, 0f);
((Option<float>)(object)MinZoomOption).AddListener((OnChange<float>)delegate(float value)
{
if (value + ZoomOffset > MaxZoom && value + ZoomOffset < MaxZoomOption.MaxValue)
{
((Option<float>)(object)MaxZoomOption).SetValue(value + ZoomOffset);
}
else if (value + ZoomOffset > MaxZoomOption.MaxValue)
{
((Option<float>)(object)MinZoomOption).SetValue(MaxZoomOption.MaxValue - ZoomOffset);
}
});
((Option<float>)(object)MaxZoomOption).AddListener((OnChange<float>)delegate(float value)
{
if (value - ZoomOffset < MinZoom && value - ZoomOffset > MinZoomOption.MinValue)
{
((Option<float>)(object)MinZoomOption).SetValue(value - ZoomOffset);
}
else if (value - ZoomOffset < MinZoomOption.MinValue)
{
((Option<float>)(object)MaxZoomOption).SetValue(MinZoomOption.MinValue + ZoomOffset);
}
});
((Option<float>)(object)MinPitchOption).AddListener((OnChange<float>)delegate(float value)
{
if (value > ((Option<float>)(object)MaxPitchOption).Value && value < MaxPitchOption.MaxValue)
{
((Option<float>)(object)MaxPitchOption).SetValue(value);
}
else if (value > MaxPitchOption.MaxValue)
{
((Option<float>)(object)MinPitchOption).SetValue(MaxPitchOption.MaxValue);
}
});
((Option<float>)(object)MaxPitchOption).AddListener((OnChange<float>)delegate(float value)
{
if (value < ((Option<float>)(object)MinPitchOption).Value && value > MinPitchOption.MinValue)
{
((Option<float>)(object)MinPitchOption).SetValue(value);
}
else if (value < MinPitchOption.MinValue)
{
((Option<float>)(object)MaxPitchOption).SetValue(MinPitchOption.MinValue);
}
});
}
private static void SetupKeybinds()
{
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Expected O, but got Unknown
//IL_007b: 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_0086: Expected O, but got Unknown
KeybindingCategory val = KeybindingsManager.AddCategory("Modern Camera");
EnabledKeybind = val.AddKeyBinding("moderncamera.enabled", "Enabled", (string)null);
Keybinding enabledKeybind = EnabledKeybind;
object obj = <>c.<>9__94_0;
if (obj == null)
{
KeyEvent val2 = delegate
{
((Option<bool>)(object)EnabledOption).SetValue(!Enabled);
};
<>c.<>9__94_0 = val2;
obj = (object)val2;
}
enabledKeybind.AddKeyDownListener((KeyEvent)obj);
ActionModeKeybind = val.AddKeyBinding("moderncamera.actionmode", "Action Mode", (string)null);
Keybinding actionModeKeybind = ActionModeKeybind;
object obj2 = <>c.<>9__94_1;
if (obj2 == null)
{
KeyEvent val3 = delegate
{
if (Enabled && !ModernCameraState.IsFirstPerson)
{
ModernCameraState.IsMouseLocked = !ModernCameraState.IsMouseLocked;
ModernCameraState.IsActionMode = !ModernCameraState.IsActionMode;
}
};
<>c.<>9__94_1 = val3;
obj2 = (object)val3;
}
actionModeKeybind.AddKeyDownListener((KeyEvent)obj2);
HideUIKeybind = val.AddKeyBinding("moderncamera.hideui", "Hide UI", (string)null);
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "VRising.ModernCamera";
public const string PLUGIN_NAME = "ModernCamera";
public const string PLUGIN_VERSION = "1.5.6";
}
}
namespace ModernCamera.Utils
{
internal static class Mouse
{
[DllImport("user32.dll")]
private static extern bool SetCursorPos(int X, int Y);
[DllImport("user32.dll")]
private static extern bool GetCursorPos(out POINT point);
[DllImport("user32.dll")]
private static extern void mouse_event(int dwFlags, int dx, int dy, int dwData, int dwExtraInfo);
internal static bool SetCursorPosition(POINT point)
{
return SetCursorPos(point.X, point.Y);
}
internal static bool SetCursorPosition(int x, int y)
{
POINT pOINT = Window.ClientToScreen(x, y);
return SetCursorPos(pOINT.X, pOINT.Y);
}
internal static void CenterCursorPosition()
{
RECT clientRect = Window.GetClientRect();
SetCursorPosition((clientRect.Right - clientRect.Left) / 2, (clientRect.Bottom - clientRect.Top) / 2);
}
internal static POINT GetCursorPosition()
{
GetCursorPos(out var point);
return point;
}
internal static void Click(MouseEvent mouseEvent)
{
Click(mouseEvent, GetCursorPosition());
}
internal static void Click(MouseEvent mouseEvent, POINT point)
{
mouse_event((int)mouseEvent, point.X, point.Y, 0, 0);
}
internal static void Click(MouseEvent mouseEvent, int x, int y)
{
mouse_event((int)mouseEvent, x, y, 0, 0);
}
}
internal static class Window
{
internal static IntPtr Handle;
[DllImport("user32.dll", CharSet = CharSet.Auto)]
private static extern IntPtr FindWindow(string strClassName, string strWindowName);
[DllImport("user32.dll")]
private static extern bool GetWindowRect(IntPtr hwnd, ref RECT rectangle);
[DllImport("user32.dll")]
private static extern bool GetClientRect(IntPtr hwnd, ref RECT rectangle);
[DllImport("user32.dll")]
private static extern bool ClientToScreen(IntPtr hwnd, ref POINT point);
[DllImport("user32.dll")]
private static extern bool ScreenToClient(IntPtr hwnd, ref POINT point);
static Window()
{
Handle = GetWindow("VRising");
}
public static IntPtr GetWindow(string title)
{
return FindWindow(null, title);
}
public static RECT GetWindowRect()
{
RECT rectangle = default(RECT);
GetWindowRect(Handle, ref rectangle);
return rectangle;
}
public static RECT GetClientRect()
{
RECT rectangle = default(RECT);
GetClientRect(Handle, ref rectangle);
return rectangle;
}
public static POINT ClientToScreen(int x, int y)
{
POINT point = new POINT(x, y);
ClientToScreen(Handle, ref point);
return point;
}
public static POINT ClientToScreen(POINT point)
{
return ClientToScreen(point.X, point.Y);
}
public static POINT ScreenToClient(int x, int y)
{
POINT point = new POINT(x, y);
ClientToScreen(Handle, ref point);
return point;
}
public static POINT ScreenToClient(POINT point)
{
return ScreenToClient(point.X, point.Y);
}
}
}
namespace ModernCamera.Structs
{
internal struct POINT
{
internal int X;
internal int Y;
internal POINT(int X, int Y)
{
this.X = X;
this.Y = Y;
}
}
internal struct RECT
{
internal int Left;
internal int Top;
internal int Right;
internal int Bottom;
internal RECT(int Left, int Top, int Right, int Bottom)
{
this.Left = Left;
this.Top = Top;
this.Right = Right;
this.Bottom = Bottom;
}
}
}
namespace ModernCamera.Patches
{
[HarmonyPatch]
internal static class ActionWheelSystem_Patch
{
private static bool WheelVisible;
[HarmonyPostfix]
[HarmonyPatch(typeof(ActionWheelSystem), "OnUpdate")]
private static void OnUpdate(ActionWheelSystem __instance)
{
if (!WheelVisible && (__instance._CurrentActiveWheel.IsVisible() || __instance._EmotesWheel.IsVisible()))
{
ModernCameraState.IsMenuOpen = true;
WheelVisible = true;
}
else if (WheelVisible && !__instance._CurrentActiveWheel.IsVisible() && !__instance._EmotesWheel.IsVisible())
{
ModernCameraState.IsMenuOpen = false;
WheelVisible = false;
}
}
}
[HarmonyPatch]
internal class EscapeMenuView_Patch
{
[HarmonyPostfix]
[HarmonyPatch(typeof(EscapeMenuView), "OnEnable")]
private static void OnEnable()
{
ModernCameraState.IsMenuOpen = true;
}
[HarmonyPostfix]
[HarmonyPatch(typeof(EscapeMenuView), "OnDestroy")]
private static void OnDestroy()
{
ModernCameraState.IsMenuOpen = false;
}
}
[HarmonyPatch]
internal static class GameplayInputSystem_Patch
{
[HarmonyPrefix]
[HarmonyPatch(typeof(GameplayInputSystem), "HandleInput")]
private unsafe static void HandleInputPrefix(ref InputState inputState)
{
//IL_0008: 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_0049: Unknown result type (might be due to invalid IL or missing references)
ModernCameraState.ValidGameplayInputState = true;
ModernCameraState.GameplayInputState = inputState;
if (Settings.Enabled && ModernCameraState.IsMouseLocked && !ModernCameraState.IsMenuOpen && !((InputState)(ref inputState)).IsInputPressed((ButtonInputAction)500))
{
ButtonInputAction val = (ButtonInputAction)500;
inputState.InputsPressed.m_ListData->Add(ref val);
}
}
}
[HarmonyPatch]
internal static class HUDElementComponent_Patch
{
[HarmonyPostfix]
[HarmonyPatch(typeof(HUDElementComponent), "UpdateVisibility")]
private static void UpdateVisibility(HUDElementComponent __instance)
{
if (!((Object)((Component)__instance).gameObject).name.Equals("InteractorEntry(Clone)"))
{
return;
}
foreach (CanvasGroup componentsInChild in ((Component)__instance).GetComponentsInChildren<CanvasGroup>())
{
componentsInChild.alpha = 1f;
}
}
}
[HarmonyPatch]
internal static class HUDMenu_Patch
{
[HarmonyPostfix]
[HarmonyPatch(typeof(HUDMenu), "OnEnable")]
private static void OnEnable()
{
ModernCameraState.IsMenuOpen = true;
}
[HarmonyPostfix]
[HarmonyPatch(typeof(HUDMenu), "OnDisable")]
private static void OnDisable()
{
ModernCameraState.IsMenuOpen = false;
}
}
[HarmonyPatch]
internal static class OptionsMenu_Base_Patch
{
[HarmonyPostfix]
[HarmonyPatch(typeof(OptionsMenu_Base), "Start")]
private static void Start()
{
ModernCameraState.IsMenuOpen = true;
}
[HarmonyPostfix]
[HarmonyPatch(typeof(OptionsMenu_Base), "OnDestroy")]
private static void OnDestroy()
{
ModernCameraState.IsMenuOpen = false;
}
}
[HarmonyPatch]
internal static class TopdownCameraSystem_Patch
{
[HarmonyPrefix]
[HarmonyPatch(typeof(TopdownCameraSystem), "OnUpdate")]
private static void OnUpdatePrefix(TopdownCameraSystem __instance)
{
//IL_0010: 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)
if (Settings.Enabled)
{
__instance._ZoomModifierSystem._ZoomModifiers.Clear();
}
}
}
[HarmonyPatch]
internal class UIEntryPoint_Patch
{
[HarmonyPostfix]
[HarmonyPatch(typeof(UIEntryPoint), "Awake")]
private static void AwakePostfix()
{
ModernCameraState.Reset();
}
}
}
namespace ModernCamera.Hooks
{
internal static class TopdownCameraSystem_Hook
{
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate void HandleInput(IntPtr _this, ref InputState inputState);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate void UpdateCameraInputs(IntPtr _this, ref TopdownCameraState cameraState, ref TopdownCamera cameraData);
private static HandleInput? HandleInputOriginal;
private static INativeDetour? HandleInputDetour;
private static UpdateCameraInputs? UpdateCameraInputsOriginal;
private static INativeDetour? UpdateCameraInputsDetour;
private static bool DefaultZoomSettingsSaved;
private static bool UsingDefaultZoomSettings;
private static ZoomSettings DefaultZoomSettings;
private static ZoomSettings DefaultStandardZoomSettings;
private static ZoomSettings DefaultBuildModeZoomSettings;
internal static void CreateAndApply()
{
if (HandleInputDetour == null)
{
HandleInputDetour = DetourUtils.Create<HandleInput>(typeof(TopdownCameraSystem), "HandleInput", (HandleInput)HandleInputHook, ref HandleInputOriginal);
}
if (UpdateCameraInputsDetour == null)
{
UpdateCameraInputsDetour = DetourUtils.Create<UpdateCameraInputs>(typeof(TopdownCameraSystem), "UpdateCameraInputs", "OriginalLambdaBody", (UpdateCameraInputs)UpdateCameraInputsHook, ref UpdateCameraInputsOriginal);
}
}
internal static void Dispose()
{
((IDisposable)UpdateCameraInputsDetour)?.Dispose();
((IDisposable)HandleInputDetour)?.Dispose();
}
private static void HandleInputHook(IntPtr _this, ref InputState inputState)
{
if (Settings.Enabled)
{
ModernCameraState.CurrentCameraBehaviour?.HandleInput(ref inputState);
}
HandleInputOriginal(_this, ref inputState);
}
private static void UpdateCameraInputsHook(IntPtr _this, ref TopdownCameraState cameraState, ref TopdownCamera cameraData)
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: 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_011e: Unknown result type (might be due to invalid IL or missing references)
//IL_0123: Unknown result type (might be due to invalid IL or missing references)
//IL_0129: Unknown result type (might be due to invalid IL or missing references)
//IL_012e: Unknown result type (might be due to invalid IL or missing references)
//IL_0134: Unknown result type (might be due to invalid IL or missing references)
//IL_0139: Unknown result type (might be due to invalid IL or missing references)
//IL_00f7: 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)
if (Settings.Enabled)
{
if (!DefaultZoomSettingsSaved)
{
DefaultZoomSettings = cameraState.ZoomSettings;
DefaultStandardZoomSettings = cameraData.StandardZoomSettings;
DefaultBuildModeZoomSettings = cameraData.BuildModeZoomSettings;
DefaultZoomSettingsSaved = true;
}
UsingDefaultZoomSettings = false;
cameraState.ZoomSettings.MaxZoom = Settings.MaxZoom;
cameraState.ZoomSettings.MinZoom = 0f;
foreach (CameraBehaviour value in ModernCameraState.CameraBehaviours.Values)
{
if (value.ShouldActivate(ref cameraState))
{
ModernCameraState.CurrentCameraBehaviour?.Deactivate();
value.Activate(ref cameraState);
break;
}
}
if (!ModernCameraState.CurrentCameraBehaviour.Active)
{
ModernCameraState.CurrentCameraBehaviour.Activate(ref cameraState);
}
ModernCameraState.CurrentCameraBehaviour.UpdateCameraInputs(ref cameraState, ref cameraData);
cameraData.StandardZoomSettings = cameraState.ZoomSettings;
}
else if (DefaultZoomSettingsSaved && !UsingDefaultZoomSettings)
{
cameraState.ZoomSettings = DefaultZoomSettings;
cameraData.StandardZoomSettings = DefaultStandardZoomSettings;
cameraData.BuildModeZoomSettings = DefaultBuildModeZoomSettings;
UsingDefaultZoomSettings = true;
}
UpdateCameraInputsOriginal(_this, ref cameraState, ref cameraData);
}
}
}
namespace ModernCamera.Enums
{
internal enum BehaviourType
{
Default,
FirstPerson,
ThirdPerson
}
internal enum CameraAimMode
{
Default,
Forward
}
[Flags]
internal enum MouseEvent
{
Absolute = 0x8000,
LeftDown = 2,
LeftUp = 4,
MiddleDown = 0x20,
MiddleUp = 0x40,
Move = 1,
RightDown = 8,
RightUp = 0x10
}
}
namespace ModernCamera.Behaviours
{
internal abstract class CameraBehaviour
{
internal BehaviourType BehaviourType;
internal float DefaultMaxPitch;
internal float DefaultMinPitch;
internal bool Active;
protected static float TargetZoom = Settings.MaxZoom / 2f;
protected static ZoomSettings BuildModeZoomSettings;
protected static bool IsBuildSettingsSet;
internal virtual void Activate(ref TopdownCameraState state)
{
Active = true;
}
internal virtual void Deactivate()
{
TargetZoom = Settings.MaxZoom / 2f;
Active = false;
}
internal virtual bool ShouldActivate(ref TopdownCameraState state)
{
return false;
}
internal unsafe virtual void HandleInput(ref InputState inputState)
{
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
if (inputState.InputsPressed.IsCreated && ModernCameraState.IsMouseLocked && !ModernCameraState.IsMenuOpen && !((InputState)(ref inputState)).IsInputPressed((ButtonInputAction)500))
{
ButtonInputAction val = (ButtonInputAction)500;
inputState.InputsPressed.m_ListData->Add(ref val);
}
float analogValue = ((InputState)(ref inputState)).GetAnalogValue((AnalogInputAction)16);
if (analogValue != 0f && (!ModernCameraState.InBuildMode || !Settings.DefaultBuildMode))
{
float num = Mathf.Lerp(0.25f, 1.5f, Mathf.Max(0f, TargetZoom - Settings.MinZoom) / Settings.MaxZoom);
float num2 = ((((InputState)(ref inputState)).GetAnalogValue((AnalogInputAction)16) > 0f) ? num : (0f - num));
if ((TargetZoom > Settings.MinZoom && TargetZoom + num2 < Settings.MinZoom) || (ModernCameraState.IsFirstPerson && num2 > 0f))
{
TargetZoom = Settings.MinZoom;
}
else
{
TargetZoom = Mathf.Clamp(TargetZoom + num2, Settings.FirstPersonEnabled ? 0f : Settings.MinZoom, Settings.MaxZoom);
}
((InputState)(ref inputState)).SetAnalogValue((AnalogInputAction)16, 0f);
}
if (TargetZoom > Settings.MaxZoom)
{
TargetZoom = Settings.MaxZoom;
}
}
internal virtual void UpdateCameraInputs(ref TopdownCameraState state, ref TopdownCamera data)
{
//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)
//IL_00be: 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)
ModernCameraState.InBuildMode = state.InBuildMode;
if (!IsBuildSettingsSet)
{
BuildModeZoomSettings = data.BuildModeZoomSettings;
IsBuildSettingsSet = true;
}
state.ZoomSettings.MaxPitch = DefaultMaxPitch;
state.ZoomSettings.MinPitch = DefaultMinPitch;
if (!state.InBuildMode || !Settings.DefaultBuildMode)
{
data.BuildModeZoomSettings.MaxPitch = DefaultMaxPitch;
data.BuildModeZoomSettings.MinPitch = DefaultMinPitch;
state.LastTarget.Zoom = TargetZoom;
state.Target.Zoom = TargetZoom;
}
if (state.InBuildMode && Settings.DefaultBuildMode)
{
data.BuildModeZoomSettings = BuildModeZoomSettings;
state.LastTarget.Zoom = data.BuildModeZoomDistance;
state.Target.Zoom = data.BuildModeZoomDistance;
}
}
}
internal class FirstPersonCameraBehaviour : CameraBehaviour
{
internal FirstPersonCameraBehaviour()
{
BehaviourType = BehaviourType.FirstPerson;
DefaultMaxPitch = 1.57f;
DefaultMinPitch = -1.57f;
}
internal override void Activate(ref TopdownCameraState state)
{
base.Activate(ref state);
ModernCameraState.IsMouseLocked = true;
ModernCameraState.IsFirstPerson = true;
ModernCameraState.CurrentBehaviourType = BehaviourType;
state.PitchPercent = 0.51f;
CameraBehaviour.TargetZoom = 0f;
}
internal override void Deactivate()
{
base.Deactivate();
if (!ModernCameraState.IsActionMode)
{
ModernCameraState.IsMouseLocked = false;
}
ModernCameraState.IsFirstPerson = false;
}
internal override bool ShouldActivate(ref TopdownCameraState state)
{
return Settings.FirstPersonEnabled && ModernCameraState.CurrentBehaviourType != BehaviourType && CameraBehaviour.TargetZoom < Settings.MinZoom;
}
internal override void UpdateCameraInputs(ref TopdownCameraState state, ref TopdownCamera data)
{
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
base.UpdateCameraInputs(ref state, ref data);
float z = Settings.FirstPersonForwardOffset;
float num = Settings.HeadHeightOffset;
if (Settings.FirstPersonShapeshiftOffsets.ContainsKey(ModernCameraState.ShapeshiftName))
{
z = Settings.FirstPersonShapeshiftOffsets[ModernCameraState.ShapeshiftName].y;
num = Settings.FirstPersonShapeshiftOffsets[ModernCameraState.ShapeshiftName].x;
}
state.LastTarget.NormalizedLookAtOffset.z = z;
state.LastTarget.NormalizedLookAtOffset.y = (ModernCameraState.IsMounted ? (num + Settings.MountedOffset) : num);
}
}
internal class ThirdPersonCameraBehaviour : CameraBehaviour
{
private float LastPitchPercent = float.PositiveInfinity;
internal ThirdPersonCameraBehaviour()
{
BehaviourType = BehaviourType.ThirdPerson;
}
internal override void Activate(ref TopdownCameraState state)
{
base.Activate(ref state);
if (ModernCameraState.CurrentBehaviourType == BehaviourType)
{
CameraBehaviour.TargetZoom = Settings.MaxZoom / 2f;
}
else
{
CameraBehaviour.TargetZoom = Settings.MinZoom;
}
ModernCameraState.CurrentBehaviourType = BehaviourType;
state.PitchPercent = ((LastPitchPercent == float.PositiveInfinity) ? 0.5f : LastPitchPercent);
}
internal override bool ShouldActivate(ref TopdownCameraState state)
{
return ModernCameraState.CurrentBehaviourType != BehaviourType && CameraBehaviour.TargetZoom > 0f;
}
internal override void HandleInput(ref InputState inputState)
{
base.HandleInput(ref inputState);
if (Settings.LockZoom)
{
CameraBehaviour.TargetZoom = Settings.LockZoomDistance;
}
}
internal override void UpdateCameraInputs(ref TopdownCameraState state, ref TopdownCamera data)
{
DefaultMaxPitch = Settings.MaxPitch;
DefaultMinPitch = Settings.MinPitch;
base.UpdateCameraInputs(ref state, ref data);
state.LastTarget.NormalizedLookAtOffset.y = (ModernCameraState.IsMounted ? (Settings.HeadHeightOffset + Settings.MountedOffset) : Settings.HeadHeightOffset);
if (Settings.OverTheShoulder && !ModernCameraState.IsShapeshifted && !ModernCameraState.IsMounted)
{
float num = Mathf.Max(0f, state.Current.Zoom - state.ZoomSettings.MinZoom) / state.ZoomSettings.MaxZoom;
state.LastTarget.NormalizedLookAtOffset.x = Mathf.Lerp(Settings.OverTheShoulderX, 0f, num);
state.LastTarget.NormalizedLookAtOffset.y = Mathf.Lerp(Settings.OverTheShoulderY, 0f, num);
}
if (Settings.LockPitch && (!state.InBuildMode || !Settings.DefaultBuildMode))
{
state.ZoomSettings.MaxPitch = Settings.LockPitchAngle;
state.ZoomSettings.MinPitch = Settings.LockPitchAngle;
data.BuildModeZoomSettings.MaxPitch = Settings.LockPitchAngle;
data.BuildModeZoomSettings.MinPitch = Settings.LockPitchAngle;
}
LastPitchPercent = state.PitchPercent;
}
}
}