WIP : 인터랙션 서브시스템 작성
This commit is contained in:
parent
75bc5e52cc
commit
c7a4aee67d
@ -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
|
||||
}
|
||||
|
||||
|
4
Assets/_DDD/_Scripts/GameEvent/InteractionSubsystem.cs
Normal file
4
Assets/_DDD/_Scripts/GameEvent/InteractionSubsystem.cs
Normal file
@ -0,0 +1,4 @@
|
||||
namespace DDD
|
||||
{
|
||||
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2e8dca10c7c74466bd1df632b7d111c4
|
||||
timeCreated: 1755665098
|
@ -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)
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 30a19025059e4338b29bf140644dd5aa
|
||||
timeCreated: 1755655803
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c0b1e0992510498b8d33d5b6094b8f4b
|
||||
timeCreated: 1755655843
|
@ -14,7 +14,8 @@ public static class RestaurantInteractionEventSolvers
|
||||
public static Dictionary<InteractionType, Type> TypeToSolver = new()
|
||||
{
|
||||
{InteractionType.RestaurantManagementUi, typeof(RestaurantManagementUiEventSolver)},
|
||||
{InteractionType.OpenRestaurant, typeof(RestaurantOpenEventSolver)}
|
||||
{InteractionType.OpenRestaurant, typeof(RestaurantOpenEventSolver)},
|
||||
{InteractionType.RestaurantOrder, typeof(RestaurantOrderSolver)}
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b832b16fa5964817afa836bc86f25f6b
|
||||
timeCreated: 1755664610
|
Loading…
Reference in New Issue
Block a user