Files
AppleHillsProduction/Assets/Scripts/Core/SettingsAccess.cs
tschesky e60d516e7e Implement Fort Fight minigame (#75)
Co-authored-by: Michal Pikulski <michal.a.pikulski@gmail.com>
Reviewed-on: #75
2025-12-04 01:18:29 +00:00

95 lines
3.3 KiB
C#

using Core;
using UnityEngine;
namespace AppleHills
{
/// <summary>
/// Unified access to settings in both editor and play mode
/// </summary>
public static class SettingsAccess
{
// Delegate type for editor-only settings providers
public delegate float GetSettingsValueDelegate();
// Static delegates that will be set by editor code
private static GetSettingsValueDelegate getPlayerStopDistanceProvider;
private static GetSettingsValueDelegate getPlayerStopDistanceDirectInteractionProvider;
private static GetSettingsValueDelegate getPuzzlePromptRangeProvider;
private static GetSettingsValueDelegate getWeakPointExplosionRadiusProvider;
// Editor-only method to set up providers - will be called from editor code
public static void SetupEditorProviders(
GetSettingsValueDelegate playerStopDistanceProvider,
GetSettingsValueDelegate playerStopDistanceDirectInteractionProvider,
GetSettingsValueDelegate puzzlePromptRangeProvider,
GetSettingsValueDelegate weakPointExplosionRadiusProvider)
{
#if UNITY_EDITOR
if (!Application.isPlaying)
{
getPlayerStopDistanceProvider = playerStopDistanceProvider;
getPlayerStopDistanceDirectInteractionProvider = playerStopDistanceDirectInteractionProvider;
getPuzzlePromptRangeProvider = puzzlePromptRangeProvider;
getWeakPointExplosionRadiusProvider = weakPointExplosionRadiusProvider;
}
#endif
}
public static float GetPlayerStopDistance()
{
#if UNITY_EDITOR
if (getPlayerStopDistanceProvider == null)
{
return 0.0f;
}
if (!Application.isPlaying && getPlayerStopDistanceProvider != null)
{
return getPlayerStopDistanceProvider();
}
#endif
return GameManager.Instance.PlayerStopDistance;
}
public static float GetPlayerStopDistanceDirectInteraction()
{
#if UNITY_EDITOR
if (!Application.isPlaying && getPlayerStopDistanceDirectInteractionProvider != null)
{
return getPlayerStopDistanceDirectInteractionProvider();
}
#endif
return GameManager.Instance.PlayerStopDistanceDirectInteraction;
}
public static float GetPuzzlePromptRange()
{
#if UNITY_EDITOR
if (!Application.isPlaying && getPuzzlePromptRangeProvider != null)
{
return getPuzzlePromptRangeProvider();
}
#endif
return GameManager.Instance.DefaultPuzzlePromptRange;
}
// Fort Fight Settings
public static float GetWeakPointExplosionRadius()
{
#if UNITY_EDITOR
if (!Application.isPlaying && getWeakPointExplosionRadiusProvider != null)
{
return getWeakPointExplosionRadiusProvider();
}
#endif
return GameManager.Instance.WeakPointExplosionRadius;
}
// Add more methods as needed for other settings
}
}