ProjectDDD/Assets/_DDD/_Scripts/RestaurantEnvironment/Interactions/RestaurantManagementInteractionSubsystem.cs

72 lines
1.9 KiB
C#
Raw Normal View History

using System;
using UnityEngine;
namespace DDD
{
[Flags]
public enum RestaurantManagementType : uint
{
OpenRestaurantMenu = 0,
StartRestaurant = 1,
2025-08-26 08:27:50 +00:00
OpenCookUi = 2,
}
public class CookwareTypePayload : ScriptableObject
{
public CookwareType CookwareType;
}
public class RestaurantManagementInteractionSubsystem : MonoBehaviour, IInteractionSubsystemObject<RestaurantManagementType>
{
[SerializeField] protected RestaurantManagementType _managementType = RestaurantManagementType.OpenRestaurantMenu;
2025-08-26 08:27:50 +00:00
[SerializeField] private CookwareType _cookwareType = CookwareType.None;
2025-08-26 09:56:40 +00:00
private ScriptableObject _cachedPayload;
private void OnDestroy()
{
if (_cachedPayload)
{
DestroyImmediate(_cachedPayload);
_cachedPayload = null;
}
}
public RestaurantManagementType GetInteractionSubsystemType()
{
return _managementType;
}
2025-08-26 08:27:50 +00:00
public virtual void InitializeSubsystem()
{
}
2025-08-26 08:27:50 +00:00
public virtual bool CanInteract()
{
return true;
}
2025-08-26 08:27:50 +00:00
public virtual bool OnInteracted(IInteractor interactor, ScriptableObject payloadSo = null)
{
return true;
}
2025-08-26 08:27:50 +00:00
public ScriptableObject GetPayload()
{
if (_managementType == RestaurantManagementType.OpenCookUi)
{
2025-08-26 09:56:40 +00:00
if (!_cachedPayload)
{
_cachedPayload = ScriptableObject.CreateInstance(typeof(CookwareTypePayload));
}
var payload = _cachedPayload as CookwareTypePayload;
payload.CookwareType = _cookwareType;
return payload;
2025-08-26 08:27:50 +00:00
}
return null;
}
}
}