Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of BetterCamera v0.5.4
BetterCamera.dll
Decompiled 15 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BetterCamera.Camera; using BetterCamera.Combat; using BetterCamera.Core; using BetterCamera.FirstPerson; using BetterCamera.Photo; using BetterCamera.UI; using HarmonyLib; using Jotunn; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using Jotunn.Utils; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; using UnityEngine.Rendering; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: IgnoresAccessChecksTo("")] [assembly: AssemblyCompany("BetterCamera")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Play Valheim in first person, take pictures in photo mode, and get more control over the camera while walking, sailing and riding.")] [assembly: AssemblyFileVersion("0.5.4.0")] [assembly: AssemblyInformationalVersion("0.5.4+a12c970938cda3102a8b0d9f25b38cb9aacffdd4")] [assembly: AssemblyProduct("BetterCamera")] [assembly: AssemblyTitle("BetterCamera")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.5.4.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace BetterCamera { [BepInPlugin("javidahmed64592.bettercamera", "Better Camera", "0.5.4")] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] public class BetterCameraPlugin : BaseUnityPlugin { public const string PluginGUID = "javidahmed64592.bettercamera"; public const string PluginName = "Better Camera"; public const string PluginVersion = "0.5.4"; private Harmony _harmony; private void Awake() { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Expected O, but got Unknown CameraController.BindConfig(((BaseUnityPlugin)this).Config); ShipHud.BindConfig(((BaseUnityPlugin)this).Config); FirstPersonSettings.BindConfig(((BaseUnityPlugin)this).Config); PhotoMode.BindConfig(((BaseUnityPlugin)this).Config); MeleeAim.BindConfig(((BaseUnityPlugin)this).Config); Translations.Load(); _harmony = new Harmony("javidahmed64592.bettercamera"); _harmony.PatchAll(); } private void OnDestroy() { PhotoMode.Exit(Player.m_localPlayer, null); Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } FirstPersonBody.Restore(); } private void Update() { Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { PhotoMode.Exit(null, null); CameraController.Reset(); } else { CameraController.UpdateInput(localPlayer); PhotoMode.UpdateInput(localPlayer); } } } } namespace BetterCamera.UI { internal static class ShipHud { private static ConfigEntry<float> _positionX; private static ConfigEntry<float> _positionY; private static ConfigEntry<bool> _alwaysFixed; public static void BindConfig(ConfigFile config) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Expected O, but got Unknown _positionX = config.Bind<float>("Ship Controls", "Fixed Position Across", 0.5f, new ConfigDescription("Where across the screen the sail and rudder indicator goes in first person, as a fraction of the screen's width from the left (0.5 is the middle).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); _positionY = config.Bind<float>("Ship Controls", "Fixed Position Up", 0.25f, new ConfigDescription("Where up the screen the sail and rudder indicator goes in first person, as a fraction of the screen's height from the bottom (0.25 is a quarter of the way up).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); _alwaysFixed = config.Bind<bool>("Ship Controls", "Always Fixed", false, "Keep the sail and rudder indicator at the fixed position in third person too, instead of beside the helm."); } public static void AfterUpdate(Hud hud) { //IL_0091: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)hud.m_shipControlsRoot == (Object)null) && hud.m_shipHudRoot.activeSelf) { GameCamera instance = GameCamera.instance; if (((Object)(object)instance != (Object)null && !instance.m_freeFly && instance.m_distance <= 0f) || _alwaysFixed.Value) { hud.m_shipControlsRoot.transform.position = new Vector3((float)Screen.width * Mathf.Clamp01(_positionX.Value), (float)Screen.height * Mathf.Clamp01(_positionY.Value), 0f); } } } } } namespace BetterCamera.Photo { internal static class PhotoCharacter { private static readonly Dictionary<Renderer, bool> Hidden = new Dictionary<Renderer, bool>(); private static readonly List<Renderer> Renderers = new List<Renderer>(); public static bool IsHidden { get; private set; } public static void Toggle() { IsHidden = !IsHidden; if (!IsHidden) { Restore(); } } public static void Apply(Player player) { if (!IsHidden || (Object)(object)player == (Object)null || (Object)(object)((Character)player).m_visual == (Object)null) { return; } ((Character)player).m_visual.GetComponentsInChildren<Renderer>(true, Renderers); foreach (Renderer renderer in Renderers) { if (!Hidden.ContainsKey(renderer)) { Hidden[renderer] = renderer.enabled; } renderer.enabled = false; } } public static void Reset() { IsHidden = false; Restore(); } private static void Restore() { foreach (KeyValuePair<Renderer, bool> item in Hidden) { if ((Object)(object)item.Key != (Object)null) { item.Key.enabled = item.Value; } } Hidden.Clear(); } } internal static class PhotoHud { private static readonly Dictionary<Transform, Vector3> Hidden = new Dictionary<Transform, Vector3>(); private static readonly List<Transform> Parts = new List<Transform>(); public static void Hide() { //IL_0042: 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) Collect(); foreach (Transform part in Parts) { if (!((Object)(object)part == (Object)null)) { if (!Hidden.ContainsKey(part)) { Hidden[part] = part.localScale; } part.localScale = Vector3.zero; } } } public static void Restore() { //IL_002d: Unknown result type (might be due to invalid IL or missing references) foreach (KeyValuePair<Transform, Vector3> item in Hidden) { if ((Object)(object)item.Key != (Object)null) { item.Key.localScale = item.Value; } } Hidden.Clear(); } private static void Collect() { Parts.Clear(); Hud instance = Hud.instance; if ((Object)(object)instance != (Object)null) { Parts.Add((Transform)(object)instance.m_healthPanel); Parts.Add((Transform)(object)instance.m_staminaBar2Root); Parts.Add((Transform)(object)instance.m_eitrBarRoot); Parts.Add((Transform)(object)instance.m_adrenalineBarRoot); Parts.Add(((Object)(object)instance.m_shipHudRoot != (Object)null) ? instance.m_shipHudRoot.transform : null); Parts.Add(((Object)(object)instance.m_mountPanel != (Object)null) ? instance.m_mountPanel.transform : null); if ((Object)(object)instance.m_rootObject != (Object)null) { HotkeyBar[] componentsInChildren = instance.m_rootObject.GetComponentsInChildren<HotkeyBar>(true); foreach (HotkeyBar val in componentsInChildren) { Parts.Add(((Component)val).transform); } } } if ((Object)(object)Minimap.instance != (Object)null && (Object)(object)Minimap.instance.m_smallRoot != (Object)null) { Parts.Add(Minimap.instance.m_smallRoot.transform); } } } internal static class PhotoKeyHints { private sealed class Hint { public string[] Keys; public string Separator = "+"; public Func<string> Label; public TextMeshProUGUI LabelText; public string ShownLabel; public GameObject Row; } private const string ContainerName = "BetterCamera_PhotoHints"; private const string ScrollIcon = "@scroll"; private const string ToggleKey = "@toggle"; private const string RollLeftKey = "@rollleft"; private const string RollRightKey = "@rollright"; private const string ResetKey = "@reset"; private const string HideUiKey = "@hideui"; private const string HideCharacterKey = "@hidecharacter"; private const string ReturnKey = "@return"; private const float LabelFontSize = 16f; private const float IconHeight = 32f; private const float IconScale = 1.8f; private const float RowSpacing = 12f; private static readonly List<Hint> Hints = new List<Hint>(14) { new Hint { Keys = new string[1] { "@toggle" }, Label = () => "$bettercamera_photo_hint_exit" }, new Hint { Keys = new string[1] { "F11" }, Label = () => "$bettercamera_photo_hint_screenshot" }, new Hint { Keys = new string[1] { "@hideui" }, Label = () => "$bettercamera_photo_hint_hud" }, new Hint { Keys = new string[1] { "@hidecharacter" }, Label = () => (!PhotoCharacter.IsHidden) ? "$bettercamera_photo_hint_hide_character" : "$bettercamera_photo_hint_show_character" }, new Hint { Keys = new string[1] { "@return" }, Label = () => "$bettercamera_photo_hint_return" }, new Hint { Keys = new string[1] { "@reset" }, Label = () => "$bettercamera_photo_hint_reset" }, new Hint { Keys = new string[2] { "@rollleft", "@rollright" }, Separator = "/", Label = () => "$bettercamera_photo_hint_roll" }, new Hint { Keys = new string[2] { "Left Alt", "@scroll" }, Label = () => "$bettercamera_photo_hint_speed" }, new Hint { Keys = new string[1] { "@scroll" }, Label = () => "$bettercamera_photo_hint_zoom" }, new Hint { Keys = new string[1] { "$KEY_SecondaryAttack" }, Label = () => (!PhotoMode.Following) ? "$bettercamera_photo_hint_follow" : "$bettercamera_photo_hint_unfollow" }, new Hint { Keys = new string[1] { "$KEY_Attack" }, Label = () => (!PhotoMode.LookingAt) ? "$bettercamera_photo_hint_look" : "$bettercamera_photo_hint_unlook" }, new Hint { Keys = new string[1] { "$KEY_Run" }, Label = () => "$bettercamera_photo_hint_fast" }, new Hint { Keys = new string[2] { "$KEY_Jump", "$KEY_Crouch" }, Separator = "/", Label = () => "$bettercamera_photo_hint_updown" }, new Hint { Keys = new string[4] { "$KEY_Forward", "$KEY_Left", "$KEY_Backward", "$KEY_Right" }, Separator = null, Label = () => "$bettercamera_photo_hint_move" } }; private static readonly string[] AllLabels = new string[17] { "$bettercamera_photo_hint_exit", "$bettercamera_photo_hint_screenshot", "$bettercamera_photo_hint_hud", "$bettercamera_photo_hint_hide_character", "$bettercamera_photo_hint_show_character", "$bettercamera_photo_hint_return", "$bettercamera_photo_hint_reset", "$bettercamera_photo_hint_roll", "$bettercamera_photo_hint_speed", "$bettercamera_photo_hint_zoom", "$bettercamera_photo_hint_follow", "$bettercamera_photo_hint_unfollow", "$bettercamera_photo_hint_look", "$bettercamera_photo_hint_unlook", "$bettercamera_photo_hint_fast", "$bettercamera_photo_hint_updown", "$bettercamera_photo_hint_move" }; private static GameObject _container; private static RectTransform _stack; private static RectTransform _keyboard; private static bool _createFailed; private static bool _layoutDirty; internal static void AfterUpdateHints(KeyHints keyHints) { if (_container != null && (Object)(object)_container == (Object)null) { Reset(); } if (!PhotoMode.Active || ZInput.IsGamepadActive() || !keyHints.m_keyHintsEnabled || InventoryGui.IsVisible()) { SetContainerActive(active: false); } else { if ((Object)(object)_container == (Object)null && (_createFailed || !Create(keyHints))) { return; } keyHints.m_buildHints.SetActive(false); keyHints.m_combatHints.SetActive(false); keyHints.m_fishingHints.SetActive(false); foreach (Hint hint in Hints) { string text = hint.Label(); if (text != hint.ShownLabel) { hint.ShownLabel = text; ((TMP_Text)hint.LabelText).text = Localization.instance.Localize(text); } } SetContainerActive(active: true); if (_layoutDirty) { LayoutRebuilder.ForceRebuildLayoutImmediate(_stack); _layoutDirty = false; } Align(); } } private static void SetContainerActive(bool active) { if ((Object)(object)_container != (Object)null && _container.activeSelf != active) { _container.SetActive(active); _layoutDirty |= active; } } private static void Align() { //IL_003e: 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_00a4: Unknown result type (might be due to invalid IL or missing references) Vector3[] array = (Vector3[])(object)new Vector3[4]; _keyboard.GetWorldCorners(array); HorizontalLayoutGroup component = ((Component)_keyboard).GetComponent<HorizontalLayoutGroup>(); float num = (((Object)(object)component != (Object)null) ? ((float)((LayoutGroup)component).padding.right * ((Transform)_keyboard).lossyScale.x) : 0f); float num2 = (((Object)(object)component != (Object)null) ? ((float)((LayoutGroup)component).padding.bottom * ((Transform)_keyboard).lossyScale.y) : 0f); ((Transform)_stack).position = new Vector3(array[3].x - num, array[3].y + num2, array[3].z); } private static bool Create(KeyHints keyHints) { //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0300: Unknown result type (might be due to invalid IL or missing references) //IL_030a: Expected O, but got Unknown Transform val = keyHints.m_buildHints.transform.Find("Keyboard"); Transform val2 = (((Object)(object)val != (Object)null) ? val.Find("Copy") : null); Transform val3 = (((Object)(object)val != (Object)null) ? val.Find("rotate") : null); Transform val4 = (((Object)(object)val2 != (Object)null) ? val2.Find("Text") : null); Transform val5 = (((Object)(object)val2 != (Object)null) ? val2.Find("Text (1)") : null); Transform val6 = (((Object)(object)val2 != (Object)null) ? val2.Find("key_bkg") : null); Transform val7 = (((Object)(object)val3 != (Object)null) ? val3.Find("mousew_icon") : null); HorizontalLayoutGroup val8 = (((Object)(object)val2 != (Object)null) ? ((Component)val2).GetComponent<HorizontalLayoutGroup>() : null); if ((Object)(object)val4 == (Object)null || (Object)(object)val5 == (Object)null || (Object)(object)val6 == (Object)null || (Object)(object)val7 == (Object)null || (Object)(object)val8 == (Object)null) { _createFailed = true; Logger.LogWarning((object)"Vanilla key hints layout not as expected, not showing photo mode key hints."); return false; } RectTransform component = new GameObject("BetterCamera_PhotoHints", new Type[1] { typeof(RectTransform) }).GetComponent<RectTransform>(); ((Transform)component).SetParent(((Component)keyHints).transform, false); RectTransform val9 = CreateStack(component); string text = LongestLabel(); foreach (Hint hint in Hints) { GameObject val10 = Object.Instantiate<GameObject>(((Component)val2).gameObject, (Transform)(object)val9, false); ((Object)val10).name = "BetterCamera_PhotoHint"; val10.SetActive(true); for (int num = val10.transform.childCount - 1; num >= 0; num--) { Object.DestroyImmediate((Object)(object)((Component)val10.transform.GetChild(num)).gameObject); } hint.LabelText = AddText(val4, val10.transform, text); ((TMP_Text)hint.LabelText).alignment = (TextAlignmentOptions)516; hint.ShownLabel = null; hint.Row = val10; Transform val11 = CreateKeyGroup(val10.transform, val8); for (int i = 0; i < hint.Keys.Length; i++) { if (i > 0 && hint.Separator != null) { AddText(val5, val11, hint.Separator); } if (hint.Keys[i] == "@scroll") { AddScrollIcon(val7, val11); continue; } GameObject obj = Object.Instantiate<GameObject>(((Component)val6).gameObject, val11, false); obj.SetActive(true); ((TMP_Text)obj.GetComponentInChildren<TextMeshProUGUI>()).text = KeyText(hint.Keys[i]); } } LayoutRebuilder.ForceRebuildLayoutImmediate(val9); EqualiseWidths(); foreach (Hint hint2 in Hints) { ((TMP_Text)hint2.LabelText).text = ""; } _container = ((Component)component).gameObject; _stack = val9; _keyboard = (RectTransform)val; _layoutDirty = true; return true; } private static string KeyText(string key) { //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: 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_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0110: 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_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_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) return key switch { "@toggle" => ((object)PhotoMode.ToggleKey/*cast due to .constrained prefix*/).ToString(), "@rollleft" => ((object)PhotoMode.RollLeftKey/*cast due to .constrained prefix*/).ToString(), "@rollright" => ((object)PhotoMode.RollRightKey/*cast due to .constrained prefix*/).ToString(), "@reset" => ((object)PhotoMode.ResetKey/*cast due to .constrained prefix*/).ToString(), "@hideui" => ((object)PhotoMode.HideUiKey/*cast due to .constrained prefix*/).ToString(), "@hidecharacter" => ((object)PhotoMode.HideCharacterKey/*cast due to .constrained prefix*/).ToString(), "@return" => ((object)PhotoMode.ReturnKey/*cast due to .constrained prefix*/).ToString(), _ => Localization.instance.Localize(key), }; } private static string LongestLabel() { string text = ""; string[] allLabels = AllLabels; foreach (string text2 in allLabels) { string text3 = Localization.instance.Localize(text2); if (text3.Length > text.Length) { text = text3; } } return text; } private static RectTransform CreateStack(RectTransform parent) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) RectTransform component = new GameObject("BetterCamera_PhotoHints_Stack", new Type[1] { typeof(RectTransform) }).GetComponent<RectTransform>(); ((Transform)component).SetParent((Transform)(object)parent, false); component.pivot = new Vector2(1f, 0f); VerticalLayoutGroup obj = ((Component)component).gameObject.AddComponent<VerticalLayoutGroup>(); ((HorizontalOrVerticalLayoutGroup)obj).spacing = 12f; ((LayoutGroup)obj).childAlignment = (TextAnchor)8; ((HorizontalOrVerticalLayoutGroup)obj).childControlWidth = true; ((HorizontalOrVerticalLayoutGroup)obj).childControlHeight = true; ((HorizontalOrVerticalLayoutGroup)obj).childForceExpandWidth = false; ((HorizontalOrVerticalLayoutGroup)obj).childForceExpandHeight = false; ContentSizeFitter obj2 = ((Component)component).gameObject.AddComponent<ContentSizeFitter>(); obj2.horizontalFit = (FitMode)2; obj2.verticalFit = (FitMode)2; return component; } private static Transform CreateKeyGroup(Transform row, HorizontalLayoutGroup template) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: 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_0068: 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_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("Keys", new Type[1] { typeof(RectTransform) }); val.transform.SetParent(row, false); HorizontalLayoutGroup obj = val.AddComponent<HorizontalLayoutGroup>(); ((HorizontalOrVerticalLayoutGroup)obj).spacing = ((HorizontalOrVerticalLayoutGroup)template).spacing; ((LayoutGroup)obj).childAlignment = (TextAnchor)3; ((HorizontalOrVerticalLayoutGroup)obj).childControlWidth = ((HorizontalOrVerticalLayoutGroup)template).childControlWidth; ((HorizontalOrVerticalLayoutGroup)obj).childControlHeight = ((HorizontalOrVerticalLayoutGroup)template).childControlHeight; ((HorizontalOrVerticalLayoutGroup)obj).childForceExpandWidth = false; ((HorizontalOrVerticalLayoutGroup)obj).childForceExpandHeight = false; ((RectTransform)val.transform).sizeDelta = new Vector2(0f, 32f); LayoutElement obj2 = val.AddComponent<LayoutElement>(); float minHeight = (obj2.preferredHeight = 32f); obj2.minHeight = minHeight; return val.transform; } private static void AddScrollIcon(Transform template, Transform parent) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: 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_00ce: Unknown result type (might be due to invalid IL or missing references) GameObject val = Object.Instantiate<GameObject>(((Component)template).gameObject, parent, false); val.SetActive(true); Image component = val.GetComponent<Image>(); component.preserveAspect = true; float num; if (!((Object)(object)component.sprite != (Object)null)) { num = 0.6f; } else { Rect rect = component.sprite.rect; float width = ((Rect)(ref rect)).width; rect = component.sprite.rect; num = width / ((Rect)(ref rect)).height; } float num2 = num; LayoutElement obj = val.GetComponent<LayoutElement>() ?? val.AddComponent<LayoutElement>(); float minWidth = (obj.preferredWidth = 32f * num2 * 1.8f); obj.minWidth = minWidth; minWidth = (obj.preferredHeight = 32f); obj.minHeight = minWidth; minWidth = (obj.flexibleHeight = 0f); obj.flexibleWidth = minWidth; val.transform.localScale = new Vector3(1.8f, 1.8f, 1f); } private static void EqualiseWidths() { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown for (int i = 0; i < 2; i++) { float num = 0f; foreach (Hint hint in Hints) { num = Mathf.Max(num, LayoutUtility.GetPreferredWidth((RectTransform)hint.Row.transform.GetChild(i))); } foreach (Hint hint2 in Hints) { GameObject gameObject = ((Component)hint2.Row.transform.GetChild(i)).gameObject; LayoutElement obj = gameObject.GetComponent<LayoutElement>() ?? gameObject.AddComponent<LayoutElement>(); obj.minWidth = num; obj.preferredWidth = num; } } } private static TextMeshProUGUI AddText(Transform template, Transform parent, string text) { GameObject obj = Object.Instantiate<GameObject>(((Component)template).gameObject, parent, false); obj.SetActive(true); LayoutElement component = obj.GetComponent<LayoutElement>(); if ((Object)(object)component != (Object)null) { Object.DestroyImmediate((Object)(object)component); } TextMeshProUGUI component2 = obj.GetComponent<TextMeshProUGUI>(); ((TMP_Text)component2).enableAutoSizing = false; ((TMP_Text)component2).fontSize = 16f; ((TMP_Text)component2).textWrappingMode = (TextWrappingModes)0; ((TMP_Text)component2).text = text; return component2; } private static void Reset() { _container = null; _stack = null; _keyboard = null; _createFailed = false; foreach (Hint hint in Hints) { hint.LabelText = null; hint.ShownLabel = null; hint.Row = null; } } } internal static class PhotoMode { private const string ButtonName = "BetterCamera_PhotoMode"; private const float FovStep = 1.1f; private const float SpeedStep = 1.2f; private const float MinSpeed = 0.25f; private const float MaxSpeed = 100f; private const float RollSpeed = 45f; private const float MaxPitch = 89f; private static ConfigEntry<KeyCode> _toggleKey; private static ConfigEntry<float> _maxDistance; private static ConfigEntry<float> _startSpeed; private static ConfigEntry<float> _fastMultiplier; private static ConfigEntry<float> _smoothing; private static ConfigEntry<bool> _exitOnDamage; private static ConfigEntry<KeyCode> _rollLeftKey; private static ConfigEntry<KeyCode> _rollRightKey; private static ConfigEntry<KeyCode> _resetKey; private static ConfigEntry<KeyCode> _hideUiKey; private static ConfigEntry<KeyCode> _hideCharacterKey; private static ConfigEntry<KeyCode> _returnKey; private static bool _active; private static float _yaw; private static float _pitch; private static float _roll; private static float _fov; private static float _speed; private static Vector3 _velocity; private static Vector3 _acceleration; private static Quaternion _rotationVelocity = Quaternion.identity; private static bool _damaged; private static bool _hudWasHidden; private static Transform _lookAt; private static Vector3 _lookAtPoint; private static Transform _follow; private static Vector3 _followOffset; [CompilerGenerated] private static int <RayMask>k__BackingField; private const float ReturnDistance = 3f; private const float ReturnHeight = 0.5f; private static string ButtonQueryName => "BetterCamera_PhotoMode!javidahmed64592.bettercamera"; public static bool Active { get { if (_active && ((Object)(object)GameCamera.instance == (Object)null || !GameCamera.instance.m_freeFly)) { _active = false; } return _active; } } public static KeyCode ToggleKey => _toggleKey.Value; public static KeyCode RollLeftKey => _rollLeftKey.Value; public static KeyCode RollRightKey => _rollRightKey.Value; public static KeyCode ResetKey => _resetKey.Value; public static KeyCode HideUiKey => _hideUiKey.Value; public static KeyCode HideCharacterKey => _hideCharacterKey.Value; public static KeyCode ReturnKey => _returnKey.Value; public static bool LookingAt => (Object)(object)_lookAt != (Object)null; public static bool Following => (Object)(object)_follow != (Object)null; private static int RayMask { get { if (<RayMask>k__BackingField == 0) { <RayMask>k__BackingField = LayerMask.GetMask(new string[8] { "Default", "static_solid", "terrain", "vehicle", "character", "piece", "character_net", "viewblock" }); } return <RayMask>k__BackingField; } } public static void BindConfig(ConfigFile config) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Expected O, but got Unknown //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Expected O, but got Unknown //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Expected O, but got Unknown //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Expected O, but got Unknown //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Expected O, but got Unknown _toggleKey = config.Bind<KeyCode>("Keybinds", "Photo Mode", (KeyCode)106, "Turns photo mode on and off: a free camera for taking pictures while your character stands still. Rebindable from the in-game controls menu."); InputManager.Instance.AddButton("javidahmed64592.bettercamera", new ButtonConfig { Name = "BetterCamera_PhotoMode", Config = _toggleKey }); _rollLeftKey = config.Bind<KeyCode>("Keybinds", "Photo Mode Roll Left", (KeyCode)113, "In photo mode, tilts the camera to the left."); _rollRightKey = config.Bind<KeyCode>("Keybinds", "Photo Mode Roll Right", (KeyCode)101, "In photo mode, tilts the camera to the right."); _resetKey = config.Bind<KeyCode>("Keybinds", "Photo Mode Reset", (KeyCode)114, "In photo mode, levels the camera and resets the zoom."); _hideUiKey = config.Bind<KeyCode>("Keybinds", "Photo Mode Hide UI", (KeyCode)117, "In photo mode, hides or shows what's left of the UI (key hints, status effects, crosshair and messages). The hotbar, map and health are always hidden in photo mode."); _hideCharacterKey = config.Bind<KeyCode>("Keybinds", "Photo Mode Hide Character", (KeyCode)104, "In photo mode, hides or shows your character, for shots of the scenery."); _returnKey = config.Bind<KeyCode>("Keybinds", "Photo Mode Return", (KeyCode)99, "In photo mode, brings the camera back to just behind your character, looking at them."); _maxDistance = config.Bind<float>("Photo Mode", "Max Distance", 100f, new ConfigDescription("How far the photo mode camera can fly from your character, in metres.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(5f, 1000f), Array.Empty<object>())); _startSpeed = config.Bind<float>("Photo Mode", "Speed", 5f, new ConfigDescription("How fast the camera flies when photo mode starts, in metres per second. Alt + scroll changes it while flying.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.25f, 100f), Array.Empty<object>())); _fastMultiplier = config.Bind<float>("Photo Mode", "Fast Multiplier", 4f, new ConfigDescription("How much faster the camera flies while holding the run key.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 20f), Array.Empty<object>())); _smoothing = config.Bind<float>("Photo Mode", "Smoothing", 0f, new ConfigDescription("Seconds the camera takes to catch up with your movement and turning, for smooth shots. 0 follows your input exactly.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 2f), Array.Empty<object>())); _exitOnDamage = config.Bind<bool>("Photo Mode", "Exit On Damage", true, "Leaves photo mode when your character takes damage, so you can defend yourself."); } public static void UpdateInput(Player player) { //IL_0045: 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_009a: 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) if (Active && (((Character)player).IsDead() || (_exitOnDamage.Value && _damaged))) { Exit(player, "$bettercamera_photo_damage"); } else { if (CameraController.Blocked()) { return; } if (Active) { if (ZInput.GetKeyDown(_toggleKey.Value, true)) { Exit(player, "$bettercamera_photo_off"); } else if (ZInput.GetKeyDown(_hideUiKey.Value, true) && (Object)(object)Hud.instance != (Object)null) { Hud.instance.m_userHidden = !Hud.instance.m_userHidden; } else if (ZInput.GetKeyDown(_hideCharacterKey.Value, true)) { PhotoCharacter.Toggle(); } else if (ZInput.GetKeyDown(_returnKey.Value, true)) { ReturnToCharacter(player); } } else if (ZInput.GetButtonDown(ButtonQueryName)) { Enter(player); } } } private static void Enter(Player player) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002c: 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_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: 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_0097: Unknown result type (might be due to invalid IL or missing references) GameCamera instance = GameCamera.instance; if (!((Object)(object)instance == (Object)null) && !instance.m_freeFly && !((Character)player).IsDead()) { Vector3 eulerAngles = ((Component)instance).transform.eulerAngles; _yaw = eulerAngles.y; _pitch = Mathf.Clamp(Mathf.DeltaAngle(0f, eulerAngles.x), -89f, 89f); _roll = 0f; _fov = CameraController.GameplayFov; _speed = _startSpeed.Value; _velocity = Vector3.zero; _acceleration = Vector3.zero; _rotationVelocity = Quaternion.identity; _lookAt = null; _follow = null; _damaged = false; _hudWasHidden = (Object)(object)Hud.instance != (Object)null && Hud.instance.m_userHidden; instance.m_freeFly = true; _active = true; ((Character)player).Message((MessageType)1, Localization.instance.Localize("$bettercamera_photo_on"), 0, (Sprite)null, false); } } public static void OnDamaged() { _damaged |= Active; } public static void Exit(Player player, string messageToken) { if (_active) { _active = false; _lookAt = null; _follow = null; GameCamera instance = GameCamera.instance; if ((Object)(object)instance != (Object)null) { instance.m_freeFly = false; } PhotoHud.Restore(); PhotoCharacter.Reset(); if ((Object)(object)Hud.instance != (Object)null) { Hud.instance.m_userHidden = _hudWasHidden; } if ((Object)(object)player != (Object)null && messageToken != null) { ((Character)player).Message((MessageType)1, Localization.instance.Localize(messageToken), 0, (Sprite)null, false); } } } public static void UpdateInventory(InventoryGui gui) { Player localPlayer = Player.m_localPlayer; if (!Active || (Object)(object)localPlayer == (Object)null || ((Character)localPlayer).IsDead() || ((Object)(object)Chat.instance != (Object)null && Chat.instance.HasFocus()) || Console.IsVisible() || Menu.IsVisible() || Minimap.IsOpen() || TextInput.IsVisible()) { return; } if (InventoryGui.IsVisible()) { bool flag = ZInput.GetButtonDown("Inventory") || ZInput.GetKeyDown((KeyCode)27, true) || ZInput.GetButtonDown("Use"); if (gui.m_shownFrames > 1 && flag) { ZInput.ResetButtonStatus("Inventory"); ZInput.ResetButtonStatus("Use"); gui.Hide(); } } else if (gui.m_hiddenFrames > 1 && ZInput.GetButtonDown("Inventory")) { ZInput.ResetButtonStatus("Inventory"); gui.Show((Container)null, 1); } } public static void UpdateCamera(GameCamera camera, float dt) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: 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_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: 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_00a1: 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) //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_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: 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_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: 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_00f2: 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_013b: 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_0146: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012f: 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_014f: 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_017a: 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_0163: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_016f: 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_0195: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_019f: 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_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) Transform transform = ((Component)camera).transform; Vector3 val = Vector3.zero; float num = 1f; if (!CameraController.Blocked()) { val = ReadInput(camera, dt, out var running); num = (running ? _fastMultiplier.Value : 1f); } PhotoHud.Hide(); PhotoCharacter.Apply(Player.m_localPlayer); Quaternion val2 = Quaternion.Euler(0f, _yaw, 0f) * Quaternion.Euler(_pitch, 0f, 0f); Vector3 val3 = transform.rotation * Quaternion.Euler(0f, 0f, 0f - _roll) * Vector3.ClampMagnitude(val, 1f) * (_speed * num); _velocity = ((_smoothing.Value <= 0f) ? val3 : Vector3.SmoothDamp(_velocity, val3, ref _acceleration, _smoothing.Value, float.PositiveInfinity, dt)); Vector3 position = transform.position; if ((Object)(object)_follow != (Object)null) { _followOffset += _velocity * dt; position = _follow.position + _followOffset; } else { _follow = null; position += _velocity * dt; } position = KeepNearPlayer(position); if ((Object)(object)_follow != (Object)null) { _followOffset = position - _follow.position; } transform.position = position; Quaternion val4 = val2; if ((Object)(object)_lookAt != (Object)null) { Vector3 val5 = _lookAt.TransformPoint(_lookAtPoint) - position; if (((Vector3)(ref val5)).sqrMagnitude > 0.0001f) { val4 = Quaternion.LookRotation(val5, Vector3.up); } } else { _lookAt = null; } val4 *= Quaternion.Euler(0f, 0f, _roll); transform.rotation = ((_smoothing.Value <= 0f) ? val4 : Utils.SmoothDamp(transform.rotation, val4, ref _rotationVelocity, _smoothing.Value, 9999f, dt)); camera.m_camera.fieldOfView = _fov; camera.m_skyCamera.fieldOfView = _fov; } private static Vector3 ReadInput(GameCamera camera, float dt, out bool running) { //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_0039: Unknown result type (might be due to invalid IL or missing references) //IL_004a: 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_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01af: 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) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: 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_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01df: 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) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_0227: 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) Vector2 val = ZInput.GetMouseDelta() * PlayerController.m_mouseSens; if (PlayerController.m_invertMouse) { val.y *= -1f; } if ((Object)(object)_lookAt == (Object)null) { _yaw += val.x; _pitch = Mathf.Clamp(_pitch - val.y, -89f, 89f); } float mouseScrollWheel = ZInput.GetMouseScrollWheel(); if (mouseScrollWheel != 0f) { bool num = ZInput.GetKey((KeyCode)308, true) || ZInput.GetKey((KeyCode)307, true); float num2 = ((mouseScrollWheel > 0f) ? 1f : (-1f)); if (num) { _speed = Mathf.Clamp(_speed * Mathf.Pow(1.2f, num2), 0.25f, 100f); ShowSpeed(); } else { _fov = Mathf.Clamp(_fov / Mathf.Pow(1.1f, num2), camera.m_freeFlyMinFov, camera.m_freeFlyMaxFov); } } if (ZInput.GetKey(_rollLeftKey.Value, true)) { _roll += 45f * dt; } if (ZInput.GetKey(_rollRightKey.Value, true)) { _roll -= 45f * dt; } if (ZInput.GetKeyDown(_resetKey.Value, true)) { _roll = 0f; _fov = CameraController.GameplayFov; } if (ZInput.GetButtonDown("Attack")) { ToggleLookAt(((Component)camera).transform); } if (ZInput.GetButtonDown("SecondaryAttack")) { ToggleFollow(((Component)camera).transform); } Vector3 val2 = Vector3.zero; if (ZInput.GetButton("Forward")) { val2 += Vector3.forward; } if (ZInput.GetButton("Backward")) { val2 += Vector3.back; } if (ZInput.GetButton("Left")) { val2 += Vector3.left; } if (ZInput.GetButton("Right")) { val2 += Vector3.right; } if (ZInput.GetButton("Jump")) { val2 += Vector3.up; } if (ZInput.GetButton("Crouch")) { val2 += Vector3.down; } running = ZInput.GetButton("Run"); return val2; } private static void ShowSpeed() { if (!((Object)(object)MessageHud.instance == (Object)null)) { string text = Localization.instance.Localize("$bettercamera_photo_speed", new string[1] { _speed.ToString("0.0", CultureInfo.CurrentCulture) }); MessageHud.instance.ShowMessage((MessageType)2, text, 0, (Sprite)null, true, false); } } private static void ToggleLookAt(Transform camera) { //IL_0067: 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) //IL_0014: 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) //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_0022: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) RaycastHit val2 = default(RaycastHit); if ((Object)(object)_lookAt != (Object)null) { _lookAt = null; Vector3 forward = camera.forward; Quaternion val = Quaternion.LookRotation(forward); _yaw = ((Quaternion)(ref val)).eulerAngles.y; _pitch = Mathf.Clamp((0f - Mathf.Asin(Mathf.Clamp(forward.y, -1f, 1f))) * 57.29578f, -89f, 89f); } else if (Physics.Raycast(camera.position, camera.forward, ref val2, 10000f, RayMask)) { _lookAt = ((Component)((RaycastHit)(ref val2)).collider).transform; _lookAtPoint = _lookAt.InverseTransformPoint(((RaycastHit)(ref val2)).point); } } private static void ToggleFollow(Transform camera) { //IL_0015: 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_006c: 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_0080: Unknown result type (might be due to invalid IL or missing references) RaycastHit val = default(RaycastHit); if ((Object)(object)_follow != (Object)null) { _follow = null; } else if (Physics.Raycast(camera.position, camera.forward, ref val, 10000f, RayMask)) { _follow = (((Object)(object)((RaycastHit)(ref val)).collider.attachedRigidbody != (Object)null) ? ((Component)((RaycastHit)(ref val)).collider.attachedRigidbody).transform : ((Component)((RaycastHit)(ref val)).collider).transform); _followOffset = camera.position - _follow.position; } } private static void ReturnToCharacter(Player player) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002f: 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) //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_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0048: 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) //IL_004f: 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_0063: 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_006d: 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_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: 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_009b: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) GameCamera instance = GameCamera.instance; if (!((Object)(object)instance == (Object)null) && !((Object)(object)((Character)player).m_eye == (Object)null)) { Vector3 position = ((Character)player).m_eye.position; Vector3 val = Vector3.ProjectOnPlane(((Component)player).transform.forward, Vector3.up); Vector3 normalized = ((Vector3)(ref val)).normalized; Vector3 val2 = position - normalized * 3f + Vector3.up * 0.5f; Vector3 val3 = position - val2; _lookAt = null; _follow = null; _velocity = Vector3.zero; _acceleration = Vector3.zero; Quaternion val4 = Quaternion.LookRotation(val3); _yaw = ((Quaternion)(ref val4)).eulerAngles.y; float y = val3.y; Vector2 val5 = new Vector2(val3.x, val3.z); _pitch = Mathf.Clamp((0f - Mathf.Atan2(y, ((Vector2)(ref val5)).magnitude)) * 57.29578f, -89f, 89f); ((Component)instance).transform.SetPositionAndRotation(val2, Quaternion.Euler(_pitch, _yaw, _roll)); } } private static Vector3 KeepNearPlayer(Vector3 position) { //IL_000f: 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_0025: 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_0038: 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_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: 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_005c: 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) //IL_0057: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return position; } Vector3 val = (((Object)(object)((Character)localPlayer).m_eye != (Object)null) ? ((Character)localPlayer).m_eye.position : ((Component)localPlayer).transform.position); Vector3 val2 = position - val; float value = _maxDistance.Value; if (!(((Vector3)(ref val2)).sqrMagnitude > value * value)) { return position; } return val + ((Vector3)(ref val2)).normalized * value; } } } namespace BetterCamera.Patches { [HarmonyPatch(typeof(Attack), "GetMeleeAttackDir")] internal static class Attack_GetMeleeAttackDir_Patch { [HarmonyPostfix] private static void Postfix(Attack __instance, Transform originJoint, ref Vector3 attackDir) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)__instance.m_character != (Object)null && (Object)(object)__instance.m_character == (Object)(object)Player.m_localPlayer) { attackDir = MeleeAim.Direction(__instance, originJoint, attackDir); } } } [HarmonyPatch(typeof(CharacterAnimEvent), "CustomLateUpdate")] internal static class CharacterAnimEvent_CustomLateUpdate_Patch { [HarmonyPostfix] private static void Postfix(CharacterAnimEvent __instance, float deltaTime) { Character character = __instance.m_character; Player val = (Player)(object)((character is Player) ? character : null); if (val != null && (Object)(object)val == (Object)(object)Player.m_localPlayer) { MeleeLean.Apply(val, deltaTime); } } } [HarmonyPatch(typeof(Character), "ApplyDamage")] internal static class Character_ApplyDamage_Patch { [HarmonyPostfix] private static void Postfix(Character __instance, HitData hit) { if ((Object)(object)__instance == (Object)(object)Player.m_localPlayer && hit.GetTotalDamage() > 0.1f) { PhotoMode.OnDamaged(); } } } [HarmonyPatch(typeof(GameCamera), "CollideRay2")] internal static class GameCamera_CollideRay2_Patch { [HarmonyPrefix] private static void Prefix(ref Vector3 eyePos, Vector3 offsetedEyePos) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) if (CameraController.UsesVehicleView) { eyePos = offsetedEyePos; } } } [HarmonyPatch(typeof(GameCamera), "GetOffsetedEyePos")] internal static class GameCamera_GetOffsetedEyePos_Patch { [HarmonyPostfix] private static void Postfix(ref Vector3 __result) { //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_001c: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer != (Object)null) { __result = CameraController.Pivot(localPlayer, __result); } } } [HarmonyPatch(typeof(GameCamera), "ScreenShot")] internal static class GameCamera_ScreenShot_Patch { [HarmonyPrefix] private static bool Prefix() { if (PhotoMode.Active) { return ZInput.GetKeyDown((KeyCode)292, true); } return true; } } [HarmonyPatch(typeof(GameCamera), "UpdateCamera")] internal static class GameCamera_UpdateCamera_Patch { [HarmonyPrefix] private static void Prefix(GameCamera __instance) { CameraController.BeforeUpdate(__instance); } [HarmonyPostfix] private static void Postfix(GameCamera __instance, float dt) { CameraController.AfterUpdate(__instance, dt); } } [HarmonyPatch(typeof(GameCamera), "UpdateFreeFly")] internal static class GameCamera_UpdateFreeFly_Patch { [HarmonyPrefix] private static bool Prefix(GameCamera __instance, float dt) { if (!PhotoMode.Active) { return true; } PhotoMode.UpdateCamera(__instance, dt); return false; } } [HarmonyPatch(typeof(GameCamera), "UpdateNearClipping")] internal static class GameCamera_UpdateNearClipping_Patch { [HarmonyPrefix] private static bool Prefix(GameCamera __instance) { if (!FirstPersonSettings.Active || (Object)(object)__instance.m_camera == (Object)null) { return true; } if (__instance.m_camera.nearClipPlane != 0.05f) { __instance.m_camera.nearClipPlane = 0.05f; } return false; } } [HarmonyPatch(typeof(Hud), "UpdateCrosshair")] internal static class Hud_UpdateCrosshair_Patch { [HarmonyPostfix] private static void Postfix(Hud __instance) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) if (PhotoMode.Active) { ((TMP_Text)__instance.m_hoverName).text = ""; ((Graphic)__instance.m_crosshair).color = Hud.s_whiteHalfAlpha; ((Component)__instance.m_pieceHealthRoot).gameObject.SetActive(false); } } } [HarmonyPatch(typeof(Hud), "UpdateShipHud")] internal static class Hud_UpdateShipHud_Patch { [HarmonyPostfix] private static void Postfix(Hud __instance) { ShipHud.AfterUpdate(__instance); } } [HarmonyPatch(typeof(Humanoid), "GetAimDir")] internal static class Humanoid_GetAimDir_Patch { [HarmonyPostfix] private static void Postfix(Humanoid __instance, Vector3 fromPoint, ref Vector3 __result) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0022: 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) Player val = (Player)(object)((__instance is Player) ? __instance : null); if (val != null && (Object)(object)val == (Object)(object)Player.m_localPlayer && FirstPersonSettings.Active) { __result = CrosshairAim.DirectionFrom(val, fromPoint, __result); } } } [HarmonyPatch(typeof(InventoryGui), "Update")] internal static class InventoryGui_Update_Patch { [HarmonyPostfix] private static void Postfix(InventoryGui __instance) { PhotoMode.UpdateInventory(__instance); } } [HarmonyPatch(typeof(KeyHints), "UpdateHints")] internal static class KeyHints_UpdateHints_Patch { [HarmonyPostfix] private static void Postfix(KeyHints __instance) { PhotoKeyHints.AfterUpdateHints(__instance); } } [HarmonyPatch(typeof(Player), "AlwaysRotateCamera")] internal static class Player_AlwaysRotateCamera_Patch { [HarmonyPostfix] private static void Postfix(Player __instance, ref bool __result) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0049: 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) if (!__result && !((Object)(object)__instance != (Object)(object)Player.m_localPlayer) && FirstPersonSettings.Active && !((Character)__instance).IsAttached()) { if (((Vector3)(ref ((Character)__instance).m_moveDir)).magnitude > 0.1f) { __result = true; return; } Vector3 val = ((Character)__instance).GetLookYaw() * Vector3.forward; __result = Vector3.Angle(val, ((Component)__instance).transform.forward) > FirstPersonSettings.TurnAngle; } } } [HarmonyPatch(typeof(Player), "FixedUpdate")] internal static class Player_FixedUpdate_Patch { [HarmonyPostfix] private static void Postfix(Player __instance) { if ((Object)(object)__instance == (Object)(object)Player.m_localPlayer && FirstPersonSettings.Active) { ((Character)__instance).SetVisible(true); } } } [HarmonyPatch(typeof(Player), "SetMouseLook")] internal static class Player_SetMouseLook_Patch { private const float SidewaysStart = 30f; private const float SidewaysEnd = 100f; [HarmonyPostfix] private static void Postfix(Player __instance) { //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_0042: 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_008d: 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_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer || !FirstPersonSettings.Active) { return; } bool num = ((Character)__instance).IsAttached() || ((Character)__instance).IsRiding(); bool flag = false; float num2 = FirstPersonSettings.MaxLookDown; if (num) { Quaternion rotation = ((Component)__instance).transform.rotation; float y = ((Quaternion)(ref rotation)).eulerAngles.y; float num3 = Mathf.DeltaAngle(y, ((Quaternion)(ref ((Character)__instance).m_lookYaw)).eulerAngles.y); float seatedTurnAngle = FirstPersonSettings.SeatedTurnAngle; if (Mathf.Abs(num3) > seatedTurnAngle) { num3 = Mathf.Sign(num3) * seatedTurnAngle; ((Character)__instance).m_lookYaw = Quaternion.Euler(0f, y + num3, 0f); flag = true; } float num4 = Mathf.SmoothStep(0f, 1f, Mathf.InverseLerp(30f, 100f, Mathf.Abs(num3))); num2 = Mathf.Min(num2, Mathf.Lerp(FirstPersonSettings.SeatedMaxLookDown, FirstPersonSettings.SeatedMaxLookDownSideways, num4)); } if (__instance.m_lookPitch > num2) { __instance.m_lookPitch = num2; flag = true; } if (flag) { ((Character)__instance).UpdateEyeRotation(); ((Character)__instance).m_lookDir = ((Character)__instance).m_eye.forward; } } } [HarmonyPatch(typeof(VisEquipment), "UpdateLodgroup")] internal static class VisEquipment_UpdateLodgroup_Patch { [HarmonyPostfix] private static void Postfix(VisEquipment __instance) { FirstPersonBody.GearChanged(__instance); } } [HarmonyPatch(typeof(ZInput), "GetMouseScrollWheel")] internal static class ZInput_GetMouseScrollWheel_Patch { [HarmonyPostfix] private static void Postfix(ref float __result) { if (__result != 0f && CameraController.FovScrollActive(Player.m_localPlayer)) { __result = 0f; } } } [HarmonyPatch(typeof(ZInput), "Update")] internal static class ZInput_Update_Patch { private const string ToggleWalk = "ToggleWalk"; private static readonly FieldRef<ZInput, Dictionary<string, ButtonDef>> Buttons = AccessTools.FieldRefAccess<ZInput, Dictionary<string, ButtonDef>>("m_buttons"); [HarmonyPostfix] private static void Postfix() { ZInput instance = ZInput.instance; if (instance != null && CameraController.CycleKeyDown(Player.m_localPlayer) && Buttons.Invoke(instance).TryGetValue("ToggleWalk", out var value) && value.Pressed) { value.ResetState(); } } } } namespace BetterCamera.FirstPerson { internal static class CrosshairAim { private const float MaxDistance = 300f; private static readonly RaycastHit[] Hits = (RaycastHit[])(object)new RaycastHit[32]; [CompilerGenerated] private static int <Mask>k__BackingField; private static int Mask { get { if (<Mask>k__BackingField == 0) { <Mask>k__BackingField = LayerMask.GetMask(new string[11] { "Default", "static_solid", "Default_small", "piece", "terrain", "vehicle", "character", "character_net", "character_ghost", "character_noenv", "hitbox" }); } return <Mask>k__BackingField; } } public static Vector3 DirectionFrom(Player player, Vector3 from, Vector3 fallback) { //IL_0011: 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_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: 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_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) if (!TryGetTarget(player, 300f, out var target)) { return fallback; } Vector3 val = target - from; if (!(((Vector3)(ref val)).sqrMagnitude > 0.01f)) { return fallback; } return ((Vector3)(ref val)).normalized; } public static bool TryGetTarget(Player player, float maxDistance, out Vector3 target) { //IL_0022: 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_002e: 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_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0036: 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_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //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) //IL_006a: 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_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) Camera mainCamera = Utils.GetMainCamera(); if ((Object)(object)mainCamera == (Object)null) { target = Vector3.zero; return false; } Vector3 position = ((Component)mainCamera).transform.position; Vector3 forward = ((Component)mainCamera).transform.forward; target = position + forward * maxDistance; int num = Physics.RaycastNonAlloc(position, forward, Hits, maxDistance, Mask, (QueryTriggerInteraction)1); float num2 = maxDistance; for (int i = 0; i < num; i++) { RaycastHit val = Hits[i]; if (((RaycastHit)(ref val)).distance < num2 && !IsOwn(player, ((RaycastHit)(ref val)).collider)) { num2 = ((RaycastHit)(ref val)).distance; target = ((RaycastHit)(ref val)).point; } } return true; } private static bool IsOwn(Player player, Collider collider) { Transform transform = ((Component)collider).transform; if (!transform.IsChildOf(((Component)player).transform)) { Ship standingOnShip = ((Character)player).GetStandingOnShip(); if (standingOnShip == null || !transform.IsChildOf(((Component)standingOnShip).transform)) { IDoodadController doodadController = player.m_doodadController; Sadle val = (Sadle)(object)((doodadController is Sadle) ? doodadController : null); if (val != null && (Object)(object)val.GetCharacter() != (Object)null) { return transform.IsChildOf(((Component)val.GetCharacter()).transform); } return false; } } return true; } } internal static class FirstPersonBody { private sealed class Copy { public SkinnedMeshRenderer Source; public Mesh SourceMesh; public SkinnedMeshRenderer Renderer; } private const float HeadWeightCutoff = 0.5f; private static readonly Dictionary<Renderer, ShadowCastingMode> ShadowOnly = new Dictionary<Renderer, ShadowCastingMode>(); private static readonly List<Copy> Copies = new List<Copy>(); private static readonly Dictionary<Mesh, Mesh> Trimmed = new Dictionary<Mesh, Mesh>(); private static readonly HashSet<Mesh> AllHead = new HashSet<Mesh>(); private static readonly List<Renderer> Renderers = new List<Renderer>(); private static readonly List<Material> SourceMaterials = new List<Material>(); private static readonly List<Material> CopyMaterials = new List<Material>(); private static MaterialPropertyBlock _block; private static Player _player; private static Animator _animator; private static AnimatorCullingMode _animatorCulling; private static bool _applied; private static bool _dirty; private static readonly Dictionary<Light, Quaternion> AimedLights = new Dictionary<Light, Quaternion>(); private static readonly List<Light> Lights = new List<Light>(); public static void Update(Player player, bool firstPerson) { NearFoliage.Update(firstPerson); if (!firstPerson || (Object)(object)player == (Object)null || (Object)(object)((Character)player).m_visual == (Object)null) { RestoreHead(); RestoreLights(); return; } AimHeadLights(player); if (!_applied || _dirty || (Object)(object)_player != (Object)(object)player || !CopiesCurrent()) { RestoreHead(); HideHead(player); } SyncCopies(player); } public static void GearChanged(VisEquipment equipment) { Player localPlayer = Player.m_localPlayer; if (_applied && (Object)(object)localPlayer != (Object)null && (Object)(object)equipment == (Object)(object)((Humanoid)localPlayer).m_visEquipment) { _dirty = true; } } public static void Restore() { RestoreHead(); RestoreLights(); NearFoliage.Restore(); } private static void HideHead(Player player) { _player = player; _applied = true; _dirty = false; Transform head = ((Character)player).m_head; if ((Object)(object)head == (Object)null) { return; } KeepAnimating(player); VisEquipment visEquipment = ((Humanoid)player).m_visEquipment; ((Character)player).m_visual.GetComponentsInChildren<Renderer>(true, Renderers); foreach (Renderer renderer in Renderers) { if (((Component)renderer).transform.IsChildOf(head) || WornOnHead(visEquipment, ((Component)renderer).transform)) { MakeShadowOnly(renderer); continue; } SkinnedMeshRenderer val = (SkinnedMeshRenderer)(object)((renderer is SkinnedMeshRenderer) ? renderer : null); if (val != null && SkinnedToHead(val, head)) { bool allHead; Mesh val2 = TrimmedMesh(val, head, out allHead); if (allHead) { MakeShadowOnly((Renderer)(object)val); } else if ((Object)(object)val2 != (Object)null) { MakeShadowOnly((Renderer)(object)val); Copies.Add(MakeCopy(player, val, val2)); } } } Renderers.Clear(); } private static void KeepAnimating(Player player) { //IL_0022: 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) _animator = ((Character)player).m_visual.GetComponent<Animator>(); if ((Object)(object)_animator != (Object)null) { _animatorCulling = _animator.cullingMode; _animator.cullingMode = (AnimatorCullingMode)0; } } private static bool WornOnHead(VisEquipment equipment, Transform renderer) { if ((Object)(object)equipment != (Object)null) { if (!IsPartOf(renderer, equipment.m_helmetItemInstance) && !IsPartOf(renderer, equipment.m_hairItemInstance)) { return IsPartOf(renderer, equipment.m_beardItemInstance); } return true; } return false; } private static bool IsPartOf(Transform renderer, GameObject item) { if ((Object)(object)item != (Object)null) { return renderer.IsChildOf(item.transform); } return false; } private static void MakeShadowOnly(Renderer renderer) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) if (!ShadowOnly.ContainsKey(renderer)) { ShadowOnly[renderer] = renderer.shadowCastingMode; } renderer.shadowCastingMode = (ShadowCastingMode)3; } private static bool SkinnedToHead(SkinnedMeshRenderer renderer, Transform head) { Transform[] bones = renderer.bones; foreach (Transform val in bones) { if ((Object)(object)val != (Object)null && val.IsChildOf(head)) { return true; } } return false; } private static Mesh TrimmedMesh(SkinnedMeshRenderer renderer, Transform head, out bool allHead) { Mesh sharedMesh = renderer.sharedMesh; allHead = false; if ((Object)(object)sharedMesh == (Object)null) { return null; } if (!Trimmed.TryGetValue(sharedMesh, out var value)) { value = (sharedMesh.isReadable ? CutHead(sharedMesh, renderer.bones, head) : null); Trimmed[sharedMesh] = value; } allHead = AllHead.Contains(sharedMesh); return value; } private static Mesh CutHead(Mesh mesh, Transform[] bones, Transform head) { //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) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) bool[] array = new bool[bones.Length]; for (int i = 0; i < bones.Length; i++) { array[i] = (Object)(object)bones[i] != (Object)null && bones[i].IsChildOf(head); } BoneWeight[] boneWeights = mesh.boneWeights; bool[] array2 = new bool[boneWeights.Length]; for (int j = 0; j < boneWeights.Length; j++) { BoneWeight val = boneWeights[j]; float num = HeadWeight(array, ((BoneWeight)(ref val)).boneIndex0, ((BoneWeight)(ref val)).weight0) + HeadWeight(array, ((BoneWeight)(ref val)).boneIndex1, ((BoneWeight)(ref val)).weight1) + HeadWeight(array, ((BoneWeight)(ref val)).boneIndex2, ((BoneWeight)(ref val)).weight2) + HeadWeight(array, ((BoneWeight)(ref val)).boneIndex3, ((BoneWeight)(ref val)).weight3); array2[j] = num >= 0.5f; } Mesh val2 = Object.Instantiate<Mesh>(mesh); ((Object)val2).name = ((Object)mesh).name + " (first person)"; int num2 = 0; int num3 = 0; List<int> list = new List<int>(); for (int k = 0; k < mesh.subMeshCount; k++) { if ((int)mesh.GetTopology(k) != 0) { continue; } int[] triangles = mesh.GetTriangles(k); list.Clear(); for (int l = 0; l + 2 < triangles.Length; l += 3) { if (array2[triangles[l]] || array2[triangles[l + 1]] || array2[triangles[l + 2]]) { num2++; continue; } list.Add(triangles[l]); list.Add(triangles[l + 1]); list.Add(triangles[l + 2]); } num3 += list.Count; val2.SetTriangles(list, k, false); } if (num2 > 0 && num3 == 0) { AllHead.Add(mesh); } if (num2 == 0 || num3 == 0) { Object.Destroy((Object)(object)val2); return null; } Logger.LogInfo((object)$"First person: cut {num2} head triangles from {((Object)mesh).name}"); return val2; } private static float HeadWeight(bool[] headBone, int index, float weight) { if (index < 0 || index >= headBone.Length || !headBone[index]) { return 0f; } return weight; } private static Copy MakeCopy(Player player, SkinnedMeshRenderer source, Mesh trimmed) { //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) //IL_0026: 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_0077: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(((Object)source).name + " (first person)") { layer = ((Component)source).gameObject.layer }; val.transform.SetParent(((Component)player).transform, false); SkinnedMeshRenderer val2 = val.AddComponent<SkinnedMeshRenderer>(); val2.sharedMesh = trimmed; val2.bones = source.bones; val2.rootBone = source.rootBone; ((Renderer)val2).localBounds = ((Renderer)source).localBounds; val2.updateWhenOffscreen = source.updateWhenOffscreen; val2.quality = source.quality; ((Renderer)val2).sharedMaterials = ((Renderer)source).sharedMaterials; ((Renderer)val2).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)val2).receiveShadows = ((Renderer)source).receiveShadows; ((Renderer)val2).lightProbeUsage = ((Renderer)source).lightProbeUsage; ((Renderer)val2).reflectionProbeUsage = ((Renderer)source).reflectionProbeUsage; ((Renderer)val2).motionVectorGenerationMode = ((Renderer)source).motionVectorGenerationMode; val2.skinnedMotionVectors = source.skinnedMotionVectors; return new Copy { Source = source, SourceMesh = source.sharedMesh, Renderer = val2 }; } private static bool CopiesCurrent() { foreach (Copy copy in Copies) { if ((Object)(object)copy.Source == (Object)null || (Object)(object)copy.Renderer == (Object)null || (Object)(object)copy.Source.sharedMesh != (Object)(object)copy.SourceMesh) { return false; } } return true; } private static void SyncCopies(Player player) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_004e: 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_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_0066: 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) //IL_0074: 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_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_0090: Unknown result type (might be due to invalid IL or missing references) if (_block == null) { _block = new MaterialPropertyBlock(); } Vector3 lossyScale = ((Component)player).transform.lossyScale; foreach (Copy copy in Copies) { Transform transform = ((Component)copy.Source).transform; Transform transform2 = ((Component)copy.Renderer).transform; transform2.SetPositionAndRotation(transform.position, transform.rotation); Vector3 lossyScale2 = transform.lossyScale; transform2.localScale = new Vector3(lossyScale2.x / lossyScale.x, lossyScale2.y / lossyScale.y, lossyScale2.z / lossyScale.z); ((Renderer)copy.Renderer).enabled = ((Renderer)copy.Source).enabled && ((Component)copy.Source).gameObject.activeInHierarchy; ((Renderer)copy.Source).GetSharedMaterials(SourceMaterials); ((Renderer)copy.Renderer).GetSharedMaterials(CopyMaterials); if (!SameMaterials()) { ((Renderer)copy.Renderer).sharedMaterials = ((Renderer)copy.Source).sharedMaterials; } ((Renderer)copy.Source).GetPropertyBlock(_block); ((Renderer)copy.Renderer).SetPropertyBlock(_block); } } private static bool SameMaterials() { if (SourceMaterials.Count != CopyMaterials.Count) { return false; } for (int i = 0; i < SourceMaterials.Count; i++) { if ((Object)(object)SourceMaterials[i] != (Object)(object)CopyMaterials[i]) { return false; } } return true; } private static void RestoreHead() { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) foreach (KeyValuePair<Renderer, ShadowCastingMode> item in ShadowOnly) { if ((Object)(object)item.Key != (Object)null) { item.Key.shadowCastingMode = item.Value; } } ShadowOnly.Clear(); foreach (Copy copy in Copies) { if ((Object)(object)copy.Renderer != (Object)null) { Object.Destroy((Object)(object)((Component)copy.Renderer).gameObject); } } Copies.Clear(); if ((Object)(object)_animator != (Object)null) { _animator.cullingMode = _animatorCulling; } _animator = null; _applied = false; _dirty = false; _player = null; } private static void AimHeadLights(Player player) { //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) GameObject val = (((Object)(object)((Humanoid)player).m_visEquipment != (Object)null) ? ((Humanoid)player).m_visEquipment.m_helmetItemInstance : null); Camera mainCamera = Utils.GetMainCamera(); if ((Object)(object)val == (Object)null || (Object)(object)mainCamera == (Object)null) { RestoreLights(); return; } val.GetComponentsInChildren<Light>(false, Lights); foreach (Light light in Lights) { if (!AimedLights.ContainsKey(light)) { AimedLights[light] = ((Component)light).transform.localRotation; } ((Component)light).transform.rotation = ((Component)mainCamera).transform.rotation; } } private static void RestoreLights() { //IL_0032: Unknown result type (might be due to invalid IL or missing references) foreach (KeyValuePair<Light, Quaternion> aimedLight in AimedLights) { if ((Object)(object)aimedLight.Key != (Object)null) { ((Component)aimedLight.Key).transform.localRotation = aimedLight.Value; } } AimedLights.Clear(); } } internal static class FirstPersonSettings { private static ConfigEntry<float> _turnAngle; private static ConfigEntry<float> _cameraHeight; private static ConfigEntry<float> _cameraForward; private static ConfigEntry<float> _headBob; private static ConfigEntry<float> _bowAimRight; private static ConfigEntry<float> _bowAimUp; private static ConfigEntry<float> _headNod; private static ConfigEntry<float> _maxLookDown; private static ConfigEntry<float> _seatedTurnAngle; private static ConfigEntry<float> _seatedMaxLookDown; private static ConfigEntry<float> _seatedMaxLookDownSideways; public const float NearClip = 0.05f; public static float TurnAngle => _turnAngle.Value; public static Vector3 CameraOffset => new Vector3(0f, _cameraHeight.Value, _cameraForward.Value); public static float HeadBob => _headBob.Value; public static Vector3 BowAimOffset => new Vector3(_bowAimRight.Value, _bowAimUp.Value, 0f); public static float HeadNod => _headNod.Value; public static float MaxLookDown => _maxLookDown.Value; public static float SeatedTurnAngle => _seatedTurnAngle.Value; public static float SeatedMaxLookDown => _seatedMaxLookDown.Value; public static float SeatedMaxLookDownSideways => _seatedMaxLookDownSideways.Value; public static bool Active { get { GameCamera instance = GameCamera.instance; if ((Object)(object)instance != (Object)null && !instance.m_freeFly && instance.m_distance <= 0f) { return (Object)(object)Player.m_localPlayer != (Object)null; } return false; } } public static void BindConfig(ConfigFile config) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Expected O, but got Unknown //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Expected O, but got Unknown //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Expected O, but got Unknown //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Expected O, but got Unknown //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Expected O, but got Unknown //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Expected O, but got Unknown //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Expected O, but got Unknown //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Expected O, but got Unknown //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Expected O, but got Unknown //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Expected O, but got Unknown _turnAngle = config.Bind<float>("First Person", "Body Turn Angle", 60f, new ConfigDescription("Degrees you can look to the side while standing still before your body turns to follow. While moving, your body always faces where you look.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 180f), Array.Empty<object>())); _cameraHeight = config.Bind<float>("First Person", "Camera Height", 0.3f, new ConfigDescription("How far above your head's pivot (the top of the neck) the first-person camera sits, in metres. Raise it if your character feels short. The camera follows the head as the animations move it.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 0.4f), Array.Empty<object>())); _cameraForward = config.Bind<float>("First Person", "Camera Forward", 0.08f, new ConfigDescription("How far in front of your head's pivot the first-person camera sits, in metres, along where you look (see Head Nod for looking up and down).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-0.1f, 0.3f), Array.Empty<object>())); _headNod = config.Bind<float>("First Person", "Head Nod", 0.25f, new ConfigDescription("How much your head tilts when you look up or down, moving the camera with it. 1 tilts the camera's height and forward offset with the view, which drops the camera to your shoulders when you look down; 0 keeps it at eye height and only turns the view.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); _headBob = config.Bind<float>("First Person", "Head Bob", 0f, new ConfigDescription("How much the camera bobs and sways with your head as you walk, run and attack. 0 (the default) keeps the view steady; 1 follows the head fully.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); _bowAimRight = config.Bind<float>("First Person", "Bow Aim Right", 0.15f, new ConfigDescription("How far the camera moves right while drawing a bow, in metres, so the bow (held in front of your face) sits beside the crosshair instead of covering it. Arrows still fly to the crosshair.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-0.3f, 0.3f), Array.Empty<object>())); _bowAimUp = config.Bind<float>("First Person", "Bow Aim Up", 0.03f, new ConfigDescription("How far the camera moves up while drawing a bow, in metres.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-0.2f, 0.2f), Array.Empty<object>())); _maxLookDown = config.Bind<float>("First Person", "Max Look Down", 65f, new ConfigDescription("The furthest you can look down in first person, in degrees below level, so the camera doesn't see inside your armour and body (vanilla 89).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(30f, 89f), Array.Empty<object>())); _seatedTurnAngle = config.Bind<float>("First Person", "Seated Turn Angle", 135f, new ConfigDescription("While seated (at the helm, on a chair or riding), how far you can look to either side, in degrees, so you can look over your shoulders without seeing inside your body.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(30f, 180f), Array.Empty<object>())); _seatedMaxLookDown = config.Bind<float>("First Person", "Seated Max Look Down", 60f, new ConfigDescription("While seated and facing forward, the furthest you can look down, in degrees below level.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 89f), Array.Empty<object>())); _seatedMaxLookDownSideways = config.Bind<float>("First Person", "Seated Max Look Down Sideways", 15f, new ConfigDescription("While seated and looking well to the side, the furthest you can look down, in degrees below level. Turning while looking down lifts the view towards this, so the camera doesn't see inside your body.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-30f, 89f), Array.Empty<object>())); } } internal static class NearFoliage { private const float RescanInterval = 3f; private static readonly int CamCull = Shader.PropertyToID("_CamCull"); private static readonly Dictionary<Material, float> Changed = new Dictionary<Material, float>(); private static readonly HashSet<int> Checked = new HashSet<int>(); private static float _nextScan; public static void Update(bool firstPerson) { if (!firstPerson) { Restore(); } else { if (Time.unscaledTime < _nextScan) { return; } _nextScan = Time.unscaledTime + 3f; Material[] array = Resources.FindObjectsOfTypeAll<Material>(); foreach (Material val in array) { if (Checked.Add(((Object)val).GetInstanceID()) && val.HasProperty(CamCull)) { float num = val.GetFloat(CamCull); if (num != 0f) { Changed[val] = num; val.SetFloat(CamCull, 0f); } } } } } public static void Restore() { if (Checked.Count == 0) { return; } foreach (KeyValuePair<Material, float> item in Changed) { if ((Object)(object)item.Key != (Object)null) { item.Key.SetFloat(CamCull, item.Value); } } Changed.Clear(); Checked.Clear(); _nextScan = 0f; } } } namespace BetterCamera.Core { internal static class KeyInput { public static bool IsDown(KeyboardShortcut shortcut) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: 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) if ((int)((KeyboardShortcut)(ref shortcut)).MainKey == 0 || !UnityInput.Current.GetKeyDown(((KeyboardShortcut)(ref shortcut)).MainKey)) { return false; } foreach (KeyCode modifier in ((KeyboardShortcut)(ref shortcut)).Modifiers) { if (!UnityInput.Current.GetKey(modifier)) { return false; } } return true; } } internal static class Translations { private const string ResourcePrefix = "BetterCamera.Translations."; private const string ResourceSuffix = ".json"; public static void Load() { CustomLocalization localization = LocalizationManager.Instance.GetLocalization(); Assembly executingAssembly = Assembly.GetExecutingAssembly(); string[] manifestResourceNames = executingAssembly.GetManifestResourceNames(); foreach (string text in manifestResourceNames) { if (text.StartsWith("BetterCamera.Translations.", StringComparison.Ordinal) && text.EndsWith(".json", StringComparison.Ordinal)) { string text2 = text.Substring("BetterCamera.Translations.".Length, text.Length - "BetterCamera.Translations.".Length - ".json".Length); using StreamReader streamReader = new StreamReader(executingAssembly.GetManifestResourceStream(text)); localization.AddJsonFile(text2, streamReader.ReadToEnd()); } } } } } namespace BetterCamera.Combat { internal static class MeleeAim { private static ConfigEntry<float> _maxAngle; private static ConfigEntry<bool> _leanIntoSwings; public static float MaxAngle => _maxAngle.Value; public static bool LeanIntoSwings => _leanIntoSwings.Value; public static void BindConfig(ConfigFile config) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown _maxAngle = config.Bind<float>("Combat", "Melee Aim Angle", 45f, new ConfigDescription("How far, in degrees, melee swings tilt up or down to follow where you look, so you can hit enemies above or below you on a slope. Vanilla swings always stay level (0).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 90f), Array.Empty<object>())); _leanIntoSwings = config.Bind<bool>("Combat", "Lean Into Swings", true, "Your upper body bends up or down with tilted melee swings, so the animation matches where the swing goes. Only you see it; other players see the normal animation."); } public static Vector3 Direction(Attack attack, Transform originJoint, Vector3 vanilla) { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_0061: 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_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0081: 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) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Max(attack.m_maxYAngle, MaxAngle); if (FirstPersonSettings.Active) { Humanoid character = attack.m_character; Player val = (Player)(object)((character is Player) ? character : null); if (val != null) { return FirstPersonDirection(attack, val, originJoint, num); } } if (num <= attack.m_maxYAngle) { return vanilla; } Vector3 forward = ((Component)attack.m_character).transform.forward; Vector3 aimDir = attack.m_character.GetAimDir(originJoint.position); aimDir.x = forward.x; aimDir.z = forward.z; ((Vector3)(ref aimDir)).Normalize(); return Vector3.RotateTowards(forward, aimDir, (float)Math.PI / 180f * num, 10f); } private static Vector3 FirstPersonDirection(Attack attack, Player player, Transform originJoint, float maxAngle) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_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_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: 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_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_005b: 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_005d: 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_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown resu