Cleanup compile warnings, cleanup logs, spruce up level selection menu

This commit is contained in:
Michal Pikulski
2025-10-28 14:31:17 +01:00
parent a5b1a4f8a0
commit 43779c560e
67 changed files with 4814 additions and 1050 deletions

View File

@@ -28,7 +28,6 @@ namespace Input
private const string GameActions = "PlayerTouch";
private static InputManager _instance;
private static bool _isQuitting = false;
// Override consumer stack - using a list to support multiple overrides that can be removed in LIFO order
private readonly List<ITouchInputConsumer> _overrideConsumers = new List<ITouchInputConsumer>();
@@ -50,6 +49,7 @@ namespace Input
private InputAction positionAction;
private ITouchInputConsumer defaultConsumer;
private bool isHoldActive;
private LogVerbosity _logVerbosity = LogVerbosity.Warning;
void Awake()
{
@@ -58,7 +58,12 @@ namespace Input
// Register for post-boot initialization
BootCompletionService.RegisterInitAction(InitializePostBoot);
}
private void Start()
{
_logVerbosity = DeveloperSettingsProvider.Instance.GetSettings<DebugSettings>().inputLogVerbosity;
}
private void InitializePostBoot()
{
// Subscribe to scene load completed events now that boot is complete
@@ -86,8 +91,6 @@ namespace Input
}
SwitchInputOnSceneLoaded(SceneManager.GetActiveScene().name);
Logging.Debug("[InputManager] Subscribed to SceneManagerService events");
}
private void OnDestroy()
@@ -101,12 +104,10 @@ namespace Input
{
if (sceneName.ToLower().Contains("mainmenu"))
{
Logging.Debug("[InputManager] SwitchInputOnSceneLoaded - Setting InputMode to UI for MainMenu");
SetInputMode(InputMode.GameAndUI);
}
else
{
Logging.Debug("[InputManager] SwitchInputOnSceneLoaded - Setting InputMode to PlayerTouch");
SetInputMode(InputMode.GameAndUI);
}
}
@@ -144,11 +145,6 @@ namespace Input
holdMoveAction.canceled -= OnHoldMoveCanceled;
}
}
void OnApplicationQuit()
{
_isQuitting = true;
}
/// <summary>
/// Sets the default ITouchInputConsumer to receive input events.
@@ -166,24 +162,24 @@ namespace Input
Vector2 screenPos = positionAction.ReadValue<Vector2>();
Vector3 worldPos = Camera.main.ScreenToWorldPoint(screenPos);
Vector2 worldPos2D = new Vector2(worldPos.x, worldPos.y);
Logging.Debug($"[InputManager] TapMove performed at {worldPos2D}");
LogDebugMessage($"TapMove performed at {worldPos2D}");
// First try to delegate to an override consumer if available
if (TryDelegateToOverrideConsumer(screenPos, worldPos2D))
{
Logging.Debug("[InputManager] Tap delegated to override consumer");
LogDebugMessage("Tap delegated to override consumer");
return;
}
// Then try to delegate to any ITouchInputConsumer (UI or world interactable)
if (!TryDelegateToAnyInputConsumer(screenPos, worldPos2D))
{
Logging.Debug("[InputManager] No input consumer found, forwarding tap to default consumer");
LogDebugMessage("No input consumer found, forwarding tap to default consumer");
defaultConsumer?.OnTap(worldPos2D);
}
else
{
Logging.Debug("[InputManager] Tap delegated to input consumer");
LogDebugMessage("Tap delegated to input consumer");
}
}
@@ -196,13 +192,13 @@ namespace Input
Vector2 screenPos = positionAction.ReadValue<Vector2>();
Vector3 worldPos = Camera.main.ScreenToWorldPoint(screenPos);
Vector2 worldPos2D = new Vector2(worldPos.x, worldPos.y);
Logging.Debug($"[InputManager] HoldMove started at {worldPos2D}");
LogDebugMessage($"HoldMove started at {worldPos2D}");
// First check for override consumers
if (_overrideConsumers.Count > 0)
{
_activeHoldConsumer = _overrideConsumers[_overrideConsumers.Count - 1];
Logging.Debug($"[InputManager] Hold delegated to override consumer: {_activeHoldConsumer}");
LogDebugMessage($"Hold delegated to override consumer: {_activeHoldConsumer}");
_activeHoldConsumer.OnHoldStart(worldPos2D);
return;
}
@@ -222,7 +218,7 @@ namespace Input
Vector2 screenPos = positionAction.ReadValue<Vector2>();
Vector3 worldPos = Camera.main.ScreenToWorldPoint(screenPos);
Vector2 worldPos2D = new Vector2(worldPos.x, worldPos.y);
Logging.Debug($"[InputManager] HoldMove canceled at {worldPos2D}");
LogDebugMessage($"HoldMove canceled at {worldPos2D}");
// Notify the active hold consumer that the hold has ended
_activeHoldConsumer?.OnHoldEnd(worldPos2D);
@@ -239,7 +235,7 @@ namespace Input
Vector2 screenPos = positionAction.ReadValue<Vector2>();
Vector3 worldPos = Camera.main.ScreenToWorldPoint(screenPos);
Vector2 worldPos2D = new Vector2(worldPos.x, worldPos.y);
// Logging.Debug($"[InputManager] HoldMove update at {worldPos2D}");
// LogDebugMessage($"HoldMove update at {worldPos2D}");
// Send hold move updates to the active hold consumer
_activeHoldConsumer?.OnHoldMove(worldPos2D);
@@ -286,7 +282,7 @@ namespace Input
}
if (consumer != null)
{
Logging.Debug($"[InputManager] Delegating tap to UI consumer at {screenPos} (GameObject: {result.gameObject.name})");
LogDebugMessage($"Delegating tap to UI consumer at {screenPos} (GameObject: {result.gameObject.name})");
consumer.OnTap(screenPos);
return true;
}
@@ -315,7 +311,7 @@ namespace Input
}
if (consumer != null)
{
Logging.Debug($"[InputManager] Delegating tap to consumer at {worldPos} (GameObject: {hitWithMask.gameObject.name})");
LogDebugMessage($"Delegating tap to consumer at {worldPos} (GameObject: {hitWithMask.gameObject.name})");
consumer.OnTap(worldPos);
return true;
}
@@ -329,15 +325,15 @@ namespace Input
var consumer = hit.GetComponent<ITouchInputConsumer>();
if (consumer != null)
{
Logging.Debug($"[InputManager] Delegating tap to consumer at {worldPos} (GameObject: {hit.gameObject.name})");
LogDebugMessage($"Delegating tap to consumer at {worldPos} (GameObject: {hit.gameObject.name})");
consumer.OnTap(worldPos);
return true;
}
Logging.Debug($"[InputManager] Collider2D hit at {worldPos} (GameObject: {hit.gameObject.name}), but no ITouchInputConsumer found.");
LogDebugMessage($"Collider2D hit at {worldPos} (GameObject: {hit.gameObject.name}), but no ITouchInputConsumer found.");
}
else
{
Logging.Debug($"[InputManager] No Collider2D found at {worldPos} for interactable delegation.");
LogDebugMessage($"No Collider2D found at {worldPos} for interactable delegation.");
}
return false;
}
@@ -352,7 +348,7 @@ namespace Input
return;
_overrideConsumers.Add(consumer);
Logging.Debug($"[InputManager] Override consumer registered: {consumer}");
LogDebugMessage($"Override consumer registered: {consumer}");
}
/// <summary>
@@ -370,7 +366,7 @@ namespace Input
}
_overrideConsumers.Remove(consumer);
Logging.Debug($"[InputManager] Override consumer unregistered: {consumer}");
LogDebugMessage($"Override consumer unregistered: {consumer}");
}
/// <summary>
@@ -380,7 +376,7 @@ namespace Input
{
_activeHoldConsumer = null;
_overrideConsumers.Clear();
Logging.Debug("[InputManager] All override consumers cleared.");
LogDebugMessage("All override consumers cleared.");
}
/// <summary>
@@ -393,9 +389,17 @@ namespace Input
// Get the topmost override consumer (last registered)
var consumer = _overrideConsumers[_overrideConsumers.Count - 1];
Logging.Debug($"[InputManager] Delegating tap to override consumer at {worldPos} (GameObject: {consumer})");
LogDebugMessage($"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}");
}
}
}
}