Strip debug logging from the game, fix screen weirdness

This commit is contained in:
Michal Pikulski
2025-10-14 15:53:58 +02:00
parent 18be597424
commit e8180b21bf
65 changed files with 768 additions and 411 deletions

View File

@@ -4,6 +4,7 @@ using AppleHills.Core.Settings;
using Pooling;
using Utils;
using AppleHills.Core.Interfaces;
using Core;
namespace Minigames.DivingForPictures
{
@@ -84,7 +85,7 @@ namespace Minigames.DivingForPictures
_settings = GameManager.GetSettingsObject<IDivingMinigameSettings>();
if (_settings == null)
{
Debug.LogWarning("[FloatingObstacle] Could not retrieve settings, using default values");
Logging.Warning("[FloatingObstacle] Could not retrieve settings, using default values");
_baseMoveSpeed = moveSpeed; // Use the serialized value as fallback
}
else
@@ -95,7 +96,7 @@ namespace Minigames.DivingForPictures
// For variety, randomly assign a speed between min and max
_baseMoveSpeed = Random.Range(minSpeed, maxSpeed);
Debug.Log($"[FloatingObstacle] Initialized with normalized speed: {_baseMoveSpeed} (range: {minSpeed}-{maxSpeed})");
Logging.Debug($"[FloatingObstacle] Initialized with normalized speed: {_baseMoveSpeed} (range: {minSpeed}-{maxSpeed})");
}
// Calculate screen normalization factor
@@ -117,7 +118,7 @@ namespace Minigames.DivingForPictures
// Calculate normalization factor based on screen height
_screenNormalizationFactor = Screen.height / referenceHeight;
Debug.Log($"[FloatingObstacle] Screen normalization factor: {_screenNormalizationFactor} (Screen height: {Screen.height}, Reference: {referenceHeight})");
Logging.Debug($"[FloatingObstacle] Screen normalization factor: {_screenNormalizationFactor} (Screen height: {Screen.height}, Reference: {referenceHeight})");
}
private void OnEnable()
@@ -147,7 +148,7 @@ namespace Minigames.DivingForPictures
_isPaused = true;
StopObstacleCoroutines();
Debug.Log($"[FloatingObstacle] Paused obstacle: {name}");
Logging.Debug($"[FloatingObstacle] Paused obstacle: {name}");
}
/// <summary>
@@ -160,7 +161,7 @@ namespace Minigames.DivingForPictures
_isPaused = false;
StartObstacleCoroutines();
Debug.Log($"[FloatingObstacle] Resumed obstacle: {name}");
Logging.Debug($"[FloatingObstacle] Resumed obstacle: {name}");
}
/// <summary>
@@ -221,7 +222,7 @@ namespace Minigames.DivingForPictures
_movementCoroutine = StartCoroutine(MovementCoroutine());
}
Debug.Log($"[FloatingObstacle] {gameObject.name} velocity factor updated to {_velocityFactor:F2}, normalized speed: {moveSpeed:F2}");
Logging.Debug($"[FloatingObstacle] {gameObject.name} velocity factor updated to {_velocityFactor:F2}, normalized speed: {moveSpeed:F2}");
}
/// <summary>
@@ -229,7 +230,7 @@ namespace Minigames.DivingForPictures
/// </summary>
private IEnumerator MovementCoroutine()
{
Debug.Log($"[FloatingObstacle] Started movement coroutine with speed: {_baseMoveSpeed:F3}");
Logging.Debug($"[FloatingObstacle] Started movement coroutine with speed: {_baseMoveSpeed:F3}");
while (enabled && gameObject.activeInHierarchy)
{
@@ -273,7 +274,7 @@ namespace Minigames.DivingForPictures
if (_collider != null && _collider.enabled)
{
_collider.enabled = false;
Debug.Log($"[FloatingObstacle] Obstacle {gameObject.name} hit player - collider disabled");
Logging.Debug($"[FloatingObstacle] Obstacle {gameObject.name} hit player - collider disabled");
}
}
@@ -299,12 +300,12 @@ namespace Minigames.DivingForPictures
// Use a larger buffer to ensure obstacles are truly off-screen before returning to pool
if (transform.position.y > _screenTop + 5f)
{
Debug.Log($"[FloatingObstacle] {gameObject.name} off-screen at Y:{transform.position.y:F2}, screen top:{_screenTop:F2}");
Logging.Debug($"[FloatingObstacle] {gameObject.name} off-screen at Y:{transform.position.y:F2}, screen top:{_screenTop:F2}");
ReturnToPool();
}
else if (transform.position.y < _screenBottom - 5f) // Added check for bottom screen edge
{
Debug.Log($"[FloatingObstacle] {gameObject.name} below screen at Y:{transform.position.y:F2}, screen bottom:{_screenBottom:F2}");
Logging.Debug($"[FloatingObstacle] {gameObject.name} below screen at Y:{transform.position.y:F2}, screen bottom:{_screenBottom:F2}");
ReturnToPool();
}
}
@@ -328,14 +329,14 @@ namespace Minigames.DivingForPictures
ObstacleSpawner foundSpawner = FindFirstObjectByType<ObstacleSpawner>();
if (foundSpawner != null)
{
Debug.LogWarning($"[FloatingObstacle] Obstacle {gameObject.name} lost spawner reference, found replacement spawner");
Logging.Warning($"[FloatingObstacle] Obstacle {gameObject.name} lost spawner reference, found replacement spawner");
spawner = foundSpawner;
spawner.ReturnObstacleToPool(gameObject, prefabIndex);
}
else
{
// No spawner found - just deactivate the object instead of destroying it
Debug.LogWarning($"[FloatingObstacle] No spawner found for {gameObject.name}, deactivating safely");
Logging.Warning($"[FloatingObstacle] No spawner found for {gameObject.name}, deactivating safely");
gameObject.SetActive(false);
// Move to a safe location to avoid interference
@@ -368,7 +369,7 @@ namespace Minigames.DivingForPictures
_collider.enabled = true;
}
Debug.Log($"[FloatingObstacle] Obstacle {gameObject.name} spawned from pool");
Logging.Debug($"[FloatingObstacle] Obstacle {gameObject.name} spawned from pool");
// Note: Don't start coroutines here - OnEnable() will handle that when SetActive(true) is called
}
@@ -387,7 +388,7 @@ namespace Minigames.DivingForPictures
_collider.enabled = true;
}
Debug.Log($"[FloatingObstacle] Obstacle {gameObject.name} despawned to pool");
Logging.Debug($"[FloatingObstacle] Obstacle {gameObject.name} despawned to pool");
}
/// <summary>
@@ -427,7 +428,7 @@ namespace Minigames.DivingForPictures
// Reverse movement speed (already handled by ObstacleSpawner, but this ensures consistency)
moveSpeed *= -1;
Debug.Log($"[FloatingObstacle] {gameObject.name} started surfacing with speed: {moveSpeed}");
Logging.Debug($"[FloatingObstacle] {gameObject.name} started surfacing with speed: {moveSpeed}");
}
}
}