Merge branch 'feature/fixcustomer_interaction' into develop
This commit is contained in:
commit
bf1fe51957
@ -39,9 +39,7 @@ public override TaskStatus OnUpdate()
|
||||
return TaskStatus.Failure;
|
||||
}
|
||||
|
||||
// TODO : 아래 상호작용 수행 로직이 우리 프로젝트의 권장하는 방식이 아님. 플레이어가 오브젝트에 인터랙션하는 것과 비슷한 흐름으로 NPC가 오브젝트에 인터랙션하게 만들 것.
|
||||
// TODO : 이벤트 통해서 인터랙션. 직접 호출하지 말 것!
|
||||
outInteractable.OnInteracted(_interactor);
|
||||
RestaurantEvents.InteractionEvent.RequestInteraction(_interactor.GetInteractorGameObject(), outInteractable.gameObject, outInteractable.GetInteractionType());
|
||||
|
||||
if (_registerOnBlackboard)
|
||||
{
|
||||
|
@ -53,8 +53,7 @@ public static TaskStatus FindAvailableOrderInteractable<T>(bool checkCanInteract
|
||||
if (outInteractable == null) continue;
|
||||
if (!outInteractable.TryGetSubsystemObject<T>(out var subsystem)) continue;
|
||||
|
||||
if (EqualityComparer<T>.Default.Equals(subsystem.GetInteractionSubsystemType(), targetOrderType)
|
||||
)
|
||||
if (EqualityComparer<T>.Default.Equals(subsystem.GetInteractionSubsystemType(), targetOrderType))
|
||||
{
|
||||
// CheckCanInteract이 false면 타입만 맞으면 성공
|
||||
if (!checkCanInteract)
|
||||
|
@ -14,7 +14,12 @@ public enum RestaurantOrderType : uint
|
||||
Dirty = 1u << 4,
|
||||
}
|
||||
|
||||
public class InteractionSubsystem_Order : MonoBehaviour, IInteractionSubsystemObject<RestaurantOrderType>
|
||||
public interface IRestaurantOrderObject
|
||||
{
|
||||
void TransitionToNextPhase();
|
||||
}
|
||||
|
||||
public class InteractionSubsystem_Order : MonoBehaviour, IInteractionSubsystemObject<RestaurantOrderType>, IRestaurantOrderObject
|
||||
{
|
||||
[FormerlySerializedAs("orderType")] [SerializeField] protected RestaurantOrderType _orderType = RestaurantOrderType.Wait;
|
||||
private RestaurantOrderType _currentRestaurantOrderType;
|
||||
@ -26,18 +31,23 @@ private void Start()
|
||||
|
||||
public bool CanInteract()
|
||||
{
|
||||
//if (GetInteractionSubsystemType() == RestaurantOrderType.Wait)
|
||||
//{
|
||||
// return true;
|
||||
//}
|
||||
if (GetInteractionSubsystemType() == RestaurantOrderType.Wait)
|
||||
{
|
||||
return CanTransitionToNextPhase();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void TransitionToNextPhase()
|
||||
{
|
||||
// 간단한 상태 전이: 현재 상태에서 다음 상태로 이동
|
||||
var currentState = GetInteractionSubsystemType();
|
||||
var nextState = GetNextState(currentState);
|
||||
SetInteractionSubsystemType(nextState);
|
||||
}
|
||||
|
||||
public bool OnInteracted(IInteractor interactor, ScriptableObject payloadSo = null)
|
||||
{
|
||||
// 간단한 상태 전이: 현재 상태에서 다음 상태로 이동
|
||||
var prev = _currentRestaurantOrderType;
|
||||
_currentRestaurantOrderType = GetNextState(prev);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -74,5 +84,10 @@ private RestaurantOrderType GetNextState(RestaurantOrderType state)
|
||||
default: return RestaurantOrderType.Wait;
|
||||
}
|
||||
}
|
||||
|
||||
public bool CanTransitionToNextPhase()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
@ -8,11 +8,16 @@ public class RestaurantOrderSolver_Wait : MonoBehaviour, IInteractionSubsystemSo
|
||||
public bool ExecuteInteractionSubsystem(IInteractor interactor, IInteractable interactable, ScriptableObject payload = null)
|
||||
{
|
||||
if (CanExecuteInteractionSubsystem(interactor, interactable, payload) == false) return false;
|
||||
// TODO : DO SOMETHING!!!
|
||||
/* TODO
|
||||
* OnInteracted에서 상태를 바꾸는 대신, 여기서 직접 바꿔주고, 현재 나에게 점유되어 있다는 사실을 알려주기? 그리고 CanInteractTo에서 이게 일치해야만 참 반환하게?
|
||||
* 필요하다면 IInteractable 인터페이스에 CurrentInteractor를 등록하는 메소드를 추가해야 할수도?
|
||||
*/
|
||||
|
||||
if (interactable is not IInteractionSubsystemOwner subsystemOwner)
|
||||
return false;
|
||||
if (!subsystemOwner.TryGetSubsystemObject<RestaurantOrderType>(out var subsystem))
|
||||
return false;
|
||||
if (subsystem is IRestaurantOrderObject orderObject)
|
||||
{
|
||||
orderObject.TransitionToNextPhase();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user