Refactor: Simplify interaction target retrieval in WaitForPlayerInteraction using TryGetComponent and shared blackboard.

This commit is contained in:
김산 2025-08-28 10:49:44 +09:00
parent 8851da71d3
commit b4e001f03f

View File

@ -18,17 +18,8 @@ public override void OnStart()
{
// 의자가 복합 상태를 가지게 될 경우
GameObject interactionTarget = null;
var shared = gameObject.GetComponentInChildren<IAISharedBlackboard>();
if (shared != null)
{
interactionTarget = shared.GetCurrentInteractionTarget();
}
else
{
// 하위 호환: 고객 전용 블랙보드 지원
var customerBb = gameObject.GetComponentInParent<IRestaurantCustomerBlackboard>();
interactionTarget = customerBb?.GetCurrentInteractionTarget();
}
if(!gameObject.TryGetComponent<IAISharedBlackboard>(out var sharedBlackboard)) return;
interactionTarget = sharedBlackboard.GetBlackboardGameObject(nameof(RestaurantCustomerBlackboardKey.CurrentInteractionTarget));
if (interactionTarget == null)
{