using System; using Unity.VisualScripting; using UnityEngine; namespace DDD { public enum RestaurantMealType : uint { None = 0u, WaitForOrder = 1u, WaitForServe = 1u << 1 } public class RestaurantMealInteractionSubsystem : MonoBehaviour, IInteractionSubsystemObject { private RestaurantMealType _currentRestaurantMealType; private void Awake() { _currentRestaurantMealType = RestaurantMealType.None; } public RestaurantMealType GetInteractionSubsystemType() { return _currentRestaurantMealType; } public void SetInteractionSubsystemType(RestaurantMealType inValue) { Debug.Log($"[{gameObject.GetHashCode()}, {GetType().Name}] SetInteractionSubsystemType {inValue.ToString()}"); _currentRestaurantMealType = inValue; } public void InitializeSubsystem() { Debug.Log($"[{gameObject.GetHashCode()}, {GetType().Name}] InitializeSubsystem"); _currentRestaurantMealType = RestaurantMealType.None; } public bool CanInteract() { return _currentRestaurantMealType != RestaurantMealType.None; } public bool OnInteracted(IInteractor interactor, ScriptableObject payloadSo = null) { Debug.Log($"[{gameObject.GetHashCode()}, {GetType().Name}] OnInteracted"); var prev = _currentRestaurantMealType; _currentRestaurantMealType = GetNextState(prev); return true; } public ScriptableObject GetPayload() { return null; } private RestaurantMealType GetNextState(RestaurantMealType state) { switch (state) { case RestaurantMealType.None : return RestaurantMealType.WaitForOrder; case RestaurantMealType.WaitForOrder : return RestaurantMealType.WaitForServe; case RestaurantMealType.WaitForServe : return RestaurantMealType.None; default: return RestaurantMealType.None; } } } }