Removed the fall damage toggle due to lack of reliability

This commit is contained in:
Terkoiz 2023-03-04 11:26:11 +02:00
parent 04b65cef3f
commit e28addc7ea
3 changed files with 13 additions and 37 deletions

View File

@ -15,7 +15,6 @@ namespace Terkoiz.Freecam
private BattleUIScreen _playerUi; private BattleUIScreen _playerUi;
private bool _uiHidden; private bool _uiHidden;
private bool _fallDamageToggle = false;
private GamePlayerOwner _gamePlayerOwner; private GamePlayerOwner _gamePlayerOwner;
@ -33,17 +32,24 @@ namespace Terkoiz.Freecam
// Find Main Camera // Find Main Camera
_mainCamera = GameObject.Find("FPS Camera"); _mainCamera = GameObject.Find("FPS Camera");
if (_mainCamera == null) if (_mainCamera == null)
{
FreecamPlugin.Logger.LogError("Failed to locate main camera"); FreecamPlugin.Logger.LogError("Failed to locate main camera");
return;
}
// Add Freecam script to main camera in scene // Add Freecam script to main camera in scene
_freeCamScript = _mainCamera.AddComponent<Freecam>(); _freeCamScript = _mainCamera.AddComponent<Freecam>();
if (_freeCamScript == null) if (_freeCamScript == null)
{
FreecamPlugin.Logger.LogError("Failed to add Freecam script to Camera"); FreecamPlugin.Logger.LogError("Failed to add Freecam script to Camera");
}
// Get GamePlayerOwner component // Get GamePlayerOwner component
_gamePlayerOwner = GetLocalPlayerFromWorld().GetComponentInChildren<GamePlayerOwner>(); _gamePlayerOwner = GetLocalPlayerFromWorld().GetComponentInChildren<GamePlayerOwner>();
if (_gamePlayerOwner == null) if (_gamePlayerOwner == null)
{
FreecamPlugin.Logger.LogError("Failed to locate GamePlayerOwner"); FreecamPlugin.Logger.LogError("Failed to locate GamePlayerOwner");
}
} }
[UsedImplicitly] [UsedImplicitly]
@ -63,29 +69,6 @@ namespace Terkoiz.Freecam
{ {
MovePlayerToCamera(); 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;
} }
/// <summary> /// <summary>
@ -231,7 +214,7 @@ namespace Terkoiz.Freecam
} }
[UsedImplicitly] [UsedImplicitly]
private void OnDestroy() public void OnDestroy()
{ {
// Destroy FreeCamScript before FreeCamController if exists // Destroy FreeCamScript before FreeCamController if exists
Destroy(_freeCamScript); Destroy(_freeCamScript);

View File

@ -7,7 +7,7 @@ using KeyboardShortcut = BepInEx.Configuration.KeyboardShortcut;
namespace Terkoiz.Freecam 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 public class FreecamPlugin : BaseUnityPlugin
{ {
internal new static ManualLogSource Logger { get; private set; } internal new static ManualLogSource Logger { get; private set; }
@ -31,7 +31,6 @@ namespace Terkoiz.Freecam
internal static ConfigEntry<bool> CameraHeightMovement; internal static ConfigEntry<bool> CameraHeightMovement;
internal static ConfigEntry<bool> CameraMousewheelZoom; internal static ConfigEntry<bool> CameraMousewheelZoom;
internal static ConfigEntry<bool> CameraRememberLastPosition; internal static ConfigEntry<bool> CameraRememberLastPosition;
internal static ConfigEntry<bool> DisableFallDamage;
[UsedImplicitly] [UsedImplicitly]
internal void Start() internal void Start()
@ -120,12 +119,6 @@ namespace Terkoiz.Freecam
"CameraRememberLastPosition", "CameraRememberLastPosition",
false, false,
"If enabled, returning to Freecam mode will put the camera to it's last position which was saved when exiting Freecam mode."); "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.");
} }
} }
} }

View File

@ -2,7 +2,7 @@
<PropertyGroup> <PropertyGroup>
<TargetFramework>net472</TargetFramework> <TargetFramework>net472</TargetFramework>
<Version>1.3.0</Version> <Version>1.3.1</Version>
<Authors>Terkoiz, Kobrakon, CWX</Authors> <Authors>Terkoiz, Kobrakon, CWX</Authors>
<RepositoryUrl>https://dev.sp-tarkov.com/Terkoiz/Freecam</RepositoryUrl> <RepositoryUrl>https://dev.sp-tarkov.com/Terkoiz/Freecam</RepositoryUrl>
<PackageLicenseExpression>NCSA</PackageLicenseExpression> <PackageLicenseExpression>NCSA</PackageLicenseExpression>