using System; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.InputSystem; namespace DDD { public class RestaurantManagementUi : PopupUi { [SerializeField] private InventoryView _inventoryView; [SerializeField] private TabGroupUi _sectionTabs; [SerializeField] private TabGroupUi _categoryTabs; public override void Open() { base.Open(); _sectionTabs.Initialize(OnSectionTabSelected); _categoryTabs.Initialize(OnCategoryTabSelected); } protected override void OnInputPerformed(RestaurantUiActions actionEnum, InputAction.CallbackContext context) { switch (actionEnum) { case RestaurantUiActions.Cancel: HandleCancel(); break; case RestaurantUiActions.PreviousTab: HandleMoveTab(-1); break; case RestaurantUiActions.NextTab: HandleMoveTab(1); break; case RestaurantUiActions.Interact1: HandleInteract1(); break; case RestaurantUiActions.Interact2: HandleInteract2(); break; default: throw new ArgumentOutOfRangeException(nameof(actionEnum), actionEnum, null); } } private void HandleCancel() { var evt = GameEvents.ClosePopupUiEvent; evt.UiType = GetType(); EventBus.Broadcast(evt); } private void HandleMoveTab(int direction) { _sectionTabs.Move(direction); } private void HandleInteract1() { var selected = EventSystem.current.currentSelectedGameObject; var interactable = selected?.GetComponent(); interactable?.OnInteract(); } private void HandleInteract2() { } private void OnSectionTabSelected(RestaurantManagementSectionType section) { // 추후 Menu, Cookware, Worker에 맞춰 다른 콘텐츠 노출 처리 } private void OnCategoryTabSelected(InventoryCategoryType category) { _inventoryView.ShowItems(itemData => { switch (category) { case InventoryCategoryType.Food: case InventoryCategoryType.Drink: if (itemData.ItemType != ItemType.Recipe) return false; RecipeType recipeType = DataManager.Instance.RecipeDataSo.GetDataById(itemData.Id).RecipeType; return category switch { InventoryCategoryType.Food => recipeType == RecipeType.FoodRecipe, InventoryCategoryType.Drink => recipeType == RecipeType.DrinkRecipe, _ => false }; case InventoryCategoryType.Ingredient: return itemData.ItemType == ItemType.Ingredient; default: return false; } }); } } }