From e28addc7ea0ce0ce39b489d5f2e31650f6d652bf Mon Sep 17 00:00:00 2001 From: Terkoiz Date: Sat, 4 Mar 2023 11:26:11 +0200 Subject: [PATCH] Removed the fall damage toggle due to lack of reliability --- project/Terkoiz.Freecam/FreecamController.cs | 37 +++++-------------- project/Terkoiz.Freecam/FreecamPlugin.cs | 11 +----- .../Terkoiz.Freecam/Terkoiz.Freecam.csproj | 2 +- 3 files changed, 13 insertions(+), 37 deletions(-) diff --git a/project/Terkoiz.Freecam/FreecamController.cs b/project/Terkoiz.Freecam/FreecamController.cs index cec1afb..7ba0668 100644 --- a/project/Terkoiz.Freecam/FreecamController.cs +++ b/project/Terkoiz.Freecam/FreecamController.cs @@ -15,7 +15,6 @@ namespace Terkoiz.Freecam private BattleUIScreen _playerUi; private bool _uiHidden; - private bool _fallDamageToggle = false; private GamePlayerOwner _gamePlayerOwner; @@ -33,17 +32,24 @@ namespace Terkoiz.Freecam // Find Main Camera _mainCamera = GameObject.Find("FPS Camera"); if (_mainCamera == null) + { FreecamPlugin.Logger.LogError("Failed to locate main camera"); - + return; + } + // Add Freecam script to main camera in scene _freeCamScript = _mainCamera.AddComponent(); if (_freeCamScript == null) + { FreecamPlugin.Logger.LogError("Failed to add Freecam script to Camera"); - + } + // Get GamePlayerOwner component _gamePlayerOwner = GetLocalPlayerFromWorld().GetComponentInChildren(); if (_gamePlayerOwner == null) + { FreecamPlugin.Logger.LogError("Failed to locate GamePlayerOwner"); + } } [UsedImplicitly] @@ -63,29 +69,6 @@ namespace Terkoiz.Freecam { MovePlayerToCamera(); } - - if (_fallDamageToggle != FreecamPlugin.DisableFallDamage.Value) - { - _fallDamageToggle = ToggleFallDamage(FreecamPlugin.DisableFallDamage.Value); - } - } - - private bool ToggleFallDamage(bool config) - { - var localPlayer = GetLocalPlayerFromWorld(); - if (localPlayer == null) - return false; - - // Set Safe fall height to 99999 - if (config) - { - localPlayer.ActiveHealthController.FallSafeHeight = 99999; - return true; - } - - // Set Safe fall height to 3 - localPlayer.ActiveHealthController.FallSafeHeight = 3; - return false; } /// @@ -231,7 +214,7 @@ namespace Terkoiz.Freecam } [UsedImplicitly] - private void OnDestroy() + public void OnDestroy() { // Destroy FreeCamScript before FreeCamController if exists Destroy(_freeCamScript); diff --git a/project/Terkoiz.Freecam/FreecamPlugin.cs b/project/Terkoiz.Freecam/FreecamPlugin.cs index 7d32a19..3d0d5c2 100644 --- a/project/Terkoiz.Freecam/FreecamPlugin.cs +++ b/project/Terkoiz.Freecam/FreecamPlugin.cs @@ -7,7 +7,7 @@ using KeyboardShortcut = BepInEx.Configuration.KeyboardShortcut; namespace Terkoiz.Freecam { - [BepInPlugin("com.terkoiz.freecam", "Terkoiz.Freecam", "1.3.0")] + [BepInPlugin("com.terkoiz.freecam", "Terkoiz.Freecam", "1.3.1")] public class FreecamPlugin : BaseUnityPlugin { internal new static ManualLogSource Logger { get; private set; } @@ -31,8 +31,7 @@ namespace Terkoiz.Freecam internal static ConfigEntry CameraHeightMovement; internal static ConfigEntry CameraMousewheelZoom; internal static ConfigEntry CameraRememberLastPosition; - internal static ConfigEntry DisableFallDamage; - + [UsedImplicitly] internal void Start() { @@ -120,12 +119,6 @@ namespace Terkoiz.Freecam "CameraRememberLastPosition", false, "If enabled, returning to Freecam mode will put the camera to it's last position which was saved when exiting Freecam mode."); - - DisableFallDamage = Config.Bind( - TogglesSectionName, - "DisableFallDamage", - true, - "If enabled, will prevent fall damage for the player. Highly recommended to leave this enabled if using TeleportToCamera."); } } } diff --git a/project/Terkoiz.Freecam/Terkoiz.Freecam.csproj b/project/Terkoiz.Freecam/Terkoiz.Freecam.csproj index 9d576d1..2f4f457 100644 --- a/project/Terkoiz.Freecam/Terkoiz.Freecam.csproj +++ b/project/Terkoiz.Freecam/Terkoiz.Freecam.csproj @@ -2,7 +2,7 @@ net472 - 1.3.0 + 1.3.1 Terkoiz, Kobrakon, CWX https://dev.sp-tarkov.com/Terkoiz/Freecam NCSA