IMplement basic Developer Settings

This commit is contained in:
2025-09-24 12:21:21 +02:00
parent f07ce88331
commit 8b96a5d0c3
18 changed files with 739 additions and 248 deletions

View File

@@ -33,7 +33,9 @@ public class GameManager : MonoBehaviour
[Header("Settings Status")]
[SerializeField] private bool _settingsLoaded = false;
[SerializeField] private bool _developerSettingsLoaded = false;
public bool SettingsLoaded => _settingsLoaded;
public bool DeveloperSettingsLoaded => _developerSettingsLoaded;
void Awake()
{
@@ -42,8 +44,12 @@ public class GameManager : MonoBehaviour
// Create settings provider if it doesn't exist
SettingsProvider.Instance.gameObject.name = "Settings Provider";
// Create developer settings provider if it doesn't exist
DeveloperSettingsProvider.Instance.gameObject.name = "Developer Settings Provider";
// Load all settings synchronously during Awake
InitializeSettings();
InitializeDeveloperSettings();
// DontDestroyOnLoad(gameObject);
}
@@ -55,7 +61,7 @@ public class GameManager : MonoBehaviour
// Load settings synchronously
var playerSettings = SettingsProvider.Instance.LoadSettingsSynchronous<PlayerFollowerSettings>();
var interactionSettings = SettingsProvider.Instance.LoadSettingsSynchronous<InteractionSettings>();
var minigameSettings = SettingsProvider.Instance.LoadSettingsSynchronous<MinigameSettings>();
var minigameSettings = SettingsProvider.Instance.LoadSettingsSynchronous<DivingMinigameSettings>();
// Register settings with service locator
if (playerSettings != null)
@@ -80,7 +86,7 @@ public class GameManager : MonoBehaviour
if (minigameSettings != null)
{
ServiceLocator.Register<IMinigameSettings>(minigameSettings);
ServiceLocator.Register<IDivingMinigameSettings>(minigameSettings);
Debug.Log("MinigameSettings registered successfully");
}
else
@@ -100,6 +106,28 @@ public class GameManager : MonoBehaviour
}
}
/// <summary>
/// Check for and initialize developer settings.
/// </summary>
private void InitializeDeveloperSettings()
{
Debug.Log("Starting developer settings initialization...");
// Load developer settings
var divingDevSettings = DeveloperSettingsProvider.Instance.GetSettings<DivingDeveloperSettings>();
_developerSettingsLoaded = divingDevSettings != null;
if (_developerSettingsLoaded)
{
Debug.Log("All developer settings loaded successfully");
}
else
{
Debug.LogWarning("Some developer settings failed to load");
}
}
void OnApplicationQuit()
{
_isQuitting = true;
@@ -112,6 +140,26 @@ public class GameManager : MonoBehaviour
return ServiceLocator.Get<T>();
}
/// <summary>
/// Returns the entire settings object of specified type.
/// </summary>
/// <typeparam name="T">Type of settings to retrieve</typeparam>
/// <returns>The settings object or null if not found</returns>
public static T GetSettingsObject<T>() where T : class
{
return Instance?.GetSettings<T>();
}
/// <summary>
/// Returns the developer settings object of specified type.
/// </summary>
/// <typeparam name="T">Type of developer settings to retrieve</typeparam>
/// <returns>The developer settings object or null if not found</returns>
public static T GetDeveloperSettings<T>() where T : BaseDeveloperSettings
{
return DeveloperSettingsProvider.Instance?.GetSettings<T>();
}
// PLAYER & FOLLOWER SETTINGS
// Player settings
@@ -178,9 +226,18 @@ public class GameManager : MonoBehaviour
// MINIGAME SETTINGS
// Endless Descender settings
public float EndlessDescenderLerpSpeed => GetSettings<IMinigameSettings>()?.EndlessDescenderLerpSpeed ?? 12f;
public float EndlessDescenderMaxOffset => GetSettings<IMinigameSettings>()?.EndlessDescenderMaxOffset ?? 3f;
public float EndlessDescenderClampXMin => GetSettings<IMinigameSettings>()?.EndlessDescenderClampXMin ?? -3.5f;
public float EndlessDescenderClampXMax => GetSettings<IMinigameSettings>()?.EndlessDescenderClampXMax ?? 3.5f;
public float EndlessDescenderSpeedExponent => GetSettings<IMinigameSettings>()?.EndlessDescenderSpeedExponent ?? 2.5f;
public float EndlessDescenderLerpSpeed => GetSettings<IDivingMinigameSettings>()?.EndlessDescenderLerpSpeed ?? 12f;
public float EndlessDescenderMaxOffset => GetSettings<IDivingMinigameSettings>()?.EndlessDescenderMaxOffset ?? 3f;
public float EndlessDescenderClampXMin => GetSettings<IDivingMinigameSettings>()?.EndlessDescenderClampXMin ?? -3.5f;
public float EndlessDescenderClampXMax => GetSettings<IDivingMinigameSettings>()?.EndlessDescenderClampXMax ?? 3.5f;
public float EndlessDescenderSpeedExponent => GetSettings<IDivingMinigameSettings>()?.EndlessDescenderSpeedExponent ?? 2.5f;
public float EndlessDescenderTapMaxDistance => GetSettings<IDivingMinigameSettings>()?.EndlessDescenderTapMaxDistance ?? 0.5f;
public float EndlessDescenderTapDecelerationRate => GetSettings<IDivingMinigameSettings>()?.EndlessDescenderTapDecelerationRate ?? 5.0f;
public int EndlessDescenderInitialTileCount => GetSettings<IDivingMinigameSettings>()?.EndlessDescenderInitialTileCount ?? 3;
public float EndlessDescenderTileSpawnBuffer => GetSettings<IDivingMinigameSettings>()?.EndlessDescenderTileSpawnBuffer ?? 1f;
public float EndlessDescenderMoveSpeed => GetSettings<IDivingMinigameSettings>()?.EndlessDescenderMoveSpeed ?? 3f;
public float EndlessDescenderSpeedUpFactor => GetSettings<IDivingMinigameSettings>()?.EndlessDescenderSpeedUpFactor ?? 0.2f;
public float EndlessDescenderSpeedUpInterval => GetSettings<IDivingMinigameSettings>()?.EndlessDescenderSpeedUpInterval ?? 10f;
public float EndlessDescenderMaxMoveSpeed => GetSettings<IDivingMinigameSettings>()?.EndlessDescenderMaxMoveSpeed ?? 12f;
public float EndlessDescenderVelocityCalculationInterval => GetSettings<IDivingMinigameSettings>()?.EndlessDescenderVelocityCalculationInterval ?? 0.5f;
}