Cleanup compile warnings, cleanup logs, spruce up level selection menu
This commit is contained in:
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using AppleHills.Core.Interfaces;
|
||||
using AppleHills.Core.Settings;
|
||||
using Bootstrap;
|
||||
using Core.Settings;
|
||||
using Input;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -26,7 +27,9 @@ namespace Core
|
||||
|
||||
// List of pausable components that have registered with the GameManager
|
||||
private List<IPausable> _pausableComponents = new List<IPausable>();
|
||||
|
||||
private LogVerbosity _settingsLogVerbosity = LogVerbosity.Warning;
|
||||
private LogVerbosity _managerLogVerbosity = LogVerbosity.Warning;
|
||||
|
||||
// Events for pause state changes
|
||||
public event Action OnGamePaused;
|
||||
public event Action OnGameResumed;
|
||||
@@ -48,7 +51,13 @@ namespace Core
|
||||
|
||||
// DontDestroyOnLoad(gameObject);
|
||||
}
|
||||
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_settingsLogVerbosity = DeveloperSettingsProvider.Instance.GetSettings<DebugSettings>().settingsLogVerbosity;
|
||||
_managerLogVerbosity = DeveloperSettingsProvider.Instance.GetSettings<DebugSettings>().gameManagerLogVerbosity;
|
||||
}
|
||||
|
||||
private void InitializePostBoot()
|
||||
{
|
||||
// For post-boot correct initialization order
|
||||
@@ -70,7 +79,7 @@ namespace Core
|
||||
component.Pause();
|
||||
}
|
||||
|
||||
Logging.Debug($"[GameManager] Registered pausable component: {(component as MonoBehaviour)?.name ?? "Unknown"}");
|
||||
LogDebugMessage($"Registered pausable component: {(component as MonoBehaviour)?.name ?? "Unknown"}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,7 +92,7 @@ namespace Core
|
||||
if (component != null && _pausableComponents.Contains(component))
|
||||
{
|
||||
_pausableComponents.Remove(component);
|
||||
Logging.Debug($"[GameManager] Unregistered pausable component: {(component as MonoBehaviour)?.name ?? "Unknown"}");
|
||||
LogDebugMessage($"Unregistered pausable component: {(component as MonoBehaviour)?.name ?? "Unknown"}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,7 +108,7 @@ namespace Core
|
||||
ApplyPause(true);
|
||||
}
|
||||
|
||||
Logging.Debug($"[GameManager] Pause requested by {requester?.ToString() ?? "Unknown"}. pauseCount = {_pauseCount}");
|
||||
LogDebugMessage($"Pause requested by {requester?.ToString() ?? "Unknown"}. pauseCount = {_pauseCount}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -114,7 +123,7 @@ namespace Core
|
||||
ApplyPause(false);
|
||||
}
|
||||
|
||||
Logging.Debug($"[GameManager] Pause released by {requester?.ToString() ?? "Unknown"}. pauseCount = {_pauseCount}");
|
||||
LogDebugMessage($"Pause released by {requester?.ToString() ?? "Unknown"}. pauseCount = {_pauseCount}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -153,12 +162,12 @@ namespace Core
|
||||
OnGameResumed?.Invoke();
|
||||
}
|
||||
|
||||
Logging.Debug($"[GameManager] Game {(shouldPause ? "paused" : "resumed")}. Paused {_pausableComponents.Count} components.");
|
||||
LogDebugMessage($"Game {(shouldPause ? "paused" : "resumed")}. Paused {_pausableComponents.Count} components.");
|
||||
}
|
||||
|
||||
private void InitializeSettings()
|
||||
{
|
||||
Logging.Debug("Starting settings initialization...");
|
||||
LogDebugMessage("Starting settings initialization...", "SettingsInitialization", _settingsLogVerbosity);
|
||||
|
||||
// Load settings synchronously
|
||||
var playerSettings = SettingsProvider.Instance.LoadSettingsSynchronous<PlayerFollowerSettings>();
|
||||
@@ -169,7 +178,7 @@ namespace Core
|
||||
if (playerSettings != null)
|
||||
{
|
||||
ServiceLocator.Register<IPlayerFollowerSettings>(playerSettings);
|
||||
Logging.Debug("PlayerFollowerSettings registered successfully");
|
||||
LogDebugMessage("PlayerFollowerSettings registered successfully", "SettingsInitialization", _settingsLogVerbosity);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -179,7 +188,7 @@ namespace Core
|
||||
if (interactionSettings != null)
|
||||
{
|
||||
ServiceLocator.Register<IInteractionSettings>(interactionSettings);
|
||||
Logging.Debug("InteractionSettings registered successfully");
|
||||
LogDebugMessage("InteractionSettings registered successfully", "SettingsInitialization", _settingsLogVerbosity);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -189,7 +198,7 @@ namespace Core
|
||||
if (minigameSettings != null)
|
||||
{
|
||||
ServiceLocator.Register<IDivingMinigameSettings>(minigameSettings);
|
||||
Logging.Debug("MinigameSettings registered successfully");
|
||||
LogDebugMessage("MinigameSettings registered successfully", "SettingsInitialization", _settingsLogVerbosity);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -200,7 +209,7 @@ namespace Core
|
||||
_settingsLoaded = playerSettings != null && interactionSettings != null && minigameSettings != null;
|
||||
if (_settingsLoaded)
|
||||
{
|
||||
Logging.Debug("All settings loaded and registered with ServiceLocator");
|
||||
LogDebugMessage("All settings loaded and registered with ServiceLocator", "SettingsInitialization", _settingsLogVerbosity);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -213,7 +222,7 @@ namespace Core
|
||||
/// </summary>
|
||||
private void InitializeDeveloperSettings()
|
||||
{
|
||||
Logging.Debug("Starting developer settings initialization...");
|
||||
LogDebugMessage("Starting developer settings initialization...", "SettingsInitialization", _settingsLogVerbosity);
|
||||
|
||||
// Load developer settings
|
||||
var divingDevSettings = DeveloperSettingsProvider.Instance.GetSettings<DivingDeveloperSettings>();
|
||||
@@ -223,7 +232,7 @@ namespace Core
|
||||
|
||||
if (_developerSettingsLoaded)
|
||||
{
|
||||
Logging.Debug("All developer settings loaded successfully");
|
||||
LogDebugMessage("All developer settings loaded successfully", "SettingsInitialization", _settingsLogVerbosity);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -258,6 +267,19 @@ namespace Core
|
||||
return DeveloperSettingsProvider.Instance?.GetSettings<T>();
|
||||
}
|
||||
|
||||
private void LogDebugMessage(string message, string prefix = "GameManager", LogVerbosity verbosity = LogVerbosity.None)
|
||||
{
|
||||
if (verbosity == LogVerbosity.None)
|
||||
{
|
||||
verbosity = _managerLogVerbosity;
|
||||
}
|
||||
|
||||
if ( verbosity <= LogVerbosity.Debug)
|
||||
{
|
||||
Logging.Debug($"[{prefix}] {message}");
|
||||
}
|
||||
}
|
||||
|
||||
// LEFTOVER LEGACY SETTINGS
|
||||
public float PlayerStopDistance => GetSettings<IInteractionSettings>()?.PlayerStopDistance ?? 6.0f;
|
||||
public float PlayerStopDistanceDirectInteraction => GetSettings<IInteractionSettings>()?.PlayerStopDistanceDirectInteraction ?? 2.0f;
|
||||
|
||||
@@ -13,7 +13,6 @@ namespace Core
|
||||
public class ItemManager : MonoBehaviour
|
||||
{
|
||||
private static ItemManager _instance;
|
||||
private static bool _isQuitting;
|
||||
|
||||
/// <summary>
|
||||
/// Singleton instance of the ItemManager. No longer creates an instance if one doesn't exist.
|
||||
@@ -73,11 +72,6 @@ namespace Core
|
||||
ClearAllRegistrations();
|
||||
}
|
||||
|
||||
void OnApplicationQuit()
|
||||
{
|
||||
_isQuitting = true;
|
||||
}
|
||||
|
||||
private void OnSceneLoadStarted(string sceneName)
|
||||
{
|
||||
// Clear all registrations when a new scene is loaded, so no stale references persist
|
||||
|
||||
@@ -16,17 +16,12 @@ namespace AppleHills.Core
|
||||
{
|
||||
#region Singleton Setup
|
||||
private static QuickAccess _instance;
|
||||
private static bool _isQuitting = false;
|
||||
|
||||
/// <summary>
|
||||
/// Singleton instance of QuickAccess. No longer creates an instance if one doesn't exist.
|
||||
/// </summary>
|
||||
public static QuickAccess Instance => _instance;
|
||||
|
||||
void OnApplicationQuit()
|
||||
{
|
||||
_isQuitting = true;
|
||||
}
|
||||
#endregion Singleton Setup
|
||||
|
||||
#region Manager Instances
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using AppleHills.Core.Settings;
|
||||
using UI;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
@@ -15,7 +16,6 @@ namespace Core
|
||||
{
|
||||
private LoadingScreenController _loadingScreen;
|
||||
private static SceneManagerService _instance;
|
||||
private static bool _isQuitting = false;
|
||||
|
||||
/// <summary>
|
||||
/// Singleton instance of the SceneManagerService. No longer creates an instance if one doesn't exist.
|
||||
@@ -32,6 +32,7 @@ namespace Core
|
||||
|
||||
private readonly Dictionary<string, AsyncOperation> _activeLoads = new();
|
||||
private readonly Dictionary<string, AsyncOperation> _activeUnloads = new();
|
||||
private LogVerbosity _logVerbosity = LogVerbosity.Debug;
|
||||
private const string BootstrapSceneName = "BootstrapScene";
|
||||
|
||||
void Awake()
|
||||
@@ -52,7 +53,12 @@ namespace Core
|
||||
SceneManager.LoadScene(BootstrapSceneName, LoadSceneMode.Additive);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_logVerbosity = DeveloperSettingsProvider.Instance.GetSettings<DebugSettings>().sceneLogVerbosity;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize current scene tracking immediately in Awake
|
||||
/// This ensures scene management works correctly regardless of boot timing
|
||||
@@ -68,19 +74,19 @@ namespace Core
|
||||
if (activeScene.name != BootstrapSceneName)
|
||||
{
|
||||
CurrentGameplayScene = activeScene.name;
|
||||
Logging.Debug($"[SceneManagerService] Initialized with current scene: {CurrentGameplayScene}");
|
||||
LogDebugMessage($"Initialized with current scene: {CurrentGameplayScene}");
|
||||
}
|
||||
// Otherwise default to MainMenu
|
||||
else
|
||||
{
|
||||
CurrentGameplayScene = "AppleHillsOverworld";
|
||||
Logging.Debug($"[SceneManagerService] Initialized with default scene: {CurrentGameplayScene}");
|
||||
LogDebugMessage($"Initialized with default scene: {CurrentGameplayScene}");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CurrentGameplayScene = "AppleHillsOverworld";
|
||||
Logging.Debug($"[SceneManagerService] No valid active scene, defaulting to: {CurrentGameplayScene}");
|
||||
LogDebugMessage($"No valid active scene, defaulting to: {CurrentGameplayScene}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,7 +98,7 @@ namespace Core
|
||||
// Set up loading screen event handlers if available
|
||||
SetupLoadingScreenEvents();
|
||||
|
||||
Logging.Debug($"[SceneManagerService] Post-boot initialization complete, current scene is: {CurrentGameplayScene}");
|
||||
LogDebugMessage($"Post-boot initialization complete, current scene is: {CurrentGameplayScene}");
|
||||
}
|
||||
|
||||
private void SetupLoadingScreenEvents()
|
||||
@@ -103,11 +109,6 @@ namespace Core
|
||||
SceneLoadCompleted += _ => _loadingScreen.HideLoadingScreen();
|
||||
}
|
||||
|
||||
void OnApplicationQuit()
|
||||
{
|
||||
_isQuitting = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Load a single scene asynchronously (additive).
|
||||
/// </summary>
|
||||
@@ -138,7 +139,7 @@ namespace Core
|
||||
var scene = SceneManager.GetSceneByName(sceneName);
|
||||
if (!scene.isLoaded)
|
||||
{
|
||||
Logging.Warning($"SceneManagerService: Attempted to unload scene '{sceneName}', but it is not loaded.");
|
||||
Logging.Warning($"[SceneManagerService] Attempted to unload scene '{sceneName}', but it is not loaded.");
|
||||
return;
|
||||
}
|
||||
SceneUnloadStarted?.Invoke(sceneName);
|
||||
@@ -317,7 +318,7 @@ namespace Core
|
||||
}
|
||||
else
|
||||
{
|
||||
Logging.Warning($"SceneManagerService: Previous scene '{CurrentGameplayScene}' is not loaded, skipping unload.");
|
||||
Logging.Warning($"[SceneManagerService] Previous scene '{CurrentGameplayScene}' is not loaded, skipping unload.");
|
||||
}
|
||||
}
|
||||
// Ensure BootstrapScene is loaded before loading new scene
|
||||
@@ -337,5 +338,13 @@ namespace Core
|
||||
_loadingScreen.HideLoadingScreen();
|
||||
}
|
||||
}
|
||||
|
||||
private void LogDebugMessage(string message)
|
||||
{
|
||||
if (_logVerbosity <= LogVerbosity.Debug)
|
||||
{
|
||||
Logging.Debug($"[SceneManagerService] {message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using AppleHills.Core.Settings;
|
||||
using Bootstrap;
|
||||
using Input;
|
||||
using Settings;
|
||||
@@ -17,6 +18,7 @@ namespace Core
|
||||
[Header("Config")]
|
||||
public SceneOrientationConfig orientationConfig;
|
||||
public GameObject orientationPromptPrefab;
|
||||
private LogVerbosity _logVerbosity = LogVerbosity.Warning;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
@@ -33,11 +35,16 @@ namespace Core
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_logVerbosity = DeveloperSettingsProvider.Instance.GetSettings<DebugSettings>().sceneLogVerbosity;
|
||||
}
|
||||
|
||||
private void InitializePostBoot()
|
||||
{
|
||||
// Initialize any dependencies that require other services to be ready
|
||||
Logging.Debug("[SceneOrientationEnforcer] Post-boot initialization complete");
|
||||
LogDebugMessage("Post-boot initialization complete");
|
||||
|
||||
// Subscribe to sceneLoaded event
|
||||
SceneManager.sceneLoaded += OnSceneLoaded;
|
||||
@@ -52,7 +59,7 @@ namespace Core
|
||||
if (sceneName.ToLower().Contains("bootstrap"))
|
||||
{
|
||||
// Bootstrap being loaded additively, don't do anything
|
||||
Logging.Debug($"[SceneOrientationEnforcer] Detected bootstrapped scene: '{sceneName}'. Skipping orientation enforcement.");
|
||||
LogDebugMessage($"Detected bootstrapped scene: '{sceneName}'. Skipping orientation enforcement.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -62,23 +69,23 @@ namespace Core
|
||||
}
|
||||
else
|
||||
{
|
||||
Logging.Debug($"[SceneOrientationEnforcer] No orientationConfig assigned. Defaulting to Landscape for scene '{sceneName}'");
|
||||
LogDebugMessage($"No orientationConfig assigned. Defaulting to Landscape for scene '{sceneName}'");
|
||||
}
|
||||
|
||||
switch (requirement)
|
||||
{
|
||||
case ScreenOrientationRequirement.Portrait:
|
||||
Logging.Debug($"[SceneOrientationEnforcer] Forcing Portrait for scene '{sceneName}'");
|
||||
LogDebugMessage($"Forcing Portrait for scene '{sceneName}'");
|
||||
StartCoroutine(ForcePortrait());
|
||||
break;
|
||||
case ScreenOrientationRequirement.Landscape:
|
||||
Logging.Debug($"[SceneOrientationEnforcer] Forcing Landscape for scene '{sceneName}'");
|
||||
LogDebugMessage($"Forcing Landscape for scene '{sceneName}'");
|
||||
StartCoroutine(ForceLandscape());
|
||||
break;
|
||||
case ScreenOrientationRequirement.NotApplicable:
|
||||
default:
|
||||
// Default to landscape when no specific requirement is found
|
||||
Logging.Debug($"[SceneOrientationEnforcer] No specific orientation for scene '{sceneName}'. Defaulting to Landscape");
|
||||
LogDebugMessage($"No specific orientation for scene '{sceneName}'. Defaulting to Landscape");
|
||||
StartCoroutine(ForceLandscape());
|
||||
break;
|
||||
}
|
||||
@@ -92,7 +99,7 @@ namespace Core
|
||||
/// <summary>
|
||||
/// Forces the game into landscape mode, allowing both LandscapeLeft and LandscapeRight.
|
||||
/// </summary>
|
||||
public static IEnumerator ForceLandscape()
|
||||
public IEnumerator ForceLandscape()
|
||||
{
|
||||
// If we're already in a landscape orientation, nothing to do.
|
||||
bool currentlyLandscape = Screen.orientation == ScreenOrientation.LandscapeLeft
|
||||
@@ -100,12 +107,12 @@ namespace Core
|
||||
if (!currentlyLandscape)
|
||||
{
|
||||
// Lock it to portrait and allow the device to orient itself
|
||||
Logging.Debug($"[SceneOrientationEnforcer] Actually forcing Portrait from previous: {Screen.orientation}");
|
||||
LogDebugMessage($"Actually forcing Portrait from previous: {Screen.orientation}");
|
||||
Screen.orientation = ScreenOrientation.LandscapeRight;
|
||||
}
|
||||
else
|
||||
{
|
||||
Logging.Debug($"[SceneOrientationEnforcer] Skipping Landscape enforcement, device already in: {Screen.orientation}");
|
||||
LogDebugMessage($"Skipping Landscape enforcement, device already in: {Screen.orientation}");
|
||||
}
|
||||
|
||||
yield return null;
|
||||
@@ -125,7 +132,7 @@ namespace Core
|
||||
/// <summary>
|
||||
/// Forces the game into portrait mode, allowing both Portrait and PortraitUpsideDown.
|
||||
/// </summary>
|
||||
public static IEnumerator ForcePortrait()
|
||||
public IEnumerator ForcePortrait()
|
||||
{
|
||||
// If we're already in a portrait orientation, nothing to do.
|
||||
bool currentlyPortrait = Screen.orientation == ScreenOrientation.Portrait
|
||||
@@ -133,12 +140,12 @@ namespace Core
|
||||
if (!currentlyPortrait)
|
||||
{
|
||||
// Lock it to portrait and allow the device to orient itself
|
||||
Logging.Debug($"[SceneOrientationEnforcer] Actually forcing Portrait from previous: {Screen.orientation}");
|
||||
LogDebugMessage($"Actually forcing Portrait from previous: {Screen.orientation}");
|
||||
Screen.orientation = ScreenOrientation.PortraitUpsideDown;
|
||||
}
|
||||
else
|
||||
{
|
||||
Logging.Debug($"[SceneOrientationEnforcer] Skipping Portrait enforcement, device already in: {Screen.orientation}");
|
||||
LogDebugMessage($"Skipping Portrait enforcement, device already in: {Screen.orientation}");
|
||||
}
|
||||
|
||||
yield return null;
|
||||
@@ -154,5 +161,13 @@ namespace Core
|
||||
// Allow device to auto-rotate to correct portrait orientation
|
||||
Screen.orientation = ScreenOrientation.AutoRotation;
|
||||
}
|
||||
|
||||
private void LogDebugMessage(string message)
|
||||
{
|
||||
if (_logVerbosity <= LogVerbosity.Debug)
|
||||
{
|
||||
Logging.Debug($"[SceneOrientationEnforcer] {message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,11 +7,10 @@ namespace AppleHills.Core.Settings
|
||||
/// </summary>
|
||||
public enum LogVerbosity
|
||||
{
|
||||
None = 0,
|
||||
Errors = 1,
|
||||
Warnings = 2,
|
||||
Info = 3,
|
||||
Verbose = 4
|
||||
None = -1,
|
||||
Debug = 0,
|
||||
Warning = 1,
|
||||
Error = 2
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -23,12 +22,26 @@ namespace AppleHills.Core.Settings
|
||||
{
|
||||
[Header("Visual Debugging Options")]
|
||||
[Tooltip("Should debug messages be show on screen in Editor")]
|
||||
[SerializeField] private bool showDebugUiMessages = false;
|
||||
[SerializeField] public bool showDebugUiMessages = false;
|
||||
|
||||
[Header("Game Behavior Options")]
|
||||
[Tooltip("Should Time.timeScale be set to 0 when the game is paused")]
|
||||
[SerializeField] private bool pauseTimeOnPauseGame = true;
|
||||
|
||||
[SerializeField] public bool pauseTimeOnPauseGame = true;
|
||||
|
||||
[Header("Logging Options")]
|
||||
[Tooltip("Logging level for bootstrap services")]
|
||||
[SerializeField] public LogVerbosity bootstrapLogVerbosity = LogVerbosity.Warning;
|
||||
[Tooltip("Logging level for settings-related services")]
|
||||
[SerializeField] public LogVerbosity settingsLogVerbosity = LogVerbosity.Warning;
|
||||
[Tooltip("Logging level for Game Manager")]
|
||||
[SerializeField] public LogVerbosity gameManagerLogVerbosity = LogVerbosity.Warning;
|
||||
[Tooltip("Logging level for Scene management services - orientation, loading etc.")]
|
||||
[SerializeField] public LogVerbosity sceneLogVerbosity = LogVerbosity.Warning;
|
||||
[Tooltip("Logging level for Scene Orientation Enforcer")]
|
||||
[SerializeField] public LogVerbosity saveLoadLogVerbosity = LogVerbosity.Warning;
|
||||
[Tooltip("Logging level for Input management services")]
|
||||
[SerializeField] public LogVerbosity inputLogVerbosity = LogVerbosity.Warning;
|
||||
|
||||
// Property getters
|
||||
public bool ShowDebugUiMessages => showDebugUiMessages;
|
||||
public bool PauseTimeOnPauseGame => pauseTimeOnPauseGame;
|
||||
|
||||
@@ -87,10 +87,6 @@ namespace AppleHills.Core.Settings
|
||||
[Tooltip("Maximum normalized movement speed allowed for tiles")]
|
||||
[SerializeField] private float maxNormalizedTileMoveSpeed = 1.2f;
|
||||
|
||||
// Legacy settings - keeping for backward compatibility
|
||||
[HideInInspector] [SerializeField] private float moveSpeed = 3f;
|
||||
[HideInInspector] [SerializeField] private float maxMoveSpeed = 12f;
|
||||
|
||||
[Tooltip("Interval for velocity calculations (seconds)")]
|
||||
[SerializeField] private float velocityCalculationInterval = 0.5f;
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Core;
|
||||
using AppleHills.Core.Settings;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AppleHills.Core.Settings
|
||||
namespace Core.Settings
|
||||
{
|
||||
/// <summary>
|
||||
/// Service Locator implementation for managing settings services.
|
||||
@@ -11,7 +11,7 @@ namespace AppleHills.Core.Settings
|
||||
/// </summary>
|
||||
public static class ServiceLocator
|
||||
{
|
||||
private static readonly Dictionary<Type, object> _services = new Dictionary<Type, object>();
|
||||
private static readonly Dictionary<Type, object> Services = new Dictionary<Type, object>();
|
||||
|
||||
/// <summary>
|
||||
/// Register a service with the service locator.
|
||||
@@ -20,8 +20,8 @@ namespace AppleHills.Core.Settings
|
||||
/// <param name="service">The service implementation</param>
|
||||
public static void Register<T>(T service) where T : class
|
||||
{
|
||||
_services[typeof(T)] = service;
|
||||
Logging.Debug($"Service registered: {typeof(T).Name}");
|
||||
Services[typeof(T)] = service;
|
||||
LogDebugMessage($"Service registered: {typeof(T).Name}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -31,12 +31,12 @@ namespace AppleHills.Core.Settings
|
||||
/// <returns>The service implementation, or null if not found</returns>
|
||||
public static T Get<T>() where T : class
|
||||
{
|
||||
if (_services.TryGetValue(typeof(T), out object service))
|
||||
if (Services.TryGetValue(typeof(T), out object service))
|
||||
{
|
||||
return service as T;
|
||||
}
|
||||
|
||||
Logging.Warning($"Service of type {typeof(T).Name} not found!");
|
||||
Logging.Warning($"[ServiceLocator] Service of type {typeof(T).Name} not found!");
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -45,8 +45,17 @@ namespace AppleHills.Core.Settings
|
||||
/// </summary>
|
||||
public static void Clear()
|
||||
{
|
||||
_services.Clear();
|
||||
Logging.Debug("All services cleared");
|
||||
Services.Clear();
|
||||
LogDebugMessage("All services cleared");
|
||||
}
|
||||
|
||||
private static void LogDebugMessage(string message)
|
||||
{
|
||||
if (DeveloperSettingsProvider.Instance.GetSettings<DebugSettings>().settingsLogVerbosity <=
|
||||
LogVerbosity.Debug)
|
||||
{
|
||||
Logging.Debug($"[ServiceLocator] {message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,6 +35,11 @@ namespace AppleHills
|
||||
public static float GetPlayerStopDistance()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
if (getPlayerStopDistanceProvider == null)
|
||||
{
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
if (!Application.isPlaying && getPlayerStopDistanceProvider != null)
|
||||
{
|
||||
return getPlayerStopDistanceProvider();
|
||||
|
||||
Reference in New Issue
Block a user