checklist 로직 분리
This commit is contained in:
parent
5642a5fe77
commit
b0ffb9df08
@ -225,6 +225,7 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: e765c62d234d09447bff001041f3dea6, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
_parent: {fileID: 4147204719077067979}
|
||||
--- !u!1 &4608547885265804944
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -6340,7 +6341,6 @@ MonoBehaviour:
|
||||
m_EditorClassIdentifier:
|
||||
<UiType>k__BackingField: 3
|
||||
_enableBlockImage: 0
|
||||
InputActionMaps: 3
|
||||
_uiActionsInputBinding: {fileID: 11400000, guid: 8073fcaf56fc7c34e996d0d47044f146, type: 2}
|
||||
_checklistView: {fileID: 7075966153492927588}
|
||||
_inventoryView: {fileID: 3570087040626823091}
|
||||
@ -6363,7 +6363,6 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: 80dee5e1862248aab26236036049e5fc, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
_holdCompleteTime: 0
|
||||
--- !u!1001 &4530765275021007961
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
|
BIN
Assets/_DDD/_Addressables/So/RestaurantData/RestaurantManagementData.asset
(Stored with Git LFS)
BIN
Assets/_DDD/_Addressables/So/RestaurantData/RestaurantManagementData.asset
(Stored with Git LFS)
Binary file not shown.
@ -16,29 +16,22 @@ public enum ChecklistLocalizationKey
|
||||
|
||||
public class ChecklistView : MonoBehaviour, IEventHandler<TodayMenuAddedEvent>, IEventHandler<TodayMenuRemovedEvent>
|
||||
{
|
||||
private List<ChecklistData> _checklistDatas;
|
||||
|
||||
private Dictionary<ChecklistLocalizationKey, string> _checklistLocalizationKeys = new()
|
||||
[SerializeField] private Transform _parent;
|
||||
|
||||
private RestaurantManagementViewModel _viewModel;
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
{ChecklistLocalizationKey.Checklist1, "checklist_1"},
|
||||
{ChecklistLocalizationKey.Checklist2, "checklist_2"},
|
||||
{ChecklistLocalizationKey.Checklist3, "checklist_3"},
|
||||
};
|
||||
EventBus.Unregister<TodayMenuAddedEvent>(this);
|
||||
EventBus.Unregister<TodayMenuRemovedEvent>(this);
|
||||
}
|
||||
|
||||
private RestaurantManagementState restaurantManagementStateSo;
|
||||
|
||||
public void Initalize()
|
||||
public void Initialize(RestaurantManagementViewModel viewModel)
|
||||
{
|
||||
restaurantManagementStateSo = RestaurantState.Instance.ManagementState;
|
||||
|
||||
_checklistDatas = new List<ChecklistData>(3);
|
||||
_checklistDatas = GetComponentsInChildren<ChecklistData>().ToList();
|
||||
|
||||
foreach (var checklistData in _checklistDatas)
|
||||
{
|
||||
checklistData.Initialize();
|
||||
}
|
||||
_viewModel = viewModel;
|
||||
|
||||
ClearObject(_parent);
|
||||
_viewModel.CreateChecklist(_parent);
|
||||
UpdateView();
|
||||
|
||||
EventBus.Register<TodayMenuAddedEvent>(this);
|
||||
@ -47,23 +40,18 @@ public void Initalize()
|
||||
|
||||
public void UpdateView()
|
||||
{
|
||||
if (restaurantManagementStateSo == null) return;
|
||||
|
||||
bool[] states = restaurantManagementStateSo.GetChecklistStates();
|
||||
int loopCount = Mathf.Min(_checklistDatas.Count, states.Length);
|
||||
for (int i = 0; i < loopCount; i++)
|
||||
{
|
||||
_checklistDatas[i].UpdateData(_checklistLocalizationKeys[(ChecklistLocalizationKey)i], states[i]);
|
||||
}
|
||||
_viewModel.UpdateChecklistView();
|
||||
}
|
||||
|
||||
public void Invoke(TodayMenuRemovedEvent evt) => UpdateView();
|
||||
public void Invoke(TodayMenuAddedEvent evt) => UpdateView();
|
||||
|
||||
private void OnDestroy()
|
||||
private void ClearObject(Transform parent)
|
||||
{
|
||||
EventBus.Unregister<TodayMenuAddedEvent>(this);
|
||||
EventBus.Unregister<TodayMenuRemovedEvent>(this);
|
||||
foreach (Transform child in _parent)
|
||||
{
|
||||
Destroy(child.gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -111,7 +111,7 @@ private void SetupViewModelEvents()
|
||||
|
||||
private void InitializeViews()
|
||||
{
|
||||
_checklistView.Initalize();
|
||||
_checklistView.Initialize(_viewModel);
|
||||
_inventoryView.Initialize(_viewModel);
|
||||
_itemDetailView.Initialize();
|
||||
_todayMenuView.Initialize(_viewModel);
|
||||
|
@ -178,6 +178,41 @@ public void MoveTab(int direction)
|
||||
OnTabMoved?.Invoke(direction);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ChecklistView
|
||||
|
||||
private List<ChecklistData> _checklistDatas;
|
||||
|
||||
private Dictionary<ChecklistLocalizationKey, string> _checklistLocalizationKeys = new()
|
||||
{
|
||||
{ChecklistLocalizationKey.Checklist1, "checklist_1"},
|
||||
{ChecklistLocalizationKey.Checklist2, "checklist_2"},
|
||||
{ChecklistLocalizationKey.Checklist3, "checklist_3"},
|
||||
};
|
||||
|
||||
public void CreateChecklist(Transform parent)
|
||||
{
|
||||
var checklistCount = GetRestaurantManagementData().ChecklistCount;
|
||||
_checklistDatas = new List<ChecklistData>(checklistCount);
|
||||
for (int i = 0; i < checklistCount; i++)
|
||||
{
|
||||
var instance = Instantiate(GetRestaurantManagementData().ChecklistDataPrefab, parent);
|
||||
instance.Initialize();
|
||||
_checklistDatas.Add(instance);
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateChecklistView()
|
||||
{
|
||||
bool[] states = GetRestaurantManagementState().GetChecklistStates();
|
||||
int loopCount = Mathf.Min(_checklistDatas.Count, states.Length);
|
||||
for (int i = 0; i < loopCount; i++)
|
||||
{
|
||||
_checklistDatas[i].UpdateData(_checklistLocalizationKeys[(ChecklistLocalizationKey)i], states[i]);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region InventoryView
|
||||
|
@ -14,6 +14,7 @@ public class RestaurantManagementData : ScriptableObject
|
||||
public int MaxCookwareCount = 6;
|
||||
|
||||
[Title("체크리스트 조건")]
|
||||
public int ChecklistCount = 3;
|
||||
public int ChecklistFoodCount = 1;
|
||||
public int ChecklistCookwareCount = 1;
|
||||
public int ChecklistMatchedMenuWithCookwareCount = 1;
|
||||
@ -21,6 +22,7 @@ public class RestaurantManagementData : ScriptableObject
|
||||
[Title("컴포넌트")]
|
||||
public ItemSlotUi ItemSlotUiPrefab;
|
||||
public TasteHashTagSlotUi TasteHashTagSlotUiPrefab;
|
||||
public ChecklistData ChecklistDataPrefab;
|
||||
|
||||
public Material FoodTasteMaterial;
|
||||
public Material DrinkTasteMaterial;
|
||||
|
Loading…
Reference in New Issue
Block a user