Data로직 수정으로 불필요한 Task 정리
This commit is contained in:
parent
2f2226e3d4
commit
2c3f257353
BIN
Assets/_DDD/_Addressables/So/RestaurantManagementDataSo.asset
(Stored with Git LFS)
BIN
Assets/_DDD/_Addressables/So/RestaurantManagementDataSo.asset
(Stored with Git LFS)
Binary file not shown.
@ -22,7 +22,8 @@ public class CameraManager : Singleton<CameraManager>, IManager
|
|||||||
|
|
||||||
private void OnDestroy()
|
private void OnDestroy()
|
||||||
{
|
{
|
||||||
foreach (var cameraGameObject in _cameraGameObjects.Values)
|
var snapshot = new List<CameraGameObject>(_cameraGameObjects.Values);
|
||||||
|
foreach (var cameraGameObject in snapshot)
|
||||||
{
|
{
|
||||||
if (cameraGameObject)
|
if (cameraGameObject)
|
||||||
{
|
{
|
||||||
|
@ -20,9 +20,9 @@ protected override void Update()
|
|||||||
base.Update();
|
base.Update();
|
||||||
|
|
||||||
var currentSelectedGameObject = EventSystem.current.currentSelectedGameObject;
|
var currentSelectedGameObject = EventSystem.current.currentSelectedGameObject;
|
||||||
if (!currentSelectedGameObject || currentSelectedGameObject.activeInHierarchy == false)
|
if (currentSelectedGameObject == null || currentSelectedGameObject.activeInHierarchy == false)
|
||||||
{
|
{
|
||||||
if (!GetInitialSelected()) return;
|
if (GetInitialSelected() == null) return;
|
||||||
|
|
||||||
EventSystem.current.SetSelectedGameObject(GetInitialSelected());
|
EventSystem.current.SetSelectedGameObject(GetInitialSelected());
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,12 @@
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Mono.Cecil;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace DDD
|
namespace DDD
|
||||||
{
|
{
|
||||||
public class InventorySlotUiStrategy : IItemSlotUiStrategy
|
public class InventorySlotUiStrategy : IItemSlotUiStrategy
|
||||||
{
|
{
|
||||||
public string AnimatorControllerKey => "InventorySlotUi";
|
public void Setup(ItemSlotUi ui, ItemViewModel model)
|
||||||
|
|
||||||
public Task Setup(ItemSlotUi ui, ItemViewModel model)
|
|
||||||
{
|
{
|
||||||
if (InventoryManager.Instance.ContainInventoryItem(model.Id))
|
if (InventoryManager.Instance.ContainInventoryItem(model.Id))
|
||||||
{
|
{
|
||||||
@ -16,7 +15,7 @@ public Task Setup(ItemSlotUi ui, ItemViewModel model)
|
|||||||
ui.HideMark();
|
ui.HideMark();
|
||||||
ui.SetButtonInteractable(true);
|
ui.SetButtonInteractable(true);
|
||||||
|
|
||||||
return Task.CompletedTask;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO : 임시 초기화 값
|
// TODO : 임시 초기화 값
|
||||||
@ -37,13 +36,11 @@ public Task Setup(ItemSlotUi ui, ItemViewModel model)
|
|||||||
ui.HideCountText();
|
ui.HideCountText();
|
||||||
ui.HideMark();
|
ui.HideMark();
|
||||||
ui.SetButtonInteractable(false);
|
ui.SetButtonInteractable(false);
|
||||||
|
|
||||||
return Task.CompletedTask;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<RuntimeAnimatorController> GetAnimatorController()
|
public RuntimeAnimatorController GetAnimatorController()
|
||||||
{
|
{
|
||||||
return await AssetManager.LoadAsset<RuntimeAnimatorController>(AnimatorControllerKey);
|
return RestaurantDataSo.instance.ManagementData.InventorySlotUiAnimatorController;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnInventoryChanged(ItemSlotUi ui)
|
public void OnInventoryChanged(ItemSlotUi ui)
|
||||||
|
@ -36,7 +36,7 @@ private void OnDisable()
|
|||||||
EventBus.Unregister<TodayMenuRemovedEvent>(this);
|
EventBus.Unregister<TodayMenuRemovedEvent>(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task Initialize()
|
public void Initialize()
|
||||||
{
|
{
|
||||||
restaurantManagementStateSo = RestaurantState.instance.ManagementState;
|
restaurantManagementStateSo = RestaurantState.instance.ManagementState;
|
||||||
restaurantManagementDataSo = RestaurantDataSo.instance.ManagementData;
|
restaurantManagementDataSo = RestaurantDataSo.instance.ManagementData;
|
||||||
@ -51,19 +51,19 @@ public async Task Initialize()
|
|||||||
{
|
{
|
||||||
var itemSlotUi = Instantiate(restaurantManagementDataSo.ItemSlotUiPrefab, _slotParent);
|
var itemSlotUi = Instantiate(restaurantManagementDataSo.ItemSlotUiPrefab, _slotParent);
|
||||||
var slot = itemSlotUi.GetComponent<ItemSlotUi>();
|
var slot = itemSlotUi.GetComponent<ItemSlotUi>();
|
||||||
await slot.Initialize(model, new InventorySlotUiStrategy());
|
slot.Initialize(model, new InventorySlotUiStrategy());
|
||||||
itemSlotUi.name = ItemSlotUiName + model.Id;
|
itemSlotUi.name = ItemSlotUiName + model.Id;
|
||||||
|
|
||||||
var interactor = itemSlotUi.GetComponent<ItemSlotInteractor>();
|
var interactor = itemSlotUi.GetComponent<ItemSlotInteractor>();
|
||||||
if (model.ItemType == ItemType.Recipe)
|
if (model.ItemType == ItemType.Recipe)
|
||||||
{
|
{
|
||||||
await interactor.Initialize(TodayMenuEventType.Add, new TodayMenuInteractorStrategy());
|
interactor.Initialize(TodayMenuEventType.Add, new TodayMenuInteractorStrategy());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (DataManager.Instance.GetDataSo<CookwareDataSo>().TryGetDataById(model.Id, out var cookwareData))
|
if (DataManager.Instance.GetDataSo<CookwareDataSo>().TryGetDataById(model.Id, out var cookwareData))
|
||||||
{
|
{
|
||||||
await interactor.Initialize(TodayMenuEventType.Add, new TodayCookwareInteractorStrategy());
|
interactor.Initialize(TodayMenuEventType.Add, new TodayCookwareInteractorStrategy());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,32 +23,28 @@ public class ItemDetailView : MonoBehaviour, IEventHandler<ItemSlotSelectedEvent
|
|||||||
[SerializeField] private RectTransform _tasteHashTagContent2;
|
[SerializeField] private RectTransform _tasteHashTagContent2;
|
||||||
|
|
||||||
private RestaurantManagementDataSo restaurantManagementDataSo;
|
private RestaurantManagementDataSo restaurantManagementDataSo;
|
||||||
private RestaurantManagementStateSo restaurantManagementStateSo;
|
|
||||||
|
|
||||||
private List<TasteHashTagSlotUi> _tasteHashTagSlotUis = new();
|
private List<TasteHashTagSlotUi> _tasteHashTagSlotUis = new();
|
||||||
private ItemViewModel _currentItemViewModel;
|
private ItemViewModel _currentItemViewModel;
|
||||||
private TaskCompletionSource<bool> _isInitialized = new();
|
|
||||||
|
|
||||||
private const string CookwareDetailPanel = "CookwareDetailPanel";
|
private const string CookwareDetailPanel = "CookwareDetailPanel";
|
||||||
private const string IngredientDetailPanel = "IngredientDetailPanel";
|
private const string IngredientDetailPanel = "IngredientDetailPanel";
|
||||||
private const string RecipeDetailPanel = "RecipeDetailPanel";
|
private const string RecipeDetailPanel = "RecipeDetailPanel";
|
||||||
|
|
||||||
private async void Start()
|
private void Start()
|
||||||
{
|
{
|
||||||
restaurantManagementDataSo = RestaurantDataSo.instance.ManagementData;
|
|
||||||
restaurantManagementStateSo = RestaurantState.instance.ManagementState;
|
|
||||||
Debug.Assert(restaurantManagementDataSo != null, "RestaurantManagementSo is null");
|
|
||||||
Debug.Assert(restaurantManagementStateSo != null, "RestaurantManagementSo is null");
|
|
||||||
|
|
||||||
_nameLabel.text = string.Empty;
|
_nameLabel.text = string.Empty;
|
||||||
_descriptionLabel.text = string.Empty;
|
_descriptionLabel.text = string.Empty;
|
||||||
_cookwareImage.sprite = null;
|
_cookwareImage.sprite = null;
|
||||||
|
|
||||||
_isInitialized.SetResult(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnEnable()
|
private void OnEnable()
|
||||||
{
|
{
|
||||||
|
if (restaurantManagementDataSo == null)
|
||||||
|
{
|
||||||
|
restaurantManagementDataSo = RestaurantDataSo.instance.ManagementData;
|
||||||
|
}
|
||||||
|
|
||||||
EventBus.Register<ItemSlotSelectedEvent>(this);
|
EventBus.Register<ItemSlotSelectedEvent>(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,10 +58,8 @@ public void Invoke(ItemSlotSelectedEvent evt)
|
|||||||
Show(evt.Model);
|
Show(evt.Model);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async void Show(ItemViewModel model)
|
public void Show(ItemViewModel model)
|
||||||
{
|
{
|
||||||
await _isInitialized.Task;
|
|
||||||
|
|
||||||
_currentItemViewModel = model;
|
_currentItemViewModel = model;
|
||||||
|
|
||||||
if (_currentItemViewModel == null) return;
|
if (_currentItemViewModel == null) return;
|
||||||
|
@ -4,6 +4,6 @@ namespace DDD
|
|||||||
{
|
{
|
||||||
public interface IInteractableUi
|
public interface IInteractableUi
|
||||||
{
|
{
|
||||||
Task OnInteract();
|
void OnInteract();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -5,8 +5,7 @@ namespace DDD
|
|||||||
{
|
{
|
||||||
public interface IItemSlotUiStrategy
|
public interface IItemSlotUiStrategy
|
||||||
{
|
{
|
||||||
string AnimatorControllerKey { get; }
|
void Setup(ItemSlotUi ui, ItemViewModel model);
|
||||||
Task Setup(ItemSlotUi ui, ItemViewModel model);
|
RuntimeAnimatorController GetAnimatorController();
|
||||||
Task<RuntimeAnimatorController> GetAnimatorController();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -16,7 +16,7 @@ public class ItemSlotInteractor : MonoBehaviour, IInteractableUi
|
|||||||
{
|
{
|
||||||
private ItemSlotUi _itemSlotUi;
|
private ItemSlotUi _itemSlotUi;
|
||||||
private RestaurantManagementStateSo restaurantManagementStateSo;
|
private RestaurantManagementStateSo restaurantManagementStateSo;
|
||||||
private TaskCompletionSource<bool> _isInitialized = new();
|
|
||||||
private TodayMenuEventType _todayMenuEventType = TodayMenuEventType.None;
|
private TodayMenuEventType _todayMenuEventType = TodayMenuEventType.None;
|
||||||
|
|
||||||
public IItemSlotInteractorStrategy Strategy { get; private set; }
|
public IItemSlotInteractorStrategy Strategy { get; private set; }
|
||||||
@ -26,19 +26,16 @@ private void Awake()
|
|||||||
_itemSlotUi = GetComponent<ItemSlotUi>();
|
_itemSlotUi = GetComponent<ItemSlotUi>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task Initialize(TodayMenuEventType todayMenuEventType, IItemSlotInteractorStrategy strategy)
|
public void Initialize(TodayMenuEventType todayMenuEventType, IItemSlotInteractorStrategy strategy)
|
||||||
{
|
{
|
||||||
_todayMenuEventType = todayMenuEventType;
|
_todayMenuEventType = todayMenuEventType;
|
||||||
Strategy = strategy;
|
Strategy = strategy;
|
||||||
|
|
||||||
restaurantManagementStateSo = RestaurantState.instance.ManagementState;
|
restaurantManagementStateSo = RestaurantState.instance.ManagementState;
|
||||||
_isInitialized.SetResult(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task OnInteract()
|
public void OnInteract()
|
||||||
{
|
{
|
||||||
await _isInitialized.Task;
|
|
||||||
|
|
||||||
switch (_todayMenuEventType)
|
switch (_todayMenuEventType)
|
||||||
{
|
{
|
||||||
case TodayMenuEventType.Add:
|
case TodayMenuEventType.Add:
|
||||||
|
@ -19,14 +19,14 @@ public class ItemSlotUi : MonoBehaviour, ISelectHandler, IAutoScrollItem
|
|||||||
[field: SerializeField] public ItemViewModel Model { get; private set; }
|
[field: SerializeField] public ItemViewModel Model { get; private set; }
|
||||||
public IItemSlotUiStrategy Strategy { get; private set; }
|
public IItemSlotUiStrategy Strategy { get; private set; }
|
||||||
|
|
||||||
public async Task Initialize(ItemViewModel model, IItemSlotUiStrategy strategy)
|
public void Initialize(ItemViewModel model, IItemSlotUiStrategy strategy)
|
||||||
{
|
{
|
||||||
Model = model;
|
Model = model;
|
||||||
Strategy = strategy;
|
Strategy = strategy;
|
||||||
|
|
||||||
var controller = await strategy.GetAnimatorController();
|
var controller = strategy.GetAnimatorController();
|
||||||
_animator.runtimeAnimatorController = controller;
|
_animator.runtimeAnimatorController = controller;
|
||||||
_ = Strategy.Setup(this, model);
|
Strategy.Setup(this, model);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetIcon(Sprite sprite) => _icon.sprite = sprite;
|
public void SetIcon(Sprite sprite) => _icon.sprite = sprite;
|
||||||
|
@ -81,11 +81,11 @@ protected override GameObject GetInitialSelected()
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async override void Open(OpenPopupUiEvent evt)
|
public override void Open(OpenPopupUiEvent evt)
|
||||||
{
|
{
|
||||||
base.Open(evt);
|
base.Open(evt);
|
||||||
|
|
||||||
await _inventoryView.Initialize();
|
_inventoryView.Initialize();
|
||||||
|
|
||||||
// 각 그룹별로 허용된 카테고리 설정
|
// 각 그룹별로 허용된 카테고리 설정
|
||||||
SetupCategoryTabs();
|
SetupCategoryTabs();
|
||||||
|
@ -113,11 +113,10 @@ private void SetActiveContents(bool isActive)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task OnInteract()
|
public void OnInteract()
|
||||||
{
|
{
|
||||||
_onSelected?.Invoke(_tabButtonValue);
|
_onSelected?.Invoke(_tabButtonValue);
|
||||||
OnTabClicked?.Invoke(_tabButtonValue);
|
OnTabClicked?.Invoke(_tabButtonValue);
|
||||||
return Task.CompletedTask;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,18 +6,15 @@ namespace DDD
|
|||||||
public class TodayMenuSlotUiStrategy : IItemSlotUiStrategy
|
public class TodayMenuSlotUiStrategy : IItemSlotUiStrategy
|
||||||
{
|
{
|
||||||
private readonly RecipeType _recipeType;
|
private readonly RecipeType _recipeType;
|
||||||
private RestaurantManagementStateSo restaurantManagementStateSo;
|
|
||||||
|
|
||||||
public string AnimatorControllerKey => "TodayMenuSlotUi";
|
|
||||||
|
|
||||||
public TodayMenuSlotUiStrategy(RecipeType recipeType)
|
public TodayMenuSlotUiStrategy(RecipeType recipeType)
|
||||||
{
|
{
|
||||||
_recipeType = recipeType;
|
_recipeType = recipeType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task Setup(ItemSlotUi ui, ItemViewModel model)
|
public void Setup(ItemSlotUi ui, ItemViewModel model)
|
||||||
{
|
{
|
||||||
restaurantManagementStateSo = RestaurantState.instance.ManagementState;
|
var restaurantManagementStateSo = RestaurantState.instance.ManagementState;
|
||||||
|
|
||||||
if (model == null)
|
if (model == null)
|
||||||
{
|
{
|
||||||
@ -54,9 +51,9 @@ public async Task Setup(ItemSlotUi ui, ItemViewModel model)
|
|||||||
ui.SetButtonInteractable(true);
|
ui.SetButtonInteractable(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<RuntimeAnimatorController> GetAnimatorController()
|
public RuntimeAnimatorController GetAnimatorController()
|
||||||
{
|
{
|
||||||
return await AssetManager.LoadAsset<RuntimeAnimatorController>(AnimatorControllerKey);
|
return RestaurantDataSo.instance.ManagementData.TodayMenuSlotUiAnimatorController;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -17,7 +17,7 @@ public class TodayMenuView : MonoBehaviour, IEventHandler<TodayMenuAddedEvent>,
|
|||||||
|
|
||||||
private void Start()
|
private void Start()
|
||||||
{
|
{
|
||||||
_ = Initialize();
|
Initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnDestroy()
|
private void OnDestroy()
|
||||||
@ -26,11 +26,10 @@ private void OnDestroy()
|
|||||||
EventBus.Unregister<TodayMenuRemovedEvent>(this);
|
EventBus.Unregister<TodayMenuRemovedEvent>(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task Initialize()
|
private void Initialize()
|
||||||
{
|
{
|
||||||
restaurantManagementStateSo = RestaurantState.instance.ManagementState;
|
restaurantManagementStateSo = RestaurantState.instance.ManagementState;
|
||||||
restaurantManagementDataSo = RestaurantDataSo.instance.ManagementData;
|
restaurantManagementDataSo = RestaurantDataSo.instance.ManagementData;
|
||||||
Debug.Assert(restaurantManagementStateSo != null, "_restaurantManagementSo != null");
|
|
||||||
|
|
||||||
foreach (Transform child in _todayFoodContent)
|
foreach (Transform child in _todayFoodContent)
|
||||||
{
|
{
|
||||||
@ -43,9 +42,9 @@ private async Task Initialize()
|
|||||||
{
|
{
|
||||||
var go = Instantiate(restaurantManagementDataSo.ItemSlotUiPrefab, _todayFoodContent);
|
var go = Instantiate(restaurantManagementDataSo.ItemSlotUiPrefab, _todayFoodContent);
|
||||||
var slot = go.GetComponent<ItemSlotUi>();
|
var slot = go.GetComponent<ItemSlotUi>();
|
||||||
await slot.Initialize(null, new TodayMenuSlotUiStrategy(RecipeType.FoodRecipe));
|
slot.Initialize(null, new TodayMenuSlotUiStrategy(RecipeType.FoodRecipe));
|
||||||
var itemSlotInteractor = go.GetComponent<ItemSlotInteractor>();
|
var itemSlotInteractor = go.GetComponent<ItemSlotInteractor>();
|
||||||
await itemSlotInteractor.Initialize(TodayMenuEventType.Remove, new TodayMenuInteractorStrategy());
|
itemSlotInteractor.Initialize(TodayMenuEventType.Remove, new TodayMenuInteractorStrategy());
|
||||||
|
|
||||||
_foodSlots.Add(slot);
|
_foodSlots.Add(slot);
|
||||||
}
|
}
|
||||||
@ -61,9 +60,9 @@ private async Task Initialize()
|
|||||||
{
|
{
|
||||||
var go = Instantiate(restaurantManagementDataSo.ItemSlotUiPrefab, _todayDrinkContent);
|
var go = Instantiate(restaurantManagementDataSo.ItemSlotUiPrefab, _todayDrinkContent);
|
||||||
var slot = go.GetComponent<ItemSlotUi>();
|
var slot = go.GetComponent<ItemSlotUi>();
|
||||||
await slot.Initialize(null, new TodayMenuSlotUiStrategy(RecipeType.DrinkRecipe));
|
slot.Initialize(null, new TodayMenuSlotUiStrategy(RecipeType.DrinkRecipe));
|
||||||
var itemSlotInteractor = go.GetComponent<ItemSlotInteractor>();
|
var itemSlotInteractor = go.GetComponent<ItemSlotInteractor>();
|
||||||
await itemSlotInteractor.Initialize(TodayMenuEventType.Remove, new TodayMenuInteractorStrategy());
|
itemSlotInteractor.Initialize(TodayMenuEventType.Remove, new TodayMenuInteractorStrategy());
|
||||||
|
|
||||||
_drinkSlots.Add(slot);
|
_drinkSlots.Add(slot);
|
||||||
}
|
}
|
||||||
@ -93,14 +92,14 @@ private void UpdateView()
|
|||||||
|
|
||||||
var model = ItemViewModelFactory.CreateByItemId(foodRecipeIdCountPair.Key);
|
var model = ItemViewModelFactory.CreateByItemId(foodRecipeIdCountPair.Key);
|
||||||
var foodSlot = _foodSlots[foodIndex];
|
var foodSlot = _foodSlots[foodIndex];
|
||||||
_ = foodSlot.Initialize(model, new TodayMenuSlotUiStrategy(RecipeType.FoodRecipe));
|
foodSlot.Initialize(model, new TodayMenuSlotUiStrategy(RecipeType.FoodRecipe));
|
||||||
foodSlot.Model.SetCount(foodRecipeIdCountPair.Value);
|
foodSlot.Model.SetCount(foodRecipeIdCountPair.Value);
|
||||||
foodIndex++;
|
foodIndex++;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = foodIndex; i < _foodSlots.Count; i++)
|
for (int i = foodIndex; i < _foodSlots.Count; i++)
|
||||||
{
|
{
|
||||||
_ = _foodSlots[i].Initialize(null, new TodayMenuSlotUiStrategy(RecipeType.FoodRecipe));
|
_foodSlots[i].Initialize(null, new TodayMenuSlotUiStrategy(RecipeType.FoodRecipe));
|
||||||
}
|
}
|
||||||
|
|
||||||
int drinkIndex = 0;
|
int drinkIndex = 0;
|
||||||
@ -110,14 +109,14 @@ private void UpdateView()
|
|||||||
|
|
||||||
var model = ItemViewModelFactory.CreateByItemId(drinkRecipeIdCountPair.Key);
|
var model = ItemViewModelFactory.CreateByItemId(drinkRecipeIdCountPair.Key);
|
||||||
var drinkSlot = _drinkSlots[drinkIndex];
|
var drinkSlot = _drinkSlots[drinkIndex];
|
||||||
_ = drinkSlot.Initialize(model, new TodayMenuSlotUiStrategy(RecipeType.DrinkRecipe));
|
drinkSlot.Initialize(model, new TodayMenuSlotUiStrategy(RecipeType.DrinkRecipe));
|
||||||
drinkSlot.Model.SetCount(drinkRecipeIdCountPair.Value);
|
drinkSlot.Model.SetCount(drinkRecipeIdCountPair.Value);
|
||||||
drinkIndex++;
|
drinkIndex++;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = drinkIndex; i < _drinkSlots.Count; i++)
|
for (int i = drinkIndex; i < _drinkSlots.Count; i++)
|
||||||
{
|
{
|
||||||
_ = _drinkSlots[i].Initialize(null, new TodayMenuSlotUiStrategy(RecipeType.DrinkRecipe));
|
_drinkSlots[i].Initialize(null, new TodayMenuSlotUiStrategy(RecipeType.DrinkRecipe));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,11 +5,7 @@ namespace DDD
|
|||||||
{
|
{
|
||||||
public class TodayCookwareSlotUiStrategy : IItemSlotUiStrategy
|
public class TodayCookwareSlotUiStrategy : IItemSlotUiStrategy
|
||||||
{
|
{
|
||||||
private RestaurantManagementStateSo restaurantManagementStateSo;
|
public void Setup(ItemSlotUi ui, ItemViewModel model)
|
||||||
|
|
||||||
public string AnimatorControllerKey => "TodayMenuSlotUi";
|
|
||||||
|
|
||||||
public Task Setup(ItemSlotUi ui, ItemViewModel model)
|
|
||||||
{
|
{
|
||||||
if (model == null)
|
if (model == null)
|
||||||
{
|
{
|
||||||
@ -18,20 +14,18 @@ public Task Setup(ItemSlotUi ui, ItemViewModel model)
|
|||||||
ui.HideMark();
|
ui.HideMark();
|
||||||
ui.SetButtonInteractable(false);
|
ui.SetButtonInteractable(false);
|
||||||
|
|
||||||
return Task.CompletedTask;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ui.SetIcon(model.ItemSprite);
|
ui.SetIcon(model.ItemSprite);
|
||||||
ui.HideCountText();
|
ui.HideCountText();
|
||||||
ui.ShowMark(DataManager.Instance.GetSprite(SpriteConstants.CheckNoSpriteKey)); // TODO : 추후에 장비와 매칭
|
ui.ShowMark(DataManager.Instance.GetSprite(SpriteConstants.CheckNoSpriteKey)); // TODO : 추후에 장비와 매칭
|
||||||
ui.SetButtonInteractable(true);
|
ui.SetButtonInteractable(true);
|
||||||
|
|
||||||
return Task.CompletedTask;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<RuntimeAnimatorController> GetAnimatorController()
|
public RuntimeAnimatorController GetAnimatorController()
|
||||||
{
|
{
|
||||||
return await AssetManager.LoadAsset<RuntimeAnimatorController>(AnimatorControllerKey);
|
return RestaurantDataSo.instance.ManagementData.TodayMenuSlotUiAnimatorController;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -17,7 +17,7 @@ public class TodayRestaurantStateView : MonoBehaviour, IEventHandler<TodayMenuAd
|
|||||||
|
|
||||||
private void Start()
|
private void Start()
|
||||||
{
|
{
|
||||||
_ = Initialize();
|
Initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnDestroy()
|
private void OnDestroy()
|
||||||
@ -26,11 +26,10 @@ private void OnDestroy()
|
|||||||
EventBus.Unregister<TodayMenuRemovedEvent>(this);
|
EventBus.Unregister<TodayMenuRemovedEvent>(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task Initialize()
|
private void Initialize()
|
||||||
{
|
{
|
||||||
restaurantManagementStateSo = RestaurantState.instance.ManagementState;
|
restaurantManagementStateSo = RestaurantState.instance.ManagementState;
|
||||||
restaurantManagementDataSo = RestaurantDataSo.instance.ManagementData;
|
restaurantManagementDataSo = RestaurantDataSo.instance.ManagementData;
|
||||||
Debug.Assert(restaurantManagementStateSo != null, "_restaurantManagementSo != null");
|
|
||||||
|
|
||||||
foreach (Transform child in _todayWorkerContent)
|
foreach (Transform child in _todayWorkerContent)
|
||||||
{
|
{
|
||||||
@ -43,9 +42,9 @@ private async Task Initialize()
|
|||||||
{
|
{
|
||||||
var go = Instantiate(restaurantManagementDataSo.ItemSlotUiPrefab, _todayWorkerContent);
|
var go = Instantiate(restaurantManagementDataSo.ItemSlotUiPrefab, _todayWorkerContent);
|
||||||
var slot = go.GetComponent<ItemSlotUi>();
|
var slot = go.GetComponent<ItemSlotUi>();
|
||||||
await slot.Initialize(null, new TodayWorkerSlotUiStrategy());
|
slot.Initialize(null, new TodayWorkerSlotUiStrategy());
|
||||||
var itemSlotInteractor = go.GetComponent<ItemSlotInteractor>();
|
var itemSlotInteractor = go.GetComponent<ItemSlotInteractor>();
|
||||||
await itemSlotInteractor.Initialize(TodayMenuEventType.Remove, new TodayCookwareInteractorStrategy());
|
itemSlotInteractor.Initialize(TodayMenuEventType.Remove, new TodayCookwareInteractorStrategy());
|
||||||
|
|
||||||
_workerSlots.Add(slot);
|
_workerSlots.Add(slot);
|
||||||
}
|
}
|
||||||
@ -60,9 +59,9 @@ private async Task Initialize()
|
|||||||
{
|
{
|
||||||
var go = Instantiate(restaurantManagementDataSo.ItemSlotUiPrefab, _todayCookwareContent);
|
var go = Instantiate(restaurantManagementDataSo.ItemSlotUiPrefab, _todayCookwareContent);
|
||||||
var slot = go.GetComponent<ItemSlotUi>();
|
var slot = go.GetComponent<ItemSlotUi>();
|
||||||
await slot.Initialize(null, new TodayCookwareSlotUiStrategy());
|
slot.Initialize(null, new TodayCookwareSlotUiStrategy());
|
||||||
var itemSlotInteractor = go.GetComponent<ItemSlotInteractor>();
|
var itemSlotInteractor = go.GetComponent<ItemSlotInteractor>();
|
||||||
await itemSlotInteractor.Initialize(TodayMenuEventType.Remove, new TodayCookwareInteractorStrategy());
|
itemSlotInteractor.Initialize(TodayMenuEventType.Remove, new TodayCookwareInteractorStrategy());
|
||||||
|
|
||||||
_cookwareSlots.Add(slot);
|
_cookwareSlots.Add(slot);
|
||||||
}
|
}
|
||||||
@ -92,14 +91,14 @@ private void UpdateView()
|
|||||||
|
|
||||||
var model = ItemViewModelFactory.CreateByItemId(workerKey);
|
var model = ItemViewModelFactory.CreateByItemId(workerKey);
|
||||||
var newWorkerSlot = _workerSlots[workerIndex];
|
var newWorkerSlot = _workerSlots[workerIndex];
|
||||||
_ = newWorkerSlot.Initialize(model, new TodayWorkerSlotUiStrategy());
|
newWorkerSlot.Initialize(model, new TodayWorkerSlotUiStrategy());
|
||||||
newWorkerSlot.Model.SetCount(1);
|
newWorkerSlot.Model.SetCount(1);
|
||||||
workerIndex++;
|
workerIndex++;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = workerIndex; i < _workerSlots.Count; i++)
|
for (int i = workerIndex; i < _workerSlots.Count; i++)
|
||||||
{
|
{
|
||||||
_ = _workerSlots[i].Initialize(null, new TodayWorkerSlotUiStrategy());
|
_workerSlots[i].Initialize(null, new TodayWorkerSlotUiStrategy());
|
||||||
}
|
}
|
||||||
|
|
||||||
int cookwareIndex = 0;
|
int cookwareIndex = 0;
|
||||||
@ -109,14 +108,14 @@ private void UpdateView()
|
|||||||
|
|
||||||
var model = ItemViewModelFactory.CreateByItemId(cookwareKey);
|
var model = ItemViewModelFactory.CreateByItemId(cookwareKey);
|
||||||
var newCookwareSlot = _cookwareSlots[cookwareIndex];
|
var newCookwareSlot = _cookwareSlots[cookwareIndex];
|
||||||
_ = newCookwareSlot.Initialize(model, new TodayCookwareSlotUiStrategy());
|
newCookwareSlot.Initialize(model, new TodayCookwareSlotUiStrategy());
|
||||||
newCookwareSlot.Model.SetCount(1);
|
newCookwareSlot.Model.SetCount(1);
|
||||||
cookwareIndex++;
|
cookwareIndex++;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = cookwareIndex; i < _cookwareSlots.Count; i++)
|
for (int i = cookwareIndex; i < _cookwareSlots.Count; i++)
|
||||||
{
|
{
|
||||||
_ = _cookwareSlots[i].Initialize(null, new TodayCookwareSlotUiStrategy());
|
_cookwareSlots[i].Initialize(null, new TodayCookwareSlotUiStrategy());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,12 @@
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Unity.VisualScripting.Antlr3.Runtime;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace DDD
|
namespace DDD
|
||||||
{
|
{
|
||||||
public class TodayWorkerSlotUiStrategy : IItemSlotUiStrategy
|
public class TodayWorkerSlotUiStrategy : IItemSlotUiStrategy
|
||||||
{
|
{
|
||||||
private RestaurantManagementStateSo restaurantManagementStateSo;
|
public void Setup(ItemSlotUi ui, ItemViewModel model)
|
||||||
|
|
||||||
public string AnimatorControllerKey => "TodayMenuSlotUi";
|
|
||||||
|
|
||||||
public Task Setup(ItemSlotUi ui, ItemViewModel model)
|
|
||||||
{
|
{
|
||||||
if (model == null)
|
if (model == null)
|
||||||
{
|
{
|
||||||
@ -18,20 +15,18 @@ public Task Setup(ItemSlotUi ui, ItemViewModel model)
|
|||||||
ui.HideMark();
|
ui.HideMark();
|
||||||
ui.SetButtonInteractable(false);
|
ui.SetButtonInteractable(false);
|
||||||
|
|
||||||
return Task.CompletedTask;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ui.SetIcon(model.ItemSprite);
|
ui.SetIcon(model.ItemSprite);
|
||||||
ui.HideCountText();
|
ui.HideCountText();
|
||||||
ui.ShowMark(DataManager.Instance.GetSprite(SpriteConstants.CheckNoSpriteKey)); // TODO : 추후에 장비와 매칭
|
ui.ShowMark(DataManager.Instance.GetSprite(SpriteConstants.CheckNoSpriteKey)); // TODO : 추후에 장비와 매칭
|
||||||
ui.SetButtonInteractable(true);
|
ui.SetButtonInteractable(true);
|
||||||
|
|
||||||
return Task.CompletedTask;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<RuntimeAnimatorController> GetAnimatorController()
|
public RuntimeAnimatorController GetAnimatorController()
|
||||||
{
|
{
|
||||||
return await AssetManager.LoadAsset<RuntimeAnimatorController>(AnimatorControllerKey);
|
return RestaurantDataSo.instance.ManagementData.TodayMenuSlotUiAnimatorController;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -11,5 +11,8 @@ public class RestaurantManagementDataSo : ScriptableObject
|
|||||||
|
|
||||||
public Material FoodTasteMaterial;
|
public Material FoodTasteMaterial;
|
||||||
public Material DrinkTasteMateria;
|
public Material DrinkTasteMateria;
|
||||||
|
|
||||||
|
public RuntimeAnimatorController TodayMenuSlotUiAnimatorController;
|
||||||
|
public RuntimeAnimatorController InventorySlotUiAnimatorController;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -33,6 +33,10 @@ public async Task LoadData()
|
|||||||
|
|
||||||
PlayerData = playerHandle.Result;
|
PlayerData = playerHandle.Result;
|
||||||
ManagementData = managementHandle.Result;
|
ManagementData = managementHandle.Result;
|
||||||
|
|
||||||
|
Debug.Assert(PlayerData != null, "PlayerData is null");
|
||||||
|
Debug.Assert(ManagementData != null, "ManagementData is null");
|
||||||
|
|
||||||
_isLoaded = true;
|
_isLoaded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user