diff --git a/Assets/Editor/Settings/EditorSettingsProvider.cs b/Assets/Editor/Settings/EditorSettingsProvider.cs index 8237ec7b..356955b9 100644 --- a/Assets/Editor/Settings/EditorSettingsProvider.cs +++ b/Assets/Editor/Settings/EditorSettingsProvider.cs @@ -1,8 +1,6 @@ using UnityEditor; using AppleHills.Core.Settings; using Core; -using UnityEngine; -using UnityEngine.Rendering.VirtualTexturing; namespace AppleHills.Editor { @@ -65,7 +63,7 @@ namespace AppleHills.Editor GetPuzzlePromptRange ); - LogDebugMessage("Editor settings loaded for Scene View use"); + Logging.Debug("Editor settings loaded for Scene View use"); } public static void RefreshSceneViews() @@ -102,14 +100,5 @@ namespace AppleHills.Editor return null; } - - private static void LogDebugMessage(string message) - { - if (Application.isPlaying && - DeveloperSettingsProvider.Instance.GetSettings().settingsLogVerbosity <= LogVerbosity.Debug) - { - Logging.Debug($"[EditorSettingsProvider] {message}"); - } - } } } diff --git a/Assets/Scripts/Bootstrap/BootSceneController.cs b/Assets/Scripts/Bootstrap/BootSceneController.cs index 416bfa40..6878413e 100644 --- a/Assets/Scripts/Bootstrap/BootSceneController.cs +++ b/Assets/Scripts/Bootstrap/BootSceneController.cs @@ -35,7 +35,7 @@ namespace Bootstrap internal override void OnManagedAwake() { - LogDebugMessage("BootSceneController.Awake() - Initializing loading screen DURING bootstrap"); + Logging.Debug("BootSceneController.Awake() - Initializing loading screen DURING bootstrap"); // Validate loading screen exists if (initialLoadingScreen == null) @@ -71,7 +71,7 @@ namespace Bootstrap internal override void OnManagedStart() { - LogDebugMessage("BootSceneController.OnManagedStart() - Boot is GUARANTEED complete, starting scene loading"); + Logging.Debug("BootSceneController.OnManagedStart() - Boot is GUARANTEED complete, starting scene loading"); // Boot is GUARANTEED complete at this point - that's the whole point of OnManagedStart! // No need to subscribe to OnBootCompleted or check CustomBoot.Initialised @@ -100,12 +100,12 @@ namespace Bootstrap /// private void OnInitialLoadingComplete() { - LogDebugMessage("Initial loading screen fully hidden, boot sequence completed"); + Logging.Debug("Initial loading screen fully hidden, boot sequence completed"); // Play the intro cinematic if available if (CinematicsManager.Instance != null) { - LogDebugMessage("Attempting to play intro cinematic"); + Logging.Debug("Attempting to play intro cinematic"); // Use LoadAndPlayCinematic to play the intro sequence CinematicsManager.Instance.LoadAndPlayCinematic("IntroSequence", false); @@ -147,13 +147,13 @@ namespace Bootstrap { if (debugMode) { - LogDebugMessage($"Bootstrap progress: {progress:P0}, Combined: {GetCombinedProgress():P0}"); + Logging.Debug($"Bootstrap progress: {progress:P0}, Combined: {GetCombinedProgress():P0}"); } } private void LogDebugInfo() { - LogDebugMessage($"Debug - Phase: {_currentPhase}, Bootstrap: {CustomBoot.CurrentProgress:P0}, " + + Logging.Debug($"Debug - Phase: {_currentPhase}, Bootstrap: {CustomBoot.CurrentProgress:P0}, " + $"Scene: {_sceneLoadingProgress:P0}, Combined: {GetCombinedProgress():P0}, Boot Complete: {_bootComplete}"); } @@ -170,7 +170,7 @@ namespace Bootstrap private async void LoadMainScene() { - LogDebugMessage($"Loading main menu scene: {mainSceneName}"); + Logging.Debug($"Loading main menu scene: {mainSceneName}"); try { @@ -184,7 +184,7 @@ namespace Bootstrap if (debugMode) { - LogDebugMessage($"Scene loading raw: {value:P0}, Combined: {GetCombinedProgress():P0}"); + Logging.Debug($"Scene loading raw: {value:P0}, Combined: {GetCombinedProgress():P0}"); } }); @@ -208,13 +208,13 @@ namespace Bootstrap _sceneLoadingProgress = 1f; // CRITICAL: Broadcast lifecycle events so components get their OnSceneReady callbacks - LogDebugMessage($"Broadcasting OnSceneReady for: {mainSceneName}"); + Logging.Debug($"Broadcasting OnSceneReady for: {mainSceneName}"); LifecycleManager.Instance?.BroadcastSceneReady(mainSceneName); // Restore scene data for the main menu if (SaveLoadManager.Instance != null) { - LogDebugMessage($"Restoring scene data for: {mainSceneName}"); + Logging.Debug($"Restoring scene data for: {mainSceneName}"); SaveLoadManager.Instance.RestoreSceneData(); } @@ -244,7 +244,7 @@ namespace Bootstrap Scene currentScene = SceneManager.GetActiveScene(); string startingSceneName = currentScene.name; - LogDebugMessage($"Unloading StartingScene: {startingSceneName}"); + Logging.Debug($"Unloading StartingScene: {startingSceneName}"); // Unload the StartingScene await SceneManager.UnloadSceneAsync(startingSceneName); @@ -253,14 +253,14 @@ namespace Bootstrap Scene mainMenuScene = SceneManager.GetSceneByName(mainSceneName); SceneManager.SetActiveScene(mainMenuScene); - LogDebugMessage($"Transition complete: {startingSceneName} unloaded, {mainSceneName} is now active"); + Logging.Debug($"Transition complete: {startingSceneName} unloaded, {mainSceneName} is now active"); // Destroy the boot scene controller since its job is done Destroy(gameObject); } catch (Exception e) { - Logging.Warning($"[BootSceneController] Error unloading StartingScene: {e.Message}"); + Logging.Warning($"Error unloading StartingScene: {e.Message}"); } } @@ -281,13 +281,5 @@ namespace Bootstrap _progressAction?.Invoke(value); } } - - private void LogDebugMessage(string message) - { - if ( _logVerbosity <= LogVerbosity.Debug) - { - Logging.Debug($"[BootSceneController] {message}"); - } - } } } diff --git a/Assets/Scripts/Bootstrap/CustomBoot.cs b/Assets/Scripts/Bootstrap/CustomBoot.cs index d669916f..456b75d8 100644 --- a/Assets/Scripts/Bootstrap/CustomBoot.cs +++ b/Assets/Scripts/Bootstrap/CustomBoot.cs @@ -1,6 +1,5 @@ using System; using System.Threading.Tasks; -using AppleHills.Core.Settings; using Core; using Core.Lifecycle; using UnityEngine; @@ -105,7 +104,7 @@ namespace Bootstrap // Notify the LifecycleManager that boot is complete if (Application.isPlaying) { - LogDebugMessage("Calling LifecycleManager.OnBootCompletionTriggered()"); + Logging.Debug("Calling LifecycleManager.OnBootCompletionTriggered()"); if (LifecycleManager.Instance != null) { LifecycleManager.Instance.OnBootCompletionTriggered(); @@ -127,7 +126,7 @@ namespace Bootstrap // Notify the LifecycleManager that boot is complete if (Application.isPlaying) { - LogDebugMessage("Calling LifecycleManager.OnBootCompletionTriggered()"); + Logging.Debug("Calling LifecycleManager.OnBootCompletionTriggered()"); if (LifecycleManager.Instance != null) { LifecycleManager.Instance.OnBootCompletionTriggered(); @@ -238,16 +237,7 @@ namespace Bootstrap { CurrentProgress = Mathf.Clamp01(progress); OnBootProgressChanged?.Invoke(CurrentProgress); - LogDebugMessage($"Progress: {CurrentProgress:P0}"); - } - - private static void LogDebugMessage(string message) - { - if (DeveloperSettingsProvider.Instance.GetSettings().bootstrapLogVerbosity <= - LogVerbosity.Debug) - { - Logging.Debug($"[CustomBoot] {message}"); - } + Logging.Debug($"Progress: {CurrentProgress:P0}"); } } } \ No newline at end of file diff --git a/Assets/Scripts/Bootstrap/InitialLoadingScreen.cs b/Assets/Scripts/Bootstrap/InitialLoadingScreen.cs index 1c7430ef..a93404e6 100644 --- a/Assets/Scripts/Bootstrap/InitialLoadingScreen.cs +++ b/Assets/Scripts/Bootstrap/InitialLoadingScreen.cs @@ -138,7 +138,7 @@ namespace Bootstrap float displayProgress = Mathf.Min(steadyProgress, actualProgress); // Log the progress values for debugging - LogDebugMessage($"Progress - Default: {steadyProgress:F2}, Actual: {actualProgress:F2}, Display: {displayProgress:F2}"); + Logging.Debug($"Progress - Default: {steadyProgress:F2}, Actual: {actualProgress:F2}, Display: {displayProgress:F2}"); // Directly set the progress bar fill amount without smoothing if (progressBarImage != null) @@ -151,7 +151,7 @@ namespace Bootstrap if (steadyProgress >= 1.0f && displayProgress >= 1.0f) { _animationComplete = true; - LogDebugMessage("Animation complete"); + Logging.Debug("Animation complete"); break; } @@ -163,7 +163,7 @@ namespace Bootstrap if (progressBarImage != null) { progressBarImage.fillAmount = 1.0f; - LogDebugMessage("Final progress set to 1.0"); + Logging.Debug("Final progress set to 1.0"); } // Hide the screen if loading is also complete @@ -172,7 +172,7 @@ namespace Bootstrap if (loadingScreenContainer != null) { loadingScreenContainer.SetActive(false); - LogDebugMessage("Animation AND loading complete, hiding screen"); + Logging.Debug("Animation AND loading complete, hiding screen"); // Invoke the callback when fully hidden _onLoadingScreenFullyHidden?.Invoke(); @@ -189,7 +189,7 @@ namespace Bootstrap /// public void HideLoadingScreen() { - LogDebugMessage("Loading complete, marking loading as finished"); + Logging.Debug("Loading complete, marking loading as finished"); // Mark that loading is complete _loadingComplete = true; @@ -200,7 +200,7 @@ namespace Bootstrap if (loadingScreenContainer != null) { loadingScreenContainer.SetActive(false); - LogDebugMessage("Animation already complete, hiding screen immediately"); + Logging.Debug("Animation already complete, hiding screen immediately"); // Invoke the callback when fully hidden _onLoadingScreenFullyHidden?.Invoke(); @@ -210,7 +210,7 @@ namespace Bootstrap } else { - LogDebugMessage("Animation still in progress, waiting for it to complete"); + Logging.Debug("Animation still in progress, waiting for it to complete"); // The coroutine will handle hiding when animation completes } } @@ -244,13 +244,5 @@ namespace Bootstrap return tcs.Task; } - - private void LogDebugMessage(string message) - { - if ( _logVerbosity <= LogVerbosity.Debug) - { - Logging.Debug($"[InitialLoadingScreen] {message}"); - } - } } } diff --git a/Assets/Scripts/Core/GameManager.cs b/Assets/Scripts/Core/GameManager.cs index 7e1e7fa7..686c46e1 100644 --- a/Assets/Scripts/Core/GameManager.cs +++ b/Assets/Scripts/Core/GameManager.cs @@ -77,7 +77,7 @@ namespace Core component.Pause(); } - LogDebugMessage($"Registered pausable component: {(component as MonoBehaviour)?.name ?? "Unknown"}"); + Logging.Debug($"Registered pausable component: {(component as MonoBehaviour)?.name ?? "Unknown"}"); } } @@ -90,7 +90,7 @@ namespace Core if (component != null && _pausableComponents.Contains(component)) { _pausableComponents.Remove(component); - LogDebugMessage($"Unregistered pausable component: {(component as MonoBehaviour)?.name ?? "Unknown"}"); + Logging.Debug($"Unregistered pausable component: {(component as MonoBehaviour)?.name ?? "Unknown"}"); } } @@ -106,7 +106,7 @@ namespace Core ApplyPause(true); } - LogDebugMessage($"Pause requested by {requester?.ToString() ?? "Unknown"}. pauseCount = {_pauseCount}"); + Logging.Debug($"Pause requested by {requester?.ToString() ?? "Unknown"}. pauseCount = {_pauseCount}"); } /// @@ -121,7 +121,7 @@ namespace Core ApplyPause(false); } - LogDebugMessage($"Pause released by {requester?.ToString() ?? "Unknown"}. pauseCount = {_pauseCount}"); + Logging.Debug($"Pause released by {requester?.ToString() ?? "Unknown"}. pauseCount = {_pauseCount}"); } /// @@ -160,12 +160,12 @@ namespace Core OnGameResumed?.Invoke(); } - LogDebugMessage($"Game {(shouldPause ? "paused" : "resumed")}. Paused {_pausableComponents.Count} components."); + Logging.Debug($"Game {(shouldPause ? "paused" : "resumed")}. Paused {_pausableComponents.Count} components."); } private void InitializeSettings() { - LogDebugMessage("Starting settings initialization...", "SettingsInitialization", _settingsLogVerbosity); + Logging.Debug("Starting settings initialization..."); // Load settings synchronously var playerSettings = SettingsProvider.Instance.LoadSettingsSynchronous(); @@ -176,7 +176,7 @@ namespace Core if (playerSettings != null) { ServiceLocator.Register(playerSettings); - LogDebugMessage("PlayerFollowerSettings registered successfully", "SettingsInitialization", _settingsLogVerbosity); + Logging.Debug("PlayerFollowerSettings registered successfully"); } else { @@ -186,7 +186,7 @@ namespace Core if (interactionSettings != null) { ServiceLocator.Register(interactionSettings); - LogDebugMessage("InteractionSettings registered successfully", "SettingsInitialization", _settingsLogVerbosity); + Logging.Debug("InteractionSettings registered successfully"); } else { @@ -196,7 +196,7 @@ namespace Core if (minigameSettings != null) { ServiceLocator.Register(minigameSettings); - LogDebugMessage("MinigameSettings registered successfully", "SettingsInitialization", _settingsLogVerbosity); + Logging.Debug("MinigameSettings registered successfully"); } else { @@ -207,7 +207,7 @@ namespace Core _settingsLoaded = playerSettings != null && interactionSettings != null && minigameSettings != null; if (_settingsLoaded) { - LogDebugMessage("All settings loaded and registered with ServiceLocator", "SettingsInitialization", _settingsLogVerbosity); + Logging.Debug("All settings loaded and registered with ServiceLocator"); } else { @@ -220,7 +220,7 @@ namespace Core /// private void InitializeDeveloperSettings() { - LogDebugMessage("Starting developer settings initialization...", "SettingsInitialization", _settingsLogVerbosity); + Logging.Debug("Starting developer settings initialization..."); // Load developer settings var divingDevSettings = DeveloperSettingsProvider.Instance.GetSettings(); @@ -230,7 +230,7 @@ namespace Core if (_developerSettingsLoaded) { - LogDebugMessage("All developer settings loaded successfully", "SettingsInitialization", _settingsLogVerbosity); + Logging.Debug("All developer settings loaded successfully"); } else { @@ -264,19 +264,6 @@ namespace Core { return DeveloperSettingsProvider.Instance?.GetSettings(); } - - 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()?.PlayerStopDistance ?? 6.0f; diff --git a/Assets/Scripts/Core/SceneManagerService.cs b/Assets/Scripts/Core/SceneManagerService.cs index 47aa8a02..028f67bb 100644 --- a/Assets/Scripts/Core/SceneManagerService.cs +++ b/Assets/Scripts/Core/SceneManagerService.cs @@ -73,7 +73,7 @@ namespace Core // Load verbosity settings _logVerbosity = DeveloperSettingsProvider.Instance.GetSettings().sceneLogVerbosity; - LogDebugMessage($"SceneManagerService initialized, current scene is: {CurrentGameplayScene}"); + Logging.Debug($"SceneManagerService initialized, current scene is: {CurrentGameplayScene}"); } /// @@ -91,19 +91,19 @@ namespace Core if (activeScene.name != BootstrapSceneName) { CurrentGameplayScene = activeScene.name; - LogDebugMessage($"Initialized with current scene: {CurrentGameplayScene}"); + Logging.Debug($"Initialized with current scene: {CurrentGameplayScene}"); } // Otherwise default to MainMenu else { CurrentGameplayScene = "AppleHillsOverworld"; - LogDebugMessage($"Initialized with default scene: {CurrentGameplayScene}"); + Logging.Debug($"Initialized with default scene: {CurrentGameplayScene}"); } } else { CurrentGameplayScene = "AppleHillsOverworld"; - LogDebugMessage($"No valid active scene, defaulting to: {CurrentGameplayScene}"); + Logging.Debug($"No valid active scene, defaulting to: {CurrentGameplayScene}"); } } @@ -305,7 +305,7 @@ namespace Core } // PHASE 2: Broadcast scene unloading - notify components to cleanup - LogDebugMessage($"Broadcasting OnSceneUnloading for: {oldSceneName}"); + Logging.Debug($"Broadcasting OnSceneUnloading for: {oldSceneName}"); LifecycleManager.Instance?.BroadcastSceneUnloading(oldSceneName); // PHASE 3: Save scene-specific data via SaveLoadManager (unless skipSave is true) @@ -314,19 +314,19 @@ namespace Core var debugSettings = DeveloperSettingsProvider.Instance.GetSettings(); if (debugSettings.useSaveLoadSystem) { - LogDebugMessage($"Saving scene data for: {oldSceneName}"); + Logging.Debug($"Saving scene data for: {oldSceneName}"); SaveLoadManager.Instance.SaveSceneData(); } } else if (skipSave) { - LogDebugMessage($"Skipping save for: {oldSceneName} (skipSave=true)"); + Logging.Debug($"Skipping save for: {oldSceneName} (skipSave=true)"); } // PHASE 4: Clear PuzzleManager state before scene transition if (PuzzleS.PuzzleManager.Instance != null) { - LogDebugMessage($"Clearing puzzle state before scene transition"); + Logging.Debug($"Clearing puzzle state before scene transition"); PuzzleS.PuzzleManager.Instance.ClearPuzzleState(); } @@ -350,7 +350,7 @@ namespace Core } else { - Logging.Warning($"[SceneManagerService] Previous scene '{oldSceneName}' is not loaded, skipping unload."); + Logging.Warning($"Previous scene '{oldSceneName}' is not loaded, skipping unload."); } } @@ -362,7 +362,7 @@ namespace Core } // PHASE 8: Begin scene loading mode - enables priority-ordered component initialization - LogDebugMessage($"Beginning scene load for: {newSceneName}"); + Logging.Debug($"Beginning scene load for: {newSceneName}"); LifecycleManager.Instance?.BeginSceneLoad(newSceneName); // PHASE 9: Load new gameplay scene @@ -370,7 +370,7 @@ namespace Core CurrentGameplayScene = newSceneName; // PHASE 10: Broadcast scene ready - processes batched components in priority order, then calls OnSceneReady - LogDebugMessage($"Broadcasting OnSceneReady for: {newSceneName}"); + Logging.Debug($"Broadcasting OnSceneReady for: {newSceneName}"); LifecycleManager.Instance?.BroadcastSceneReady(newSceneName); // PHASE 11: Restore scene-specific data via SaveLoadManager @@ -379,14 +379,14 @@ namespace Core var debugSettings = DeveloperSettingsProvider.Instance.GetSettings(); if (debugSettings.useSaveLoadSystem) { - LogDebugMessage($"Restoring scene data for: {newSceneName}"); + Logging.Debug($"Restoring scene data for: {newSceneName}"); SaveLoadManager.Instance.RestoreSceneData(); } } else if (skipSave) { SaveLoadManager.Instance.RestoreSceneData(); - LogDebugMessage($"Skipping restore for: {newSceneName} (skipSave=true)"); + Logging.Debug($"Skipping restore for: {newSceneName} (skipSave=true)"); } // PHASE 12: Only hide the loading screen if autoHideLoadingScreen is true @@ -395,13 +395,5 @@ namespace Core _loadingScreen.HideLoadingScreen(); } } - - private void LogDebugMessage(string message) - { - if (_logVerbosity <= LogVerbosity.Debug) - { - Logging.Debug($"[SceneManagerService] {message}"); - } - } } } diff --git a/Assets/Scripts/Core/SceneOrientationEnforcer.cs b/Assets/Scripts/Core/SceneOrientationEnforcer.cs index bfe52f16..cebea931 100644 --- a/Assets/Scripts/Core/SceneOrientationEnforcer.cs +++ b/Assets/Scripts/Core/SceneOrientationEnforcer.cs @@ -29,7 +29,7 @@ namespace Core // Load verbosity settings early (GameManager sets up settings in its OnManagedAwake) _logVerbosity = DeveloperSettingsProvider.Instance.GetSettings().sceneLogVerbosity; - LogDebugMessage("Initialized"); + Logging.Debug("Initialized"); } internal override void OnManagedStart() @@ -71,7 +71,7 @@ namespace Core if (sceneName.ToLower().Contains("bootstrap")) { // Bootstrap being loaded additively, don't do anything - LogDebugMessage($"Detected bootstrapped scene: '{sceneName}'. Skipping orientation enforcement."); + Logging.Debug($"Detected bootstrapped scene: '{sceneName}'. Skipping orientation enforcement."); return; } @@ -81,23 +81,23 @@ namespace Core } else { - LogDebugMessage($"No orientationConfig assigned. Defaulting to Landscape for scene '{sceneName}'"); + Logging.Debug($"No orientationConfig assigned. Defaulting to Landscape for scene '{sceneName}'"); } switch (requirement) { case ScreenOrientationRequirement.Portrait: - LogDebugMessage($"Forcing Portrait for scene '{sceneName}'"); + Logging.Debug($"Forcing Portrait for scene '{sceneName}'"); StartCoroutine(ForcePortrait()); break; case ScreenOrientationRequirement.Landscape: - LogDebugMessage($"Forcing Landscape for scene '{sceneName}'"); + Logging.Debug($"Forcing Landscape for scene '{sceneName}'"); StartCoroutine(ForceLandscape()); break; case ScreenOrientationRequirement.NotApplicable: default: // Default to landscape when no specific requirement is found - LogDebugMessage($"No specific orientation for scene '{sceneName}'. Defaulting to Landscape"); + Logging.Debug($"No specific orientation for scene '{sceneName}'. Defaulting to Landscape"); StartCoroutine(ForceLandscape()); break; } @@ -125,12 +125,12 @@ namespace Core if (!currentlyLandscape) { // Lock it to portrait and allow the device to orient itself - LogDebugMessage($"Actually forcing Portrait from previous: {Screen.orientation}"); + Logging.Debug($"Actually forcing Portrait from previous: {Screen.orientation}"); Screen.orientation = ScreenOrientation.LandscapeRight; } else { - LogDebugMessage($"Skipping Landscape enforcement, device already in: {Screen.orientation}"); + Logging.Debug($"Skipping Landscape enforcement, device already in: {Screen.orientation}"); } yield return null; @@ -158,12 +158,12 @@ namespace Core if (!currentlyPortrait) { // Lock it to portrait and allow the device to orient itself - LogDebugMessage($"Actually forcing Portrait from previous: {Screen.orientation}"); + Logging.Debug($"Actually forcing Portrait from previous: {Screen.orientation}"); Screen.orientation = ScreenOrientation.PortraitUpsideDown; } else { - LogDebugMessage($"Skipping Portrait enforcement, device already in: {Screen.orientation}"); + Logging.Debug($"Skipping Portrait enforcement, device already in: {Screen.orientation}"); } yield return null; @@ -179,13 +179,5 @@ 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}"); - } - } } } diff --git a/Assets/Scripts/Core/Settings/ServiceLocator.cs b/Assets/Scripts/Core/Settings/ServiceLocator.cs index 9efcfbf9..bba61d56 100644 --- a/Assets/Scripts/Core/Settings/ServiceLocator.cs +++ b/Assets/Scripts/Core/Settings/ServiceLocator.cs @@ -1,7 +1,5 @@ using System; using System.Collections.Generic; -using AppleHills.Core.Settings; -using UnityEngine; namespace Core.Settings { @@ -21,7 +19,7 @@ namespace Core.Settings public static void Register(T service) where T : class { Services[typeof(T)] = service; - LogDebugMessage($"Service registered: {typeof(T).Name}"); + Logging.Debug($"Service registered: {typeof(T).Name}"); } /// @@ -36,7 +34,7 @@ namespace Core.Settings return service as T; } - Logging.Warning($"[ServiceLocator] Service of type {typeof(T).Name} not found!"); + Logging.Warning($"Service of type {typeof(T).Name} not found!"); return null; } @@ -46,16 +44,7 @@ namespace Core.Settings public static void Clear() { Services.Clear(); - LogDebugMessage("All services cleared"); - } - - private static void LogDebugMessage(string message) - { - if (DeveloperSettingsProvider.Instance.GetSettings().settingsLogVerbosity <= - LogVerbosity.Debug) - { - Logging.Debug($"[ServiceLocator] {message}"); - } + Logging.Debug("All services cleared"); } } } diff --git a/Assets/Scripts/Input/InputManager.cs b/Assets/Scripts/Input/InputManager.cs index 5f447cd0..dd830e99 100644 --- a/Assets/Scripts/Input/InputManager.cs +++ b/Assets/Scripts/Input/InputManager.cs @@ -102,7 +102,7 @@ namespace Input /// private void OnSceneLoadCompleted(string sceneName) { - LogDebugMessage($"Scene loaded: {sceneName}, restoring input mode"); + Logging.Debug($"Scene loaded: {sceneName}, restoring input mode"); SwitchInputOnSceneLoaded(sceneName); } @@ -180,24 +180,24 @@ namespace Input Vector2 screenPos = positionAction.ReadValue(); Vector3 worldPos = Camera.main.ScreenToWorldPoint(screenPos); Vector2 worldPos2D = new Vector2(worldPos.x, worldPos.y); - LogDebugMessage($"TapMove performed at {worldPos2D}"); + Logging.Debug($"TapMove performed at {worldPos2D}"); // First try to delegate to an override consumer if available if (TryDelegateToOverrideConsumer(screenPos, worldPos2D)) { - LogDebugMessage("Tap delegated to override consumer"); + Logging.Debug("Tap delegated to override consumer"); return; } // Then try to delegate to any ITouchInputConsumer (UI or world interactable) if (!TryDelegateToAnyInputConsumer(screenPos, worldPos2D)) { - LogDebugMessage("No input consumer found, forwarding tap to default consumer"); + Logging.Debug("No input consumer found, forwarding tap to default consumer"); defaultConsumer?.OnTap(worldPos2D); } else { - LogDebugMessage("Tap delegated to input consumer"); + Logging.Debug("Tap delegated to input consumer"); } } @@ -210,13 +210,13 @@ namespace Input Vector2 screenPos = positionAction.ReadValue(); Vector3 worldPos = Camera.main.ScreenToWorldPoint(screenPos); Vector2 worldPos2D = new Vector2(worldPos.x, worldPos.y); - LogDebugMessage($"HoldMove started at {worldPos2D}"); + Logging.Debug($"HoldMove started at {worldPos2D}"); // First check for override consumers if (_overrideConsumers.Count > 0) { _activeHoldConsumer = _overrideConsumers[_overrideConsumers.Count - 1]; - LogDebugMessage($"Hold delegated to override consumer: {_activeHoldConsumer}"); + Logging.Debug($"Hold delegated to override consumer: {_activeHoldConsumer}"); _activeHoldConsumer.OnHoldStart(worldPos2D); return; } @@ -236,7 +236,7 @@ namespace Input Vector2 screenPos = positionAction.ReadValue(); Vector3 worldPos = Camera.main.ScreenToWorldPoint(screenPos); Vector2 worldPos2D = new Vector2(worldPos.x, worldPos.y); - LogDebugMessage($"HoldMove canceled at {worldPos2D}"); + Logging.Debug($"HoldMove canceled at {worldPos2D}"); // Notify the active hold consumer that the hold has ended _activeHoldConsumer?.OnHoldEnd(worldPos2D); @@ -300,7 +300,7 @@ namespace Input } if (consumer != null) { - LogDebugMessage($"Delegating tap to UI consumer at {screenPos} (GameObject: {result.gameObject.name})"); + Logging.Debug($"Delegating tap to UI consumer at {screenPos} (GameObject: {result.gameObject.name})"); consumer.OnTap(screenPos); return true; } @@ -329,7 +329,7 @@ namespace Input } if (consumer != null) { - LogDebugMessage($"Delegating tap to consumer at {worldPos} (GameObject: {hitWithMask.gameObject.name})"); + Logging.Debug($"Delegating tap to consumer at {worldPos} (GameObject: {hitWithMask.gameObject.name})"); consumer.OnTap(worldPos); return true; } @@ -343,15 +343,15 @@ namespace Input var consumer = hit.GetComponent(); if (consumer != null) { - LogDebugMessage($"Delegating tap to consumer at {worldPos} (GameObject: {hit.gameObject.name})"); + Logging.Debug($"Delegating tap to consumer at {worldPos} (GameObject: {hit.gameObject.name})"); consumer.OnTap(worldPos); return true; } - LogDebugMessage($"Collider2D hit at {worldPos} (GameObject: {hit.gameObject.name}), but no ITouchInputConsumer found."); + Logging.Debug($"Collider2D hit at {worldPos} (GameObject: {hit.gameObject.name}), but no ITouchInputConsumer found."); } else { - LogDebugMessage($"No Collider2D found at {worldPos} for interactable delegation."); + Logging.Debug($"No Collider2D found at {worldPos} for interactable delegation."); } return false; } @@ -366,7 +366,7 @@ namespace Input return; _overrideConsumers.Add(consumer); - LogDebugMessage($"Override consumer registered: {consumer}"); + Logging.Debug($"Override consumer registered: {consumer}"); } /// @@ -384,7 +384,7 @@ namespace Input } _overrideConsumers.Remove(consumer); - LogDebugMessage($"Override consumer unregistered: {consumer}"); + Logging.Debug($"Override consumer unregistered: {consumer}"); } /// @@ -394,7 +394,7 @@ namespace Input { _activeHoldConsumer = null; _overrideConsumers.Clear(); - LogDebugMessage("All override consumers cleared."); + Logging.Debug("All override consumers cleared."); } /// @@ -407,17 +407,9 @@ namespace Input // Get the topmost override consumer (last registered) var consumer = _overrideConsumers[_overrideConsumers.Count - 1]; - LogDebugMessage($"Delegating tap to override consumer at {worldPos} (GameObject: {consumer})"); + Logging.Debug($"Delegating tap to override consumer at {worldPos} (GameObject: {consumer})"); consumer.OnTap(worldPos); return true; } - - private void LogDebugMessage(string message) - { - if (_logVerbosity <= LogVerbosity.Debug) - { - Logging.Debug($"[InputManager] {message}"); - } - } } } diff --git a/Assets/Scripts/Input/PlayerTouchController.cs b/Assets/Scripts/Input/PlayerTouchController.cs index a4790ff8..1f00618d 100644 --- a/Assets/Scripts/Input/PlayerTouchController.cs +++ b/Assets/Scripts/Input/PlayerTouchController.cs @@ -3,7 +3,6 @@ using Pathfinding; using AppleHills.Core.Settings; using Core; using Core.Lifecycle; -using Core.SaveLoad; namespace Input { @@ -103,7 +102,7 @@ namespace Input public void OnTap(Vector2 worldPosition) { InterruptMoveTo(); - LogDebugMessage($"OnTap at {worldPosition}"); + Logging.Debug($"OnTap at {worldPosition}"); if (aiPath != null) { aiPath.enabled = true; @@ -122,7 +121,7 @@ namespace Input public void OnHoldStart(Vector2 worldPosition) { InterruptMoveTo(); - LogDebugMessage($"OnHoldStart at {worldPosition}"); + Logging.Debug($"OnHoldStart at {worldPosition}"); lastHoldPosition = worldPosition; isHolding = true; if (_settings.DefaultHoldMovementMode == HoldMovementMode.Pathfinding && @@ -159,7 +158,7 @@ namespace Input /// public void OnHoldEnd(Vector2 worldPosition) { - LogDebugMessage($"OnHoldEnd at {worldPosition}"); + Logging.Debug($"OnHoldEnd at {worldPosition}"); isHolding = false; directMoveVelocity = Vector3.zero; if (aiPath != null && _settings.DefaultHoldMovementMode == @@ -335,13 +334,13 @@ namespace Input { _isMoving = true; OnMovementStarted?.Invoke(); - LogDebugMessage("Movement started"); + Logging.Debug("Movement started"); } else if (!isCurrentlyMoving && _isMoving) { _isMoving = false; OnMovementStopped?.Invoke(); - LogDebugMessage("Movement stopped"); + Logging.Debug("Movement stopped"); } } @@ -424,14 +423,6 @@ namespace Input OnArrivedAtTarget?.Invoke(); } } - - private void LogDebugMessage(string message) - { - if (_logVerbosity <= LogVerbosity.Debug) - { - Logging.Debug($"[PlayerTouchController] {message}"); - } - } #region Save/Load Lifecycle Hooks