This commit is contained in:
Lucastaa
2026-04-26 00:27:56 +07:00
parent 32c598da8b
commit 966642bdcd
44 changed files with 9296 additions and 441 deletions

View File

@@ -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