2025-07-27 19:32:41 +00:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using Sirenix.OdinInspector;
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
namespace DDD
|
|
|
|
{
|
2025-07-27 19:51:11 +00:00
|
|
|
[CreateAssetMenu(fileName = "RestaurantManagementSo", menuName = "GameState/RestaurantManagementSo")]
|
|
|
|
public class RestaurantManagementSo : GameFlowTask
|
2025-07-27 19:32:41 +00:00
|
|
|
{
|
|
|
|
[ReadOnly, SerializeField] private List<string> _foodRecipeIds = new();
|
|
|
|
[ReadOnly, SerializeField] private List<string> _drinkRecipeIds = new();
|
|
|
|
|
|
|
|
public IReadOnlyList<string> FoodRecipeIds => _foodRecipeIds;
|
|
|
|
public IReadOnlyList<string> DrinkRecipeIds => _drinkRecipeIds;
|
|
|
|
|
|
|
|
public int MaxFoodCount = 8;
|
|
|
|
public int MaxDrinkCount = 6;
|
|
|
|
|
|
|
|
public override Task OnReadyNewFlow(GameFlowState newFlowState)
|
|
|
|
{
|
|
|
|
_foodRecipeIds.Clear();
|
|
|
|
_drinkRecipeIds.Clear();
|
|
|
|
|
|
|
|
return Task.CompletedTask;
|
|
|
|
}
|
|
|
|
|
|
|
|
public bool TryAddTodayMenu(IInventorySlotUi itemSlotUi)
|
|
|
|
{
|
|
|
|
string recipeId = itemSlotUi.Model.Id;
|
|
|
|
|
|
|
|
if (_foodRecipeIds.Count >= MaxFoodCount || _foodRecipeIds.Contains(recipeId)) return false;
|
|
|
|
|
|
|
|
if (itemSlotUi.Model.ItemType == ItemType.Recipe)
|
|
|
|
{
|
|
|
|
if (DataManager.Instance.RecipeDataSo.TryGetDataById(recipeId, out RecipeData recipeData))
|
|
|
|
{
|
|
|
|
if (recipeData.RecipeType == RecipeType.FoodRecipe)
|
|
|
|
{
|
|
|
|
_foodRecipeIds.Add(recipeId);
|
|
|
|
}
|
|
|
|
else if (recipeData.RecipeType == RecipeType.DrinkRecipe)
|
|
|
|
{
|
|
|
|
_drinkRecipeIds.Add(recipeId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
EventBus.Broadcast(RestaurantEvents.TodayMenuAddedEvent);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public bool TryRemoveTodayMenu(IInventorySlotUi itemSlotUi)
|
|
|
|
{
|
|
|
|
string recipeId = itemSlotUi.Model.Id;
|
|
|
|
var evt = RestaurantEvents.TodayMenuRemovedEvent;
|
|
|
|
|
|
|
|
if (_foodRecipeIds.Remove(recipeId))
|
|
|
|
{
|
|
|
|
evt.RecipeType = RecipeType.FoodRecipe;
|
|
|
|
}
|
|
|
|
else if (_drinkRecipeIds.Remove(recipeId))
|
|
|
|
{
|
|
|
|
evt.RecipeType = RecipeType.DrinkRecipe;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
EventBus.Broadcast(evt);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public bool IsContainTodayMenu(string recipeId) => _foodRecipeIds.Contains(recipeId) || _drinkRecipeIds.Contains(recipeId);
|
|
|
|
}
|
|
|
|
}
|