using Bootstrap; using Core; using UnityEngine; // TODO: Yeet this class namespace UI.CardSystem { /// /// One-off helper that shows/hides the Card System root based on scene loads. /// Attach this to your Card System root GameObject. It subscribes to SceneManagerService.SceneLoadCompleted /// and applies visibility: hidden in "StartingScene" (configurable), visible in all other gameplay scenes. /// public class CardSystemSceneVisibility : MonoBehaviour { [Header("Target Root")] [Tooltip("The GameObject to show/hide. Defaults to this GameObject if not assigned.")] [SerializeField] private GameObject targetRoot; private void Awake() { if (targetRoot == null) targetRoot = gameObject; // Defer subscription to after boot so SceneManagerService is guaranteed ready. BootCompletionService.RegisterInitAction(InitializePostBoot, priority: 95, name: "CardSystem Scene Visibility Init"); } private void InitializePostBoot() { var sceneSvc = SceneManagerService.Instance; if (sceneSvc == null) { Debug.LogWarning("[CardSystemSceneVisibility] SceneManagerService.Instance is null post-boot."); return; } // Subscribe to scene load completion notifications sceneSvc.SceneLoadCompleted += OnSceneLoaded; // Apply initial state based on current gameplay scene ApplyVisibility(sceneSvc.CurrentGameplayScene); } private void OnDestroy() { var sceneSvc = SceneManagerService.Instance; if (sceneSvc != null) { sceneSvc.SceneLoadCompleted -= OnSceneLoaded; } } private void OnSceneLoaded(string sceneName) { ApplyVisibility(sceneName); } private void ApplyVisibility(string sceneName) { // TODO: Implement actual visibility logic based on sceneName SetActiveSafe(true); // if (targetRoot == null) // return; // // if (string.IsNullOrEmpty(sceneName)) // return; // // if (hideInBootstrapScene && sceneName == "BootstrapScene") // { // SetActiveSafe(false); // return; // } // // bool shouldShow = sceneName != startingSceneName; // SetActiveSafe(shouldShow); } private void SetActiveSafe(bool active) { if (targetRoot.activeSelf != active) { targetRoot.SetActive(active); } } } }