WIP : 인터랙션 서브시스템 작성

This commit is contained in:
Jeonghyeon Ha 2025-08-20 14:07:33 +09:00
parent 75bc5e52cc
commit c7a4aee67d
11 changed files with 135 additions and 11 deletions

View File

@ -4,18 +4,14 @@
namespace DDD namespace DDD
{ {
/* TODO : BitFlag .
.
RestaurantInteraction .
RestaurantInteractionSolver에서 RestaurantInteractionType을 Solver로 .
.
*/
[Flags] [Flags]
public enum InteractionType : ulong public enum InteractionType : uint
{ {
None = 0u, None = 0u,
RestaurantManagementUi = 1u << 0, RestaurantManagementUi = 1u << 0,
OpenRestaurant = 1u << 1, OpenRestaurant = 1u << 1,
RestaurantOrder = 1u << 2,
RestaurantMeal = 1u << 3,
All = 0xFFFFFFFFu All = 0xFFFFFFFFu
} }

View File

@ -0,0 +1,4 @@
namespace DDD
{
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 2e8dca10c7c74466bd1df632b7d111c4
timeCreated: 1755665098

View File

@ -44,7 +44,7 @@ protected virtual void Update()
_interactHeldTime += Time.deltaTime; _interactHeldTime += Time.deltaTime;
float requiredHoldTime = _interactingTarget.GetRequiredHoldTime(); float requiredHoldTime = _interactingTarget.GetExecutionParameters().HoldTime;
float ratio = Mathf.Clamp01(_interactHeldTime / requiredHoldTime); float ratio = Mathf.Clamp01(_interactHeldTime / requiredHoldTime);
if (_interactHeldTime >= requiredHoldTime) if (_interactHeldTime >= requiredHoldTime)

View File

@ -49,7 +49,7 @@ private void OnInteractPerformed(InputAction.CallbackContext context)
{ {
if (_nearestInteractable == null || CanInteractTo(_nearestInteractable) == false) return; if (_nearestInteractable == null || CanInteractTo(_nearestInteractable) == false) return;
float requiredHoldTime = _nearestInteractable.GetRequiredHoldTime(); float requiredHoldTime = _nearestInteractable.GetExecutionParameters().HoldTime;
if (requiredHoldTime <= 0f) if (requiredHoldTime <= 0f)
{ {
@ -98,7 +98,7 @@ private void BroadcastShowUi(IInteractable interactable, bool canInteract, float
{ {
var evt = GameEvents.ShowInteractionUiEvent; var evt = GameEvents.ShowInteractionUiEvent;
evt.CanInteract = canInteract; evt.CanInteract = canInteract;
evt.TextKey = interactable.GetInteractionMessageKey(); evt.TextKey = interactable.GetDisplayParameters().MessageKey;
evt.HoldProgress = ratio; evt.HoldProgress = ratio;
EventBus.Broadcast(evt); EventBus.Broadcast(evt);
} }

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 30a19025059e4338b29bf140644dd5aa
timeCreated: 1755655803

View File

@ -0,0 +1,76 @@
using System;
using UnityEngine;
namespace DDD
{
public interface IInteractionSubsystemObject<T> where T : Enum
{
T GetInteractionSubsystemType();
}
public interface IInteractionSubsystemSolver<T> 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<T> where T : Enum
{
bool CanSolveInteractionType(T interactionSubsystemType);
bool CanInteractTo(IInteractionSubsystemObject<T> 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<RestaurantOrderInteractionType>
{
[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;
}
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: c0b1e0992510498b8d33d5b6094b8f4b
timeCreated: 1755655843

View File

@ -14,7 +14,8 @@ public static class RestaurantInteractionEventSolvers
public static Dictionary<InteractionType, Type> TypeToSolver = new() public static Dictionary<InteractionType, Type> TypeToSolver = new()
{ {
{InteractionType.RestaurantManagementUi, typeof(RestaurantManagementUiEventSolver)}, {InteractionType.RestaurantManagementUi, typeof(RestaurantManagementUiEventSolver)},
{InteractionType.OpenRestaurant, typeof(RestaurantOpenEventSolver)} {InteractionType.OpenRestaurant, typeof(RestaurantOpenEventSolver)},
{InteractionType.RestaurantOrder, typeof(RestaurantOrderSolver)}
}; };
} }

View File

@ -0,0 +1,35 @@
using UnityEngine;
namespace DDD
{
public class RestaurantOrderSolver : MonoBehaviour, IInteractionSolver, IInteractionSubsystemSolver<RestaurantOrderInteractionType>
{
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<RestaurantOrderInteractionType> subsystem)
{
RestaurantOrderInteractionType interactionType = subsystem.GetInteractionSubsystemType();
// Can I solve this interaction type?
TODO_IMPLEMENT_ME
}
return false;
}
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: b832b16fa5964817afa836bc86f25f6b
timeCreated: 1755664610