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

@@ -2,6 +2,7 @@
using Input;
using Interactions;
using UnityEngine;
using AppleHills.Core.Settings; // Added for IInteractionSettings
/// <summary>
/// Handles level switching when interacted with. Applies switch data and triggers scene transitions.
@@ -14,6 +15,9 @@ public class LevelSwitch : MonoBehaviour
public LevelSwitchData switchData;
private SpriteRenderer _iconRenderer;
private Interactable _interactable;
// Settings reference
private IInteractionSettings _interactionSettings;
private bool _isActive = true;
@@ -30,6 +34,10 @@ public class LevelSwitch : MonoBehaviour
{
_interactable.characterArrived.AddListener(OnCharacterArrived);
}
// Initialize settings reference
_interactionSettings = GameManager.GetSettingsObject<IInteractionSettings>();
ApplySwitchData();
}
@@ -78,10 +86,10 @@ public class LevelSwitch : MonoBehaviour
if (switchData == null || string.IsNullOrEmpty(switchData.targetLevelSceneName) || !_isActive)
return;
var menuPrefab = GameManager.Instance.LevelSwitchMenuPrefab;
var menuPrefab = _interactionSettings?.LevelSwitchMenuPrefab;
if (menuPrefab == null)
{
Debug.LogError("LevelSwitchMenu prefab not assigned in GameSettings!");
Debug.LogError("LevelSwitchMenu prefab not assigned in InteractionSettings!");
return;
}
// Spawn the menu overlay (assume Canvas parent is handled in prefab setup)