From c7a4aee67da093c2d6d8b0c48326bcc0f4cbd5e0 Mon Sep 17 00:00:00 2001 From: Jeonghyeon Ha Date: Wed, 20 Aug 2025 14:07:33 +0900 Subject: [PATCH] =?UTF-8?q?WIP=20:=20=EC=9D=B8=ED=84=B0=EB=9E=99=EC=85=98?= =?UTF-8?q?=20=EC=84=9C=EB=B8=8C=EC=8B=9C=EC=8A=A4=ED=85=9C=20=EC=9E=91?= =?UTF-8?q?=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../_DDD/_Scripts/GameEvent/IInteractable.cs | 10 +-- .../GameEvent/InteractionSubsystem.cs | 4 + .../GameEvent/InteractionSubsystem.cs.meta | 3 + .../Core/RestaurantCharacterInteraction.cs | 2 +- .../Player/RestaurantPlayerInteraction.cs | 4 +- .../RestaurantEnvironment/Interactions.meta | 3 + .../RestaurantOrderInteraction.cs | 76 +++++++++++++++++++ .../RestaurantOrderInteraction.cs.meta | 3 + .../RestaurantInteractionEvents.cs | 3 +- .../Solvers/RestaurantOrderSolver.cs | 35 +++++++++ .../Solvers/RestaurantOrderSolver.cs.meta | 3 + 11 files changed, 135 insertions(+), 11 deletions(-) create mode 100644 Assets/_DDD/_Scripts/GameEvent/InteractionSubsystem.cs create mode 100644 Assets/_DDD/_Scripts/GameEvent/InteractionSubsystem.cs.meta create mode 100644 Assets/_DDD/_Scripts/RestaurantEnvironment/Interactions.meta create mode 100644 Assets/_DDD/_Scripts/RestaurantEnvironment/Interactions/RestaurantOrderInteraction.cs create mode 100644 Assets/_DDD/_Scripts/RestaurantEnvironment/Interactions/RestaurantOrderInteraction.cs.meta create mode 100644 Assets/_DDD/_Scripts/RestaurantEvent/Solvers/RestaurantOrderSolver.cs create mode 100644 Assets/_DDD/_Scripts/RestaurantEvent/Solvers/RestaurantOrderSolver.cs.meta diff --git a/Assets/_DDD/_Scripts/GameEvent/IInteractable.cs b/Assets/_DDD/_Scripts/GameEvent/IInteractable.cs index 52c19a0e1..c52bd47fd 100644 --- a/Assets/_DDD/_Scripts/GameEvent/IInteractable.cs +++ b/Assets/_DDD/_Scripts/GameEvent/IInteractable.cs @@ -4,18 +4,14 @@ namespace DDD { - /* TODO : BitFlag 제거해야할듯. - 인터랙션 개수가 엄청나게 많아질것으로 예상됨. - 혹은 인터랙션 타입을 여기서 추가하면 안 되고 여기는 몇가지 정적인 타입만 두고 RestaurantInteraction 같은 식으로 확장해서 사용해야함. - 확장성을 생각하면 RestaurantInteractionSolver에서 RestaurantInteractionType을 리졸브해서 또 다른 Solver로 포워딩하는 식으로. - 편하게 하려면 그냥 여기서 비트연산자 없애고 인터랙션타입을 무한정 늘리기. - */ [Flags] - public enum InteractionType : ulong + public enum InteractionType : uint { None = 0u, RestaurantManagementUi = 1u << 0, OpenRestaurant = 1u << 1, + RestaurantOrder = 1u << 2, + RestaurantMeal = 1u << 3, All = 0xFFFFFFFFu } diff --git a/Assets/_DDD/_Scripts/GameEvent/InteractionSubsystem.cs b/Assets/_DDD/_Scripts/GameEvent/InteractionSubsystem.cs new file mode 100644 index 000000000..8ca5eefc8 --- /dev/null +++ b/Assets/_DDD/_Scripts/GameEvent/InteractionSubsystem.cs @@ -0,0 +1,4 @@ +namespace DDD +{ + +} \ No newline at end of file diff --git a/Assets/_DDD/_Scripts/GameEvent/InteractionSubsystem.cs.meta b/Assets/_DDD/_Scripts/GameEvent/InteractionSubsystem.cs.meta new file mode 100644 index 000000000..1bea8095d --- /dev/null +++ b/Assets/_DDD/_Scripts/GameEvent/InteractionSubsystem.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 2e8dca10c7c74466bd1df632b7d111c4 +timeCreated: 1755665098 \ No newline at end of file diff --git a/Assets/_DDD/_Scripts/RestaurantCharacter/Core/RestaurantCharacterInteraction.cs b/Assets/_DDD/_Scripts/RestaurantCharacter/Core/RestaurantCharacterInteraction.cs index 2ca1f4021..c4745fafd 100644 --- a/Assets/_DDD/_Scripts/RestaurantCharacter/Core/RestaurantCharacterInteraction.cs +++ b/Assets/_DDD/_Scripts/RestaurantCharacter/Core/RestaurantCharacterInteraction.cs @@ -44,7 +44,7 @@ protected virtual void Update() _interactHeldTime += Time.deltaTime; - float requiredHoldTime = _interactingTarget.GetRequiredHoldTime(); + float requiredHoldTime = _interactingTarget.GetExecutionParameters().HoldTime; float ratio = Mathf.Clamp01(_interactHeldTime / requiredHoldTime); if (_interactHeldTime >= requiredHoldTime) diff --git a/Assets/_DDD/_Scripts/RestaurantCharacter/Player/RestaurantPlayerInteraction.cs b/Assets/_DDD/_Scripts/RestaurantCharacter/Player/RestaurantPlayerInteraction.cs index 8f648cef9..a86e19447 100644 --- a/Assets/_DDD/_Scripts/RestaurantCharacter/Player/RestaurantPlayerInteraction.cs +++ b/Assets/_DDD/_Scripts/RestaurantCharacter/Player/RestaurantPlayerInteraction.cs @@ -49,7 +49,7 @@ private void OnInteractPerformed(InputAction.CallbackContext context) { if (_nearestInteractable == null || CanInteractTo(_nearestInteractable) == false) return; - float requiredHoldTime = _nearestInteractable.GetRequiredHoldTime(); + float requiredHoldTime = _nearestInteractable.GetExecutionParameters().HoldTime; if (requiredHoldTime <= 0f) { @@ -98,7 +98,7 @@ private void BroadcastShowUi(IInteractable interactable, bool canInteract, float { var evt = GameEvents.ShowInteractionUiEvent; evt.CanInteract = canInteract; - evt.TextKey = interactable.GetInteractionMessageKey(); + evt.TextKey = interactable.GetDisplayParameters().MessageKey; evt.HoldProgress = ratio; EventBus.Broadcast(evt); } diff --git a/Assets/_DDD/_Scripts/RestaurantEnvironment/Interactions.meta b/Assets/_DDD/_Scripts/RestaurantEnvironment/Interactions.meta new file mode 100644 index 000000000..52a559f1d --- /dev/null +++ b/Assets/_DDD/_Scripts/RestaurantEnvironment/Interactions.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 30a19025059e4338b29bf140644dd5aa +timeCreated: 1755655803 \ No newline at end of file diff --git a/Assets/_DDD/_Scripts/RestaurantEnvironment/Interactions/RestaurantOrderInteraction.cs b/Assets/_DDD/_Scripts/RestaurantEnvironment/Interactions/RestaurantOrderInteraction.cs new file mode 100644 index 000000000..8c3ca91c1 --- /dev/null +++ b/Assets/_DDD/_Scripts/RestaurantEnvironment/Interactions/RestaurantOrderInteraction.cs @@ -0,0 +1,76 @@ +using System; +using UnityEngine; + +namespace DDD +{ + public interface IInteractionSubsystemObject where T : Enum + { + T GetInteractionSubsystemType(); + } + public interface IInteractionSubsystemSolver where T : Enum + { + bool ExecuteInteractionSubsystem(IInteractor interactor, IInteractable interactable, ScriptableObject payloadSo = null); + bool CanExecuteInteractionSubsystem(IInteractor interactor = null, IInteractable interactable = null, + ScriptableObject payloadSo = null); + } + + public interface IInteractionSubsystemSubject where T : Enum + { + bool CanSolveInteractionType(T interactionSubsystemType); + bool CanInteractTo(IInteractionSubsystemObject interactableSubsystemObject, + ScriptableObject payloadSo = null); + } + + [Flags] + public enum RestaurantOrderInteractionType : uint + { + // None = 0u, + WaitCustomer = 1u << 0, + // WaitOrder = 1u << 1, + // WaitServe = 1u << 2, + // All = 0xFFFFFFFFu + } + public class RestaurantOrderInteraction : RestaurantInteractionComponent, IInteractionSubsystemObject + { + [SerializeField] protected RestaurantOrderInteractionType _initialOrderInteractionType = RestaurantOrderInteractionType.WaitCustomer; + private RestaurantOrderInteractionType _currentRestaurantOrderInteractionType; + + // EDITOR + private void Reset() + { + SetInteractionTypeToRestaurantOrder(); + } + private void OnValidate() + { + SetInteractionTypeToRestaurantOrder(); + } + // ~EDITOR + + private void Start() + { + + } + + private void SetInteractionTypeToRestaurantOrder() + { + _interactionType = InteractionType.RestaurantOrder; + } + InteractionType GetInteractionType() + { + return InteractionType.RestaurantOrder; + } + bool CanInteract() + { + return TODO_IMPLEMENT_ME; + } + bool OnInteracted(IInteractor interactor, ScriptableObject payloadSo = null); + void InitializeInteraction(InteractionType interactionType); + InteractionExecutionParameters GetExecutionParameters(); + InteractionDisplayParameters GetDisplayParameters(); + + public RestaurantOrderInteractionType GetInteractionSubsystemType() + { + return _currentRestaurantOrderInteractionType; + } + } +} \ No newline at end of file diff --git a/Assets/_DDD/_Scripts/RestaurantEnvironment/Interactions/RestaurantOrderInteraction.cs.meta b/Assets/_DDD/_Scripts/RestaurantEnvironment/Interactions/RestaurantOrderInteraction.cs.meta new file mode 100644 index 000000000..97b6c0b9a --- /dev/null +++ b/Assets/_DDD/_Scripts/RestaurantEnvironment/Interactions/RestaurantOrderInteraction.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: c0b1e0992510498b8d33d5b6094b8f4b +timeCreated: 1755655843 \ No newline at end of file diff --git a/Assets/_DDD/_Scripts/RestaurantEvent/RestaurantInteractionEvents.cs b/Assets/_DDD/_Scripts/RestaurantEvent/RestaurantInteractionEvents.cs index 2f86f12c3..6d9021765 100644 --- a/Assets/_DDD/_Scripts/RestaurantEvent/RestaurantInteractionEvents.cs +++ b/Assets/_DDD/_Scripts/RestaurantEvent/RestaurantInteractionEvents.cs @@ -14,7 +14,8 @@ public static class RestaurantInteractionEventSolvers public static Dictionary TypeToSolver = new() { {InteractionType.RestaurantManagementUi, typeof(RestaurantManagementUiEventSolver)}, - {InteractionType.OpenRestaurant, typeof(RestaurantOpenEventSolver)} + {InteractionType.OpenRestaurant, typeof(RestaurantOpenEventSolver)}, + {InteractionType.RestaurantOrder, typeof(RestaurantOrderSolver)} }; } diff --git a/Assets/_DDD/_Scripts/RestaurantEvent/Solvers/RestaurantOrderSolver.cs b/Assets/_DDD/_Scripts/RestaurantEvent/Solvers/RestaurantOrderSolver.cs new file mode 100644 index 000000000..653b7e355 --- /dev/null +++ b/Assets/_DDD/_Scripts/RestaurantEvent/Solvers/RestaurantOrderSolver.cs @@ -0,0 +1,35 @@ +using UnityEngine; + +namespace DDD +{ + public class RestaurantOrderSolver : MonoBehaviour, IInteractionSolver, IInteractionSubsystemSolver + { + public bool ExecuteInteraction(IInteractor interactor, IInteractable interactable, ScriptableObject payloadSo = null) + { + return ExecuteInteractionSubsystem(interactor, interactable, payloadSo); + } + + public bool CanExecuteInteraction(IInteractor interactor = null, IInteractable interactable = null, + ScriptableObject payloadSo = null) + { + return CanExecuteInteractionSubsystem(interactor, interactable, payloadSo); + } + + public bool ExecuteInteractionSubsystem(IInteractor interactor, IInteractable interactable, ScriptableObject payloadSo = null) + { + TODO_IMPLEMENT_ME + } + + public bool CanExecuteInteractionSubsystem(IInteractor interactor = null, IInteractable interactable = null, + ScriptableObject payloadSo = null) + { + if (interactable is IInteractionSubsystemObject subsystem) + { + RestaurantOrderInteractionType interactionType = subsystem.GetInteractionSubsystemType(); + // Can I solve this interaction type? + TODO_IMPLEMENT_ME + } + return false; + } + } +} \ No newline at end of file diff --git a/Assets/_DDD/_Scripts/RestaurantEvent/Solvers/RestaurantOrderSolver.cs.meta b/Assets/_DDD/_Scripts/RestaurantEvent/Solvers/RestaurantOrderSolver.cs.meta new file mode 100644 index 000000000..0d072c20a --- /dev/null +++ b/Assets/_DDD/_Scripts/RestaurantEvent/Solvers/RestaurantOrderSolver.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: b832b16fa5964817afa836bc86f25f6b +timeCreated: 1755664610 \ No newline at end of file