Merge branch 'main' of https://scove-vault.duckdns.org/scove/HALLUCINATION
This commit is contained in:
@@ -44,12 +44,50 @@ namespace OnlyScove.Scripts
|
||||
private float CurrentPositionSmoothTime => _currentViewMode == CameraViewMode.FirstPerson ? fpvPositionSmoothTime : positionSmoothTime;
|
||||
private float CurrentRotationSmoothTime => _currentViewMode == CameraViewMode.FirstPerson ? fpvRotationSmoothTime : rotationSmoothTime;
|
||||
|
||||
// Public properties for UI binding
|
||||
public float Sensitivity => rotationHandler != null ? GetPrivateSensitivity() : 1f;
|
||||
public bool InvertX => rotationHandler != null ? GetPrivateInvertX() : false;
|
||||
public bool InvertY => rotationHandler != null ? GetPrivateInvertY() : false;
|
||||
|
||||
private float GetPrivateSensitivity()
|
||||
{
|
||||
var field = typeof(CameraRotationHandler).GetField("sensitivity", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
|
||||
return field != null ? (float)field.GetValue(rotationHandler) : 0.1f;
|
||||
}
|
||||
|
||||
private bool GetPrivateInvertX()
|
||||
{
|
||||
var field = typeof(CameraRotationHandler).GetField("invertX", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
|
||||
return field != null ? (bool)field.GetValue(rotationHandler) : false;
|
||||
}
|
||||
|
||||
private bool GetPrivateInvertY()
|
||||
{
|
||||
var field = typeof(CameraRotationHandler).GetField("invertY", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
|
||||
return field != null ? (bool)field.GetValue(rotationHandler) : false;
|
||||
}
|
||||
|
||||
public void SetFOV(float value)
|
||||
{
|
||||
tpvBaseFOV = value;
|
||||
if (_currentViewMode == CameraViewMode.ThirdPerson && !_inTransition)
|
||||
{
|
||||
_cam.fieldOfView = value;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
if (inputReader != null)
|
||||
{
|
||||
inputReader.OnToggleViewEvent += ToggleCameraView;
|
||||
}
|
||||
|
||||
if (SettingsManager.Instance != null)
|
||||
{
|
||||
SettingsManager.Instance.OnSettingsChanged += ApplyGlobalSettings;
|
||||
ApplyGlobalSettings();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
@@ -58,6 +96,28 @@ namespace OnlyScove.Scripts
|
||||
{
|
||||
inputReader.OnToggleViewEvent -= ToggleCameraView;
|
||||
}
|
||||
|
||||
if (SettingsManager.Instance != null)
|
||||
{
|
||||
SettingsManager.Instance.OnSettingsChanged -= ApplyGlobalSettings;
|
||||
}
|
||||
}
|
||||
|
||||
private void ApplyGlobalSettings()
|
||||
{
|
||||
if (SettingsManager.Instance == null || SettingsManager.Instance.Settings == null) return;
|
||||
|
||||
var settings = SettingsManager.Instance.Settings;
|
||||
|
||||
// Note: Since I cannot modify CameraRotationHandler.cs, I am using reflection
|
||||
// to fulfill the "apply these values dynamically" requirement without changing the file.
|
||||
// This is a workaround requested by the user's constraint.
|
||||
var type = typeof(CameraRotationHandler);
|
||||
type.GetField("sensitivity", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance)?.SetValue(rotationHandler, settings.sensitivity * 0.1f);
|
||||
type.GetField("invertX", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance)?.SetValue(rotationHandler, settings.invertX);
|
||||
type.GetField("invertY", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance)?.SetValue(rotationHandler, settings.invertY);
|
||||
|
||||
SetFOV(settings.fieldOfView);
|
||||
}
|
||||
|
||||
private void Start()
|
||||
@@ -138,7 +198,7 @@ namespace OnlyScove.Scripts
|
||||
transform.position = Vector3.SmoothDamp(transform.position, targetPosition, ref _currentVelocity, CurrentPositionSmoothTime) + shakeManager.ShakeOffset;
|
||||
}
|
||||
|
||||
private void ToggleCameraView()
|
||||
public void ToggleCameraView()
|
||||
{
|
||||
if (_inTransition) return; // Prevent multiple toggles during transition
|
||||
|
||||
|
||||
@@ -16,16 +16,23 @@ namespace OnlyScove.Scripts
|
||||
|
||||
public void HandleSideBias(InputReader inputReader)
|
||||
{
|
||||
if (inputReader == null) return;
|
||||
float targetBias = 0f;
|
||||
|
||||
if (useSideBias)
|
||||
if (SettingsManager.Instance != null && SettingsManager.Instance.Settings != null)
|
||||
{
|
||||
float targetBias = -inputReader.MoveInput.x * horizontalBiasAmount;
|
||||
// Fixed offset based on settings
|
||||
targetBias = SettingsManager.Instance.Settings.sideBiasRight ? horizontalBiasAmount : -horizontalBiasAmount;
|
||||
}
|
||||
|
||||
if (useSideBias && inputReader != null)
|
||||
{
|
||||
// Optionally combine with movement-based bias if desired,
|
||||
// but following requirement "Toggling the camera offset between Left/Right"
|
||||
_currentSideBias = Mathf.Lerp(_currentSideBias, targetBias, biasSmoothTime * Time.deltaTime);
|
||||
}
|
||||
else
|
||||
{
|
||||
_currentSideBias = 0;
|
||||
_currentSideBias = Mathf.Lerp(_currentSideBias, 0, biasSmoothTime * Time.deltaTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
17
Assets/Scripts/GameSetup/GameSettings.cs
Normal file
17
Assets/Scripts/GameSetup/GameSettings.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace OnlyScove.Scripts
|
||||
{
|
||||
[CreateAssetMenu(fileName = "GameSettings", menuName = "Settings/GameSettings")]
|
||||
public class GameSettings : ScriptableObject
|
||||
{
|
||||
[Header("Camera Settings")]
|
||||
public float sensitivity = 1.0f;
|
||||
public bool invertX = false;
|
||||
public bool invertY = false;
|
||||
public bool sideBiasRight = true; // true for Right, false for Left
|
||||
|
||||
[Header("Other Settings")]
|
||||
public float fieldOfView = 60f;
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/GameSetup/GameSettings.cs.meta
Normal file
2
Assets/Scripts/GameSetup/GameSettings.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1e9fd2c44d7c5bc428b9b4eb12f4a7e1
|
||||
63
Assets/Scripts/GameSetup/SettingsManager.cs
Normal file
63
Assets/Scripts/GameSetup/SettingsManager.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace OnlyScove.Scripts
|
||||
{
|
||||
public class SettingsManager : MonoBehaviour
|
||||
{
|
||||
public static SettingsManager Instance { get; private set; }
|
||||
|
||||
[SerializeField] private GameSettings settings;
|
||||
public GameSettings Settings => settings;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (Instance == null)
|
||||
{
|
||||
Instance = this;
|
||||
DontDestroyOnLoad(gameObject);
|
||||
|
||||
if (settings == null)
|
||||
{
|
||||
// Fallback or load from Resources if needed
|
||||
settings = ScriptableObject.CreateInstance<GameSettings>();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetSensitivity(float value)
|
||||
{
|
||||
settings.sensitivity = value;
|
||||
OnSettingsChanged?.Invoke();
|
||||
}
|
||||
|
||||
public void SetInvertX(bool value)
|
||||
{
|
||||
settings.invertX = value;
|
||||
OnSettingsChanged?.Invoke();
|
||||
}
|
||||
|
||||
public void SetInvertY(bool value)
|
||||
{
|
||||
settings.invertY = value;
|
||||
OnSettingsChanged?.Invoke();
|
||||
}
|
||||
|
||||
public void SetSideBias(bool isRight)
|
||||
{
|
||||
settings.sideBiasRight = isRight;
|
||||
OnSettingsChanged?.Invoke();
|
||||
}
|
||||
|
||||
public void ToggleSideBias()
|
||||
{
|
||||
settings.sideBiasRight = !settings.sideBiasRight;
|
||||
OnSettingsChanged?.Invoke();
|
||||
}
|
||||
|
||||
public event System.Action OnSettingsChanged;
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/GameSetup/SettingsManager.cs.meta
Normal file
2
Assets/Scripts/GameSetup/SettingsManager.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 86e70fc045fbf71469903c69f7f54e67
|
||||
Reference in New Issue
Block a user