Revamp the settings system (#7)

- A Settings Provider system to utilize addressables for loading settings at runtime
- An editor UI for easy modifications of the settings objects
- A split out developer settings functionality to keep gameplay and nitty-gritty details separately
- Most settings migrated out of game objects and into the new system
- An additional Editor utility for fetching the settings at editor runtime, for gizmos, visualization etc

Co-authored-by: Michal Pikulski <michal.a.pikulski@gmail.com>
Co-authored-by: AlexanderT <alexander@foolhardyhorizons.com>
Reviewed-on: #7
This commit is contained in:
2025-09-24 13:33:43 +00:00
parent 4b206b9b2e
commit 63cb3f1a8c
77 changed files with 2795 additions and 978 deletions

View File

@@ -1,4 +1,5 @@
using UnityEngine;
using AppleHills.Core.Settings;
namespace Minigames.DivingForPictures
{
@@ -8,11 +9,8 @@ namespace Minigames.DivingForPictures
/// </summary>
public class PlayerController : MonoBehaviour, ITouchInputConsumer
{
[Header("Tap Movement")]
[Tooltip("Maximum distance the player can move from a single tap")]
[SerializeField] private float tapMaxDistance = 0.5f;
[Tooltip("How quickly the tap impulse fades (higher = faster stop)")]
[SerializeField] private float tapDecelerationRate = 5.0f;
// Settings reference
private IDivingMinigameSettings _settings;
private float _targetFingerX;
private bool _isTouchActive;
@@ -25,6 +23,13 @@ namespace Minigames.DivingForPictures
void Awake()
{
_originY = transform.position.y;
// Get settings from GameManager
_settings = GameManager.GetSettingsObject<IDivingMinigameSettings>();
if (_settings == null)
{
Debug.LogError("[PlayerController] Failed to load diving minigame settings!");
}
}
void Start()
@@ -42,7 +47,7 @@ namespace Minigames.DivingForPictures
public void OnTap(Vector2 worldPosition)
{
// Debug.Log($"[EndlessDescenderController] OnTap at {worldPosition}");
float targetX = Mathf.Clamp(worldPosition.x, GameManager.Instance.EndlessDescenderClampXMin, GameManager.Instance.EndlessDescenderClampXMax);
float targetX = Mathf.Clamp(worldPosition.x, _settings.ClampXMin, _settings.ClampXMax);
// Calculate tap direction (+1 for right, -1 for left)
_tapDirection = Mathf.Sign(targetX - transform.position.x);
@@ -63,7 +68,7 @@ namespace Minigames.DivingForPictures
public void OnHoldStart(Vector2 worldPosition)
{
// Debug.Log($"[EndlessDescenderController] OnHoldStart at {worldPosition}");
_targetFingerX = Mathf.Clamp(worldPosition.x, GameManager.Instance.EndlessDescenderClampXMin, GameManager.Instance.EndlessDescenderClampXMax);
_targetFingerX = Mathf.Clamp(worldPosition.x, _settings.ClampXMin, _settings.ClampXMax);
_isTouchActive = true;
}
@@ -73,7 +78,7 @@ namespace Minigames.DivingForPictures
public void OnHoldMove(Vector2 worldPosition)
{
// Debug.Log($"[EndlessDescenderController] OnHoldMove at {worldPosition}");
_targetFingerX = Mathf.Clamp(worldPosition.x, GameManager.Instance.EndlessDescenderClampXMin, GameManager.Instance.EndlessDescenderClampXMax);
_targetFingerX = Mathf.Clamp(worldPosition.x, _settings.ClampXMin, _settings.ClampXMax);
}
/// <summary>
@@ -91,9 +96,9 @@ namespace Minigames.DivingForPictures
if (_isTouchActive)
{
float currentX = transform.position.x;
float lerpSpeed = GameManager.Instance.EndlessDescenderLerpSpeed;
float maxOffset = GameManager.Instance.EndlessDescenderMaxOffset;
float exponent = GameManager.Instance.EndlessDescenderSpeedExponent;
float lerpSpeed = _settings.LerpSpeed;
float maxOffset = _settings.MaxOffset;
float exponent = _settings.SpeedExponent;
float targetX = _targetFingerX;
float offset = targetX - currentX;
offset = Mathf.Clamp(offset, -maxOffset, maxOffset);
@@ -103,7 +108,7 @@ namespace Minigames.DivingForPictures
// Prevent overshooting
moveStep = Mathf.Clamp(moveStep, -absOffset, absOffset);
float newX = currentX + moveStep;
newX = Mathf.Clamp(newX, GameManager.Instance.EndlessDescenderClampXMin, GameManager.Instance.EndlessDescenderClampXMax);
newX = Mathf.Clamp(newX, _settings.ClampXMin, _settings.ClampXMax);
UpdatePosition(newX);
}
@@ -111,21 +116,21 @@ namespace Minigames.DivingForPictures
else if (_tapImpulseStrength > 0)
{
float currentX = transform.position.x;
float maxOffset = GameManager.Instance.EndlessDescenderMaxOffset;
float lerpSpeed = GameManager.Instance.EndlessDescenderLerpSpeed;
float maxOffset = _settings.MaxOffset;
float lerpSpeed = _settings.LerpSpeed;
// Calculate move distance based on impulse strength
float moveDistance = maxOffset * _tapImpulseStrength * Time.deltaTime * lerpSpeed;
// Limit total movement from single tap
moveDistance = Mathf.Min(moveDistance, tapMaxDistance * _tapImpulseStrength);
moveDistance = Mathf.Min(moveDistance, _settings.TapMaxDistance * _tapImpulseStrength);
// Apply movement in tap direction
float newX = currentX + (moveDistance * _tapDirection);
newX = Mathf.Clamp(newX, GameManager.Instance.EndlessDescenderClampXMin, GameManager.Instance.EndlessDescenderClampXMax);
newX = Mathf.Clamp(newX, _settings.ClampXMin, _settings.ClampXMax);
// Reduce impulse strength over time
_tapImpulseStrength -= Time.deltaTime * tapDecelerationRate;
_tapImpulseStrength -= Time.deltaTime * _settings.TapDecelerationRate;
if (_tapImpulseStrength < 0.01f)
{
_tapImpulseStrength = 0f;