Semi-working Interactables rework

This commit is contained in:
Michal Pikulski
2025-09-10 16:42:43 +02:00
parent abffb5c558
commit 0ef25f265c
15 changed files with 271 additions and 124 deletions

View File

@@ -157,11 +157,28 @@ public class InputManager : MonoBehaviour
Collider2D hit = Physics2D.OverlapPoint(worldPos, mask);
if (hit != null)
{
var interactable = hit.GetComponent<ITouchInputConsumer>();
var interactable = hit.GetComponent<Interactable>();
if (interactable != null)
{
Debug.unityLogger.Log("Interactable", $"[InputManager] Delegating tap to interactable at {worldPos} (GameObject: {hit.gameObject.name})");
interactable.OnTap(worldPos);
// Find the player Character (by tag)
var playerObj = GameObject.FindGameObjectWithTag("Player");
var playerCharacter = playerObj != null ? playerObj.GetComponent<Character>() : null;
if (playerCharacter != null)
{
InteractionOrchestrator.Instance.RequestInteraction(interactable, playerCharacter);
}
else
{
Debug.LogWarning("[InputManager] Player Character not found for interaction delegation.");
}
return true;
}
// Fallback: support other ITouchInputConsumer implementations
var consumer = hit.GetComponent<ITouchInputConsumer>();
if (consumer != null)
{
consumer.OnTap(worldPos);
return true;
}
else