72 lines
2.3 KiB
C#
72 lines
2.3 KiB
C#
using System;
|
|
using UnityEngine;
|
|
|
|
namespace DDD
|
|
{
|
|
public enum RestaurantOrderType : uint
|
|
{
|
|
Wait = 0u,
|
|
Reserved = 1u,
|
|
Order = 1u << 1,
|
|
Serve = 1u << 2,
|
|
Busy = 1u << 3,
|
|
Dirty = 1u << 4,
|
|
}
|
|
|
|
public class RestaurantOrderInteractionSubsystem : MonoBehaviour, IInteractionSubsystemObject<RestaurantOrderType>
|
|
{
|
|
[SerializeField] protected RestaurantOrderType orderType = RestaurantOrderType.Wait;
|
|
private RestaurantOrderType currentRestaurantOrderType;
|
|
|
|
private void Start()
|
|
{
|
|
currentRestaurantOrderType = orderType;
|
|
}
|
|
|
|
public bool CanInteract()
|
|
{
|
|
//if (GetInteractionSubsystemType() == RestaurantOrderType.Wait)
|
|
//{
|
|
// return true;
|
|
//}
|
|
return true;
|
|
}
|
|
|
|
public bool OnInteracted(IInteractor interactor, ScriptableObject payloadSo = null)
|
|
{
|
|
// 간단한 상태 전이: 현재 상태에서 다음 상태로 이동
|
|
var prev = currentRestaurantOrderType;
|
|
currentRestaurantOrderType = GetNextState(prev);
|
|
return true;
|
|
}
|
|
|
|
public void InitializeSubsystem()
|
|
{
|
|
currentRestaurantOrderType = orderType;
|
|
}
|
|
|
|
public RestaurantOrderType GetInteractionSubsystemType()
|
|
{
|
|
return currentRestaurantOrderType;
|
|
}
|
|
|
|
public void SetInteractionSubsystemType(RestaurantOrderType inValue)
|
|
{
|
|
currentRestaurantOrderType = inValue;
|
|
}
|
|
|
|
private RestaurantOrderType GetNextState(RestaurantOrderType state)
|
|
{
|
|
switch (state)
|
|
{
|
|
case RestaurantOrderType.Wait: return RestaurantOrderType.Reserved;
|
|
case RestaurantOrderType.Reserved: return RestaurantOrderType.Order;
|
|
case RestaurantOrderType.Order: return RestaurantOrderType.Serve;
|
|
case RestaurantOrderType.Serve: return RestaurantOrderType.Busy;
|
|
case RestaurantOrderType.Busy: return RestaurantOrderType.Dirty;
|
|
case RestaurantOrderType.Dirty: return RestaurantOrderType.Wait;
|
|
default: return RestaurantOrderType.Wait;
|
|
}
|
|
}
|
|
}
|
|
} |