Add RestaurantTrash interaction and refactor interaction handling logic

This commit is contained in:
Jeonghyeon Ha 2025-09-02 15:05:02 +09:00
parent 190fa64f45
commit e27d9bb7bf
9 changed files with 43 additions and 10 deletions

View File

@ -426,7 +426,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 81e01dd8c1cc3404d805400eba1bb4ae, type: 3} m_Script: {fileID: 11500000, guid: 81e01dd8c1cc3404d805400eba1bb4ae, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
_availableInteractions: 15 _availableInteractions: 31
_nearColliders: _nearColliders:
- {fileID: 0} - {fileID: 0}
- {fileID: 0} - {fileID: 0}

View File

@ -12,6 +12,7 @@ public enum InteractionType : uint
RestaurantManagement = 1u << 0, RestaurantManagement = 1u << 0,
RestaurantOrder = 1u << 1, RestaurantOrder = 1u << 1,
RestaurantCook = 1u << 3, RestaurantCook = 1u << 3,
RestaurantTrash = 1u << 4,
All = 0xFFFFFFFFu All = 0xFFFFFFFFu
} }

View File

@ -17,7 +17,7 @@ public interface ICarrier
bool IsCarrying(); bool IsCarrying();
bool CanCarryTo(ICarriable carriable); bool CanCarryTo(ICarriable carriable);
void Carry(ICarriable carriable); void Carry(ICarriable carriable);
void Use(ICarriable carriable); void Use();
} }
public interface ICarriable public interface ICarriable
@ -78,7 +78,7 @@ public void Carry(ICarriable carriable)
EventBus.Broadcast(evt); EventBus.Broadcast(evt);
} }
public void Use(ICarriable carriable) public void Use()
{ {
_currentCarriable = null; _currentCarriable = null;
_speechBubble?.Hide(); _speechBubble?.Hide();

View File

@ -1,4 +1,6 @@
using System; using System;
using System.Collections.Generic;
using Sirenix.Serialization;
using UnityEngine; using UnityEngine;
using UnityEngine.Serialization; using UnityEngine.Serialization;
@ -49,7 +51,7 @@ public class InteractionSubsystem_Order : MonoBehaviour, IInteractionSubsystemOb
{ {
[SerializeField] private RestaurantOrderType _currentRestaurantOrderType = RestaurantOrderType.Wait; [SerializeField] private RestaurantOrderType _currentRestaurantOrderType = RestaurantOrderType.Wait;
[SerializeField] private RestaurantOrderObjectState _orderObjectState = new(); [SerializeField] private RestaurantOrderObjectState _orderObjectState = new();
public bool CanInteract() public bool CanInteract()
{ {
if (GetInteractionSubsystemType() == RestaurantOrderType.Wait) if (GetInteractionSubsystemType() == RestaurantOrderType.Wait)

View File

@ -134,16 +134,41 @@ private bool TryGetSubsystem(InteractionType interactionType, out IInteractionSu
return _subsystems.TryGetValue(interactionType, out subsystem); return _subsystems.TryGetValue(interactionType, out subsystem);
} }
private bool FindCurrentInteractionDataEntry(out InteractionDataEntry interactionDataEntry)
{
string interactionType = _interactionType.ToString();
string subsystemType = string.Empty;
if (HasSubsystem(_interactionType) && GetSubsystem(_interactionType) != null)
{
subsystemType = GetSubsystem(_interactionType).GetCurrentSubsystemTypeName();
}
bool dataFound = DataManager.Instance.GetDataAsset<InteractionDataAsset>().TryGetValueByTypeName(interactionType,
subsystemType, out interactionDataEntry);
if (!dataFound)
{
interactionDataEntry = new InteractionDataEntry();
}
return dataFound;
}
// 새로운 스트럭트 기반 메서드들 // 새로운 스트럭트 기반 메서드들
public virtual InteractionExecutionParameters GetExecutionParameters() public virtual InteractionExecutionParameters GetExecutionParameters()
{ {
bool dataFound = FindCurrentInteractionDataEntry(out var interactionDataEntry);
if (!dataFound)
{
return new InteractionExecutionParameters();
}
_executionParameters = new InteractionExecutionParameters(interactionDataEntry.HoldTime);
return _executionParameters; return _executionParameters;
} }
public virtual InteractionDisplayParameters GetDisplayParameters() public virtual InteractionDisplayParameters GetDisplayParameters()
{ {
if (DataManager.Instance.GetDataAsset<InteractionDataAsset>().TryGetValueByTypeName(_interactionType.ToString(), bool dataFound = FindCurrentInteractionDataEntry(out var interactionDataEntry);
_subsystems[_interactionType].GetCurrentSubsystemTypeName(), out var interactionDataEntry) == false) if (!dataFound)
{ {
return new InteractionDisplayParameters(); return new InteractionDisplayParameters();
} }

View File

@ -11,7 +11,8 @@ public static class RestaurantInteractionEventSolvers
{ {
{InteractionType.RestaurantManagement, typeof(RestaurantManagementSolver)}, {InteractionType.RestaurantManagement, typeof(RestaurantManagementSolver)},
{InteractionType.RestaurantOrder, typeof(RestaurantOrderSolver)}, {InteractionType.RestaurantOrder, typeof(RestaurantOrderSolver)},
{InteractionType.RestaurantCook, typeof(RestaurantCookSolver)} {InteractionType.RestaurantCook, typeof(RestaurantCookSolver)},
{InteractionType.RestaurantTrash, typeof(RestaurantTrashSolver)}
}; };
public static readonly Dictionary<InteractionType, Type> TypeToPlayerSolver = new() public static readonly Dictionary<InteractionType, Type> TypeToPlayerSolver = new()
{ {

View File

@ -11,6 +11,11 @@ public override bool ExecuteInteractionSubsystem(IInteractor interactor, IIntera
public override bool CanExecuteInteractionSubsystem(IInteractor interactor = null, IInteractable interactable = null, ScriptableObject payload = null) public override bool CanExecuteInteractionSubsystem(IInteractor interactor = null, IInteractable interactable = null, ScriptableObject payload = null)
{ {
// Check carrying state
var carrier = interactor?.GetInteractorGameObject()?.GetComponent<ICarrier>();
if (carrier != null)
return !carrier.IsCarrying();
return true; return true;
} }
} }

View File

@ -18,7 +18,7 @@ public override bool ExecuteInteractionSubsystem(IInteractor interactor, IIntera
bool result = base.ExecuteInteractionSubsystem(interactor, interactable, payload); bool result = base.ExecuteInteractionSubsystem(interactor, interactable, payload);
// ExecuteInteractionSubsystem 이후에 음식 제거 - 미리 제거하면 CanExecute 통과 못 함 // ExecuteInteractionSubsystem 이후에 음식 제거 - 미리 제거하면 CanExecute 통과 못 함
carrier.Use(carrier.GetCurrentCarriable()); carrier.Use();
// OnFoodServed (Consume Bill Hud item) // OnFoodServed (Consume Bill Hud item)
RestaurantOrderEvent evt = new RestaurantOrderEvent RestaurantOrderEvent evt = new RestaurantOrderEvent

View File

@ -92,9 +92,8 @@ protected override int GetDisplayLayer()
} }
else else
{ {
return LayerMask.NameToLayer(LayerConstants.WorldUi); return base.GetDisplayLayer();
} }
return base.GetDisplayLayer();
} }
} }
} }