Remove dependencies on legacy variables in GameManager.Instance

This commit is contained in:
Michal Pikulski
2025-10-07 10:44:26 +02:00
parent c46036dce6
commit f845673eca
9 changed files with 113 additions and 89 deletions

View File

@@ -3,6 +3,7 @@ using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.InputSystem;
using UnityEngine.SceneManagement;
using AppleHills.Core.Settings; // Added for IInteractionSettings
namespace Input
{
@@ -44,6 +45,9 @@ namespace Input
}
}
// Settings reference
private IInteractionSettings _interactionSettings;
private PlayerInput playerInput;
private InputAction tapMoveAction;
private InputAction holdMoveAction;
@@ -55,6 +59,10 @@ namespace Input
{
_instance = this;
// DontDestroyOnLoad(gameObject);
// Initialize settings reference
_interactionSettings = GameManager.GetSettingsObject<IInteractionSettings>();
playerInput = GetComponent<PlayerInput>();
if (playerInput == null)
{
@@ -217,7 +225,7 @@ namespace Input
/// </summary>
private bool TryDelegateToInteractable(Vector2 worldPos)
{
LayerMask mask = GameManager.Instance != null ? GameManager.Instance.InteractableLayerMask : -1;
LayerMask mask = _interactionSettings != null ? _interactionSettings.InteractableLayerMask : -1;
Collider2D hit = Physics2D.OverlapPoint(worldPos, mask);
if (hit != null)
{