Merge remote-tracking branch 'origin/feature/customer_moveto' into feature/customer_moveto/FixToBlackboard

This commit is contained in:
김산 2025-08-28 12:43:45 +09:00
commit d1f4980da2

View File

@ -1,5 +1,6 @@
using Opsive.BehaviorDesigner.Runtime.Tasks;
using Opsive.BehaviorDesigner.Runtime.Tasks.Actions;
using Unity.VisualScripting;
using UnityEngine;
namespace DDD.Restaurant
@ -19,6 +20,14 @@ public class MoveToInteractionTarget : Action
[Tooltip("목적지 재계산 주기(초), 0 이하면 비활성화")]
[SerializeField] private float repathInterval = 0.5f;
[Header("Debug Settings")]
[Tooltip("디버그 드로우 활성화")]
[SerializeField] private bool enableDebugDraw = true;
[Tooltip("디버그 선 색상")]
[SerializeField] private Color debugLineColor = Color.red;
[Tooltip("타겟 위치 기즈모 색상")]
[SerializeField] private Color targetGizmoColor = Color.yellow;
private IAiMovement _movement;
private float _repathTimer;
private Vector3 _currentDestination;
@ -49,7 +58,7 @@ public override TaskStatus OnUpdate()
_currentDestination = CalculateDestination(_target);
StartOrUpdateMovement();
}
return CheckMovementCompletion();
}
@ -57,6 +66,73 @@ public override void OnEnd()
{
StopMovement();
}
protected override void OnDrawGizmos()
{
if (!enableDebugDraw || _target == null) return;
// 타겟 이름을 자신의 게임오브젝트 위에 표시
#if UNITY_EDITOR
UnityEditor.Handles.Label(transform.position + Vector3.up * 2f,
$"Target: {_target.name}");
#endif
// 타겟 위치에 기즈모 그리기
Gizmos.color = targetGizmoColor;
if (_isMoving && _currentDestination != Vector3.zero)
{
Gizmos.DrawWireSphere(_currentDestination, 0.5f);
}
else if (_target != null)
{
Gizmos.DrawWireSphere(_target.transform.position, 0.5f);
}
// 현재 위치에서 타겟까지 직선 그리기
Gizmos.color = debugLineColor;
Vector3 targetPos = _isMoving && _currentDestination != Vector3.zero
? _currentDestination
: (_target != null ? _target.transform.position : Vector3.zero);
if (targetPos != Vector3.zero)
{
Gizmos.DrawLine(transform.position, targetPos);
}
// 현재 오브젝트 위치에 작은 기즈모 그리기
Gizmos.color = Color.blue;
Gizmos.DrawWireCube(transform.position, Vector3.one * 0.3f);
}
protected override void OnDrawGizmosSelected()
{
if (!enableDebugDraw || _target == null) return;
// 선택되었을 때 추가 정보 표시
#if UNITY_EDITOR
Vector3 targetPos = _isMoving && _currentDestination != Vector3.zero
? _currentDestination
: _target.transform.position;
float distance = Vector3.Distance(transform.position, targetPos);
UnityEditor.Handles.Label(targetPos + Vector3.up * 1f,
$"Distance: {distance:F2}m\nStopping: {stoppingDistance:F2}m");
// InteractionPoints가 있다면 모두 표시
if (useInteractionPoints && _target.TryGetComponent<RestaurantInteractionComponent>(out var ric))
{
var points = ric.GetInteractionPoints();
if (points != null && points.Length > 0)
{
Gizmos.color = Color.cyan;
foreach (var point in points)
{
Gizmos.DrawWireSphere(point, 0.2f);
}
}
}
#endif
}
private bool ShouldUpdateDestination()
{