Snapshot before project reorganization
This commit is contained in:
@@ -25,6 +25,7 @@ namespace Unheimlich.Gameplay.Player
|
||||
|
||||
private HeadBobMode _overrideMode = HeadBobMode.Normal;
|
||||
private bool _hasOverride = false;
|
||||
private Coroutine _resetCoroutine;
|
||||
|
||||
void Start()
|
||||
{
|
||||
@@ -80,6 +81,40 @@ namespace Unheimlich.Gameplay.Player
|
||||
public void ClearOverride()
|
||||
{
|
||||
_hasOverride = false;
|
||||
|
||||
if (_resetCoroutine != null)
|
||||
{
|
||||
StopCoroutine(_resetCoroutine);
|
||||
_resetCoroutine = null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Smoothly lerps the head bob position to zero over the specified duration.
|
||||
/// </summary>
|
||||
public void LerpToZero(float duration)
|
||||
{
|
||||
if (_resetCoroutine != null)
|
||||
StopCoroutine(_resetCoroutine);
|
||||
|
||||
_resetCoroutine = StartCoroutine(LerpToZeroCoroutine(duration));
|
||||
}
|
||||
|
||||
private System.Collections.IEnumerator LerpToZeroCoroutine(float duration)
|
||||
{
|
||||
Vector3 startPos = transform.localPosition;
|
||||
float elapsed = 0f;
|
||||
|
||||
while (elapsed < duration)
|
||||
{
|
||||
elapsed += Time.deltaTime;
|
||||
float t = Mathf.Clamp01(elapsed / duration);
|
||||
transform.localPosition = Vector3.Lerp(startPos, Vector3.zero, t);
|
||||
yield return null;
|
||||
}
|
||||
|
||||
transform.localPosition = Vector3.zero;
|
||||
_resetCoroutine = null;
|
||||
}
|
||||
|
||||
private void ApplyBob(float speed, float amplitude)
|
||||
|
||||
+51
-7
@@ -66,6 +66,7 @@ namespace Unheimlich.Gameplay.Player
|
||||
private AudioListenable _currentTargetEmitter;
|
||||
private AudioSource _playerAudioSource;
|
||||
private Coroutine _listeningCoroutine;
|
||||
private Coroutine _vibrationCoroutine;
|
||||
private int _diapasonTweenId = -1;
|
||||
private int _audioListenerFadeTweenId = -1;
|
||||
private int _playerAudioFadeTweenId = -1;
|
||||
@@ -74,7 +75,9 @@ namespace Unheimlich.Gameplay.Player
|
||||
private Vector3 _diapasonHiddenPosition;
|
||||
private bool _canUseDiapason;
|
||||
private bool _isFadingOutConcentration;
|
||||
private Coroutine _vibrationCoroutine;
|
||||
|
||||
private CameraHeadBob _cameraHeadBob;
|
||||
private CameraPanSettings _originalCameraSettings;
|
||||
|
||||
protected override void OnAwake()
|
||||
{
|
||||
@@ -91,6 +94,8 @@ namespace Unheimlich.Gameplay.Player
|
||||
_cameraPanController = gameObject.AddComponent<CameraPanController>();
|
||||
}
|
||||
}
|
||||
|
||||
_cameraHeadBob = GetComponentInChildren<CameraHeadBob>();
|
||||
|
||||
if (_diapasonObject != null)
|
||||
{
|
||||
@@ -236,6 +241,10 @@ namespace Unheimlich.Gameplay.Player
|
||||
|
||||
if (_currentTargetEmitter != null && _cameraPanController != null)
|
||||
{
|
||||
_originalCameraSettings = _cameraPanController.Settings;
|
||||
if(_currentTargetEmitter.CameraPanSettings != null)
|
||||
_cameraPanController.Settings = _currentTargetEmitter.CameraPanSettings;
|
||||
|
||||
_currentTargetEmitter.SetConcentrating(true);
|
||||
|
||||
_cameraPanController.AlignToTarget(_currentTargetEmitter.transform);
|
||||
@@ -263,18 +272,23 @@ namespace Unheimlich.Gameplay.Player
|
||||
|
||||
PlayBreathIn();
|
||||
yield return new WaitForSeconds(_breathInDuration);
|
||||
|
||||
if (_cameraHeadBob != null)
|
||||
{
|
||||
float resetDuration = _concentrationDuration - _breathInDuration;
|
||||
_cameraHeadBob.LerpToZero(resetDuration);
|
||||
}
|
||||
|
||||
yield return new WaitForSeconds(_concentrationDuration - _breathInDuration);
|
||||
|
||||
IsConcentrating = false;
|
||||
IsListening = true;
|
||||
|
||||
EnableVignette(true);
|
||||
|
||||
if (_cameraPanController != null)
|
||||
{
|
||||
_cameraPanController.StartPan();
|
||||
}
|
||||
EnableVignette(true);
|
||||
|
||||
ApplyHeadBobSettings(_cameraPanController.Settings);
|
||||
_cameraPanController.StartPan();
|
||||
|
||||
|
||||
Cursor.lockState = CursorLockMode.Confined;
|
||||
Cursor.visible = false;
|
||||
@@ -311,7 +325,15 @@ namespace Unheimlich.Gameplay.Player
|
||||
{
|
||||
_cameraPanController.StopPan();
|
||||
_cameraPanController.ReturnToOriginalPosition();
|
||||
|
||||
if (_originalCameraSettings != null)
|
||||
{
|
||||
_cameraPanController.Settings = _originalCameraSettings;
|
||||
_originalCameraSettings = null;
|
||||
}
|
||||
}
|
||||
|
||||
RestoreHeadBob();
|
||||
|
||||
if (_playerAudioSource != null && _playerAudioSource.isPlaying)
|
||||
{
|
||||
@@ -528,6 +550,28 @@ namespace Unheimlich.Gameplay.Player
|
||||
_vignetteEffect.SetIntensity(_vignetteIntensity);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Applies head bob settings based on CameraPanSettings configuration.
|
||||
/// </summary>
|
||||
private void ApplyHeadBobSettings(CameraPanSettings settings)
|
||||
{
|
||||
if (_cameraHeadBob == null || settings == null)
|
||||
return;
|
||||
|
||||
_cameraHeadBob.SetMode(settings.HeadBobMode);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Restores head bob to normal behavior.
|
||||
/// </summary>
|
||||
private void RestoreHeadBob()
|
||||
{
|
||||
if (_cameraHeadBob == null)
|
||||
return;
|
||||
|
||||
_cameraHeadBob.ClearOverride();
|
||||
}
|
||||
|
||||
private void OnDrawGizmosSelected()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user