52 lines
1.7 KiB
C#
52 lines
1.7 KiB
C#
using System.Collections.Generic;
|
|
using Sirenix.OdinInspector;
|
|
using UnityEngine;
|
|
|
|
namespace DDD
|
|
{
|
|
[CreateAssetMenu(fileName = "TodayMenuDataSo", menuName = "GameState/TodayMenuDataSo")]
|
|
public class TodayMenuDataSo : ScriptableObject
|
|
{
|
|
[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 bool TryAddFoodRecipe(string recipeId)
|
|
{
|
|
if (_foodRecipeIds.Count >= MaxFoodCount || _foodRecipeIds.Contains(recipeId))
|
|
return false;
|
|
|
|
_foodRecipeIds.Add(recipeId);
|
|
EventBus.Broadcast(RestaurantEvents.TodayMenuChangedEvent);
|
|
return true;
|
|
}
|
|
|
|
public bool TryAddDrinkRecipe(string recipeId)
|
|
{
|
|
if (_drinkRecipeIds.Count >= MaxDrinkCount || _drinkRecipeIds.Contains(recipeId))
|
|
return false;
|
|
|
|
_drinkRecipeIds.Add(recipeId);
|
|
EventBus.Broadcast(RestaurantEvents.TodayMenuChangedEvent);
|
|
return true;
|
|
}
|
|
|
|
public bool RemoveRecipe(string recipeId)
|
|
{
|
|
bool removed = _foodRecipeIds.Remove(recipeId) || _drinkRecipeIds.Remove(recipeId);
|
|
if (removed)
|
|
{
|
|
EventBus.Broadcast(RestaurantEvents.TodayMenuChangedEvent);
|
|
}
|
|
|
|
return removed;
|
|
}
|
|
|
|
public bool Contains(string recipeId) => _foodRecipeIds.Contains(recipeId) || _drinkRecipeIds.Contains(recipeId);
|
|
}
|
|
} |