57 lines
1.7 KiB
C#
57 lines
1.7 KiB
C#
|
using System;
|
||
|
using UnityEngine;
|
||
|
|
||
|
namespace DDD
|
||
|
{
|
||
|
public enum RestaurantMealType : uint
|
||
|
{
|
||
|
None = 0u,
|
||
|
WaitForOrder = 1u,
|
||
|
WaitForServe = 1u << 1
|
||
|
}
|
||
|
public class RestaurantMealInteractionSubsystem : MonoBehaviour, IInteractionSubsystemObject<RestaurantMealType>
|
||
|
{
|
||
|
private RestaurantMealType _currentRestaurantMealType;
|
||
|
private void Awake()
|
||
|
{
|
||
|
_currentRestaurantMealType = RestaurantMealType.None;
|
||
|
}
|
||
|
public RestaurantMealType GetInteractionSubsystemType()
|
||
|
{
|
||
|
return _currentRestaurantMealType;
|
||
|
}
|
||
|
|
||
|
public void SetInteractionSubsystemType(RestaurantMealType inValue)
|
||
|
{
|
||
|
_currentRestaurantMealType = inValue;
|
||
|
}
|
||
|
|
||
|
public void InitializeSubsystem()
|
||
|
{
|
||
|
_currentRestaurantMealType = RestaurantMealType.None;
|
||
|
}
|
||
|
|
||
|
public bool CanInteract()
|
||
|
{
|
||
|
return _currentRestaurantMealType != RestaurantMealType.None;
|
||
|
}
|
||
|
|
||
|
public bool OnInteracted(IInteractor interactor, ScriptableObject payloadSo = null)
|
||
|
{
|
||
|
var prev = _currentRestaurantMealType;
|
||
|
_currentRestaurantMealType = GetNextState(prev);
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
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;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|