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; GameObject interactionTarget = null;
var shared = gameObject.GetComponentInChildren<IAISharedBlackboard>(); if(!gameObject.TryGetComponent<IAISharedBlackboard>(out var sharedBlackboard)) return;
if (shared != null) interactionTarget = sharedBlackboard.GetBlackboardGameObject(nameof(RestaurantCustomerBlackboardKey.CurrentInteractionTarget));
{
interactionTarget = shared.GetCurrentInteractionTarget();
}
else
{
// 하위 호환: 고객 전용 블랙보드 지원
var customerBb = gameObject.GetComponentInParent<IRestaurantCustomerBlackboard>();
interactionTarget = customerBb?.GetCurrentInteractionTarget();
}
if (interactionTarget == null) if (interactionTarget == null)
{ {