Merge branch 'develop' of http://gitea.capers.co.kr:3000/iwnc2020/ProjectDDD into feature/Interaction_type_message

This commit is contained in:
NTG 2025-08-28 18:17:07 +09:00
commit aa628edf1b
8 changed files with 54 additions and 23 deletions

View File

@ -41,7 +41,7 @@ public InteractionDisplayParameters(string successMessageKey = "", string failur
public interface IInteractable
{
bool CanInteract();
bool IsInteractionHidden(IInteractor interactor = null);
bool IsInteractionAvailable();
void OnInteracted(IInteractor interactor, ScriptableObject causerPayload = null);
InteractionType GetInteractionType();
GameObject GetInteractableGameObject();
@ -56,6 +56,7 @@ public interface IInteractor
GameObject GetInteractorGameObject();
IInteractable GetFocusedInteractable();
bool CanSolveInteractionType(InteractionType interactionType);
bool IsInteractionHidden(IInteractable interactable);
bool CanInteractTo(IInteractable interactable,
ScriptableObject payloadSo = null);
}
@ -64,5 +65,6 @@ public interface IInteractionSolver
{
bool ExecuteInteraction(IInteractor interactor, IInteractable interactable, ScriptableObject payload = null);
bool CanExecuteInteraction(IInteractor interactor = null, IInteractable interactable = null, ScriptableObject payload = null);
bool CanSolveInteraction(IInteractor interactor, IInteractable interactable);
}
}

View File

@ -16,11 +16,11 @@ public interface IInteractionSubsystemObject<T> : IInteractionSubsystemObject wh
}
public interface IInteractionSubsystemSolver
{
}
public interface IInteractionSubsystemSolver<T> : IInteractionSubsystemSolver where T : Enum
{
bool ExecuteInteractionSubsystem(IInteractor interactor, IInteractable interactable, ScriptableObject payload = null);
bool CanExecuteInteractionSubsystem(IInteractor interactor = null, IInteractable interactable = null, ScriptableObject payload = null);
}
public interface IInteractionSubsystemSolver<T> : IInteractionSubsystemSolver where T : Enum
{
}
}

View File

@ -82,8 +82,10 @@ private bool TryGetSolverForType(InteractionType type, out IInteractionSolver so
public bool CanSolveInteractionType(InteractionType type)
{
if (_cachedSolvers.TryGetValue(type, out var cachedSolver)) return cachedSolver != null;
if (_cachedSolvers.TryGetValue(type, out var cachedSolver))
{
return cachedSolver != null;
}
if (!FetchSolverTypeForInteraction(type, out var solverType)) return false;
if (transform.TryGetComponent(solverType, out var component) == false) return false;
@ -93,6 +95,19 @@ public bool CanSolveInteractionType(InteractionType type)
return solver != null;
}
public bool IsInteractionHidden(IInteractable interactable)
{
var interactionType = interactable.GetInteractionType();
if (GetInteractionSolver(interactionType) is var solver)
{
if (solver != null && solver.CanSolveInteraction(this, interactable))
{
return false;
}
}
return true;
}
protected virtual bool FetchSolverTypeForInteraction(InteractionType type, out Type solverType)
{
return RestaurantInteractionEventSolvers.TypeToSolver.TryGetValue(type, out solverType);

View File

@ -37,6 +37,11 @@ public bool CanSolveInteractionType(InteractionType interactionType)
return _interactionComponent.CanSolveInteractionType(interactionType);
}
public bool IsInteractionHidden(IInteractable interactable)
{
return _interactionComponent.IsInteractionHidden(interactable);
}
public bool CanInteractTo(IInteractable interactable, ScriptableObject payloadSo = null)
{
return _interactionComponent.CanInteractTo(interactable, payloadSo);

View File

@ -185,8 +185,9 @@ protected IInteractable GetNearestInteractable()
if (col.TryGetComponent<IInteractable>(out var interactable) == false) continue;
var type = interactable.GetInteractionType();
if (interactable.IsInteractionHidden(this)) continue;
if (!interactable.IsInteractionAvailable()) continue;
if (CanSolveInteractionType(type) == false) continue;
if (IsInteractionHidden(interactable)) continue;
float distance = Vector3.Distance(transform.position, col.transform.position);
if (distance < closestDistance)

View File

@ -159,7 +159,11 @@ private InteractionOutlineType GetCurrentOutlineType()
if (_interactionComponent is not IInteractable interactable)
return InteractionOutlineType.None;
if (_interactionComponent.IsInteractionHidden(_interactor))
if (!_interactionComponent.IsInteractionAvailable())
{
return InteractionOutlineType.None;
}
if (_interactor.IsInteractionHidden(_interactionComponent))
{
return InteractionOutlineType.None;
}

View File

@ -59,35 +59,26 @@ private static IEnumerable GetAllInteractionTypes()
public virtual bool CanInteract()
{
bool isInteractionVisible = !IsInteractionHidden();
bool isInteractionAvailable = IsInteractionAvailable();
bool hasValidSubsystem = true;
if (HasSubsystem(_interactionType))
{
hasValidSubsystem = GetSubsystem(_interactionType).CanInteract();
}
return isInteractionVisible && hasValidSubsystem;
return isInteractionAvailable && hasValidSubsystem;
}
public virtual bool IsInteractionHidden(IInteractor interactor = null)
public virtual bool IsInteractionAvailable()
{
var currentGameFlowState = GameFlowManager.Instance.GameFlowDataSo.CurrentGameState;
var flowDisabled = (currentGameFlowState & _interactionAvailableFlows) == 0;
if (flowDisabled)
{
return true;
return false;
}
// only check if interactor is valid. if not, pass the check.
if (interactor != null && HasSubsystem(_interactionType))
{
bool canSolve = interactor.CanSolveInteractionType(_interactionType);
if (!canSolve)
{
return true;
}
}
return false;
return true;
}
public virtual void OnInteracted(IInteractor interactor, ScriptableObject payload = null)

View File

@ -30,6 +30,19 @@ public bool CanExecuteInteraction(IInteractor interactor = null, IInteractable i
solver.CanExecuteInteractionSubsystem(interactor, interactable, payload);
}
public bool CanSolveInteraction(IInteractor interactor, IInteractable interactable)
{
if (interactable is IInteractionSubsystemOwner subsystemOwner)
{
if (subsystemOwner.TryGetSubsystemEnumType(out T subsystemType))
{
return _solvers.ContainsKey(subsystemType);
}
}
return false;
}
// Solver를 가져오는 공통 로직
private bool TryGetSolver(IInteractable interactable, out IInteractionSubsystemSolver<T> solver)
{