using UnityEngine;
namespace Interactions
{
///
/// Defines a target position for character movement during interaction.
/// Attach this to an interactable object's child to specify where
/// characters should move during interaction rather than using the default calculations.
///
public class CharacterMoveToTarget : MonoBehaviour
{
[Tooltip("Which character this target position is for")]
public CharacterToInteract characterType = CharacterToInteract.Pulver;
[Tooltip("Optional offset from this transform's position")]
public Vector3 positionOffset = Vector3.zero;
///
/// Get the target position for this character to move to
///
public Vector3 GetTargetPosition()
{
return transform.position + positionOffset;
}
#if UNITY_EDITOR
private void OnDrawGizmos()
{
// Draw a different colored sphere based on which character this target is for
switch (characterType)
{
case CharacterToInteract.Trafalgar:
Gizmos.color = new Color(0f, 0.5f, 1f, 0.8f); // Blue for player
break;
case CharacterToInteract.Pulver:
Gizmos.color = new Color(1f, 0.5f, 0f, 0.8f); // Orange for follower
break;
case CharacterToInteract.Both:
Gizmos.color = new Color(0.7f, 0f, 0.7f, 0.8f); // Purple for both
break;
default:
Gizmos.color = new Color(0.5f, 0.5f, 0.5f, 0.8f); // Gray for none
break;
}
Vector3 targetPos = GetTargetPosition();
Gizmos.DrawSphere(targetPos, 0.2f);
// Draw a line from the parent interactable to this target
InteractableBase parentInteractable = GetComponentInParent();
if (parentInteractable != null)
{
Gizmos.DrawLine(parentInteractable.transform.position, targetPos);
}
}
#endif
}
}