Unity Timeline Interaction System Integration (#17)

- Added InteractionTimelineAction component for timeline-driven interactions
- Implemented custom editor for timeline event mapping
- Updated interaction event flow to support timeline actions
- Enhanced character move target configuration
- Improved inspector UI for interactable components
- Added technical documentation for interaction system
- Refactored interaction action base classes for extensibility
- Fixed issues with character binding in timelines

Co-authored-by: Michal Pikulski <michal@foolhardyhorizons.com>
Co-authored-by: Michal Pikulski <michal.a.pikulski@gmail.com>
Reviewed-on: #17
This commit is contained in:
2025-10-07 10:57:11 +00:00
parent c46036dce6
commit 10992b43cc
48 changed files with 3062 additions and 254 deletions

View File

@@ -268,25 +268,22 @@ public class FollowerController: MonoBehaviour
}
}
// Command follower to go to a specific point (pathfinding mode)
/// <summary>
/// Command follower to go to a specific point (pathfinding mode).
/// Make the follower move to a specific point only. Will not automatically return.
/// </summary>
/// <param name="worldPosition">The world position to move to.</param>
public void GoToPoint(Vector2 worldPosition)
/// <param name="targetPosition">The position to move to.</param>
public void GoToPoint(Vector2 targetPosition)
{
_isManualFollowing = false;
if (_pickupCoroutine != null)
StopCoroutine(_pickupCoroutine);
if (_aiPath != null)
{
_aiPath.enabled = true;
_aiPath.maxSpeed = _followerMaxSpeed;
_aiPath.destination = new Vector3(worldPosition.x, worldPosition.y, 0);
}
_pickupCoroutine = StartCoroutine(GoToPointSequence(targetPosition));
}
// Command follower to go to a specific point and return to player
/// <summary>
/// Command follower to go to a specific point and return to player.
/// Command follower to go to a specific point and return to player after a brief delay.
/// Legacy method that combines GoToPoint and ReturnToPlayer for backward compatibility.
/// </summary>
/// <param name="itemPosition">The position of the item to pick up.</param>
/// <param name="playerTransform">The transform of the player.</param>
@@ -299,6 +296,19 @@ public class FollowerController: MonoBehaviour
_pickupCoroutine = StartCoroutine(PickupSequence(itemPosition, playerTransform));
}
/// <summary>
/// Make the follower return to the player after it has reached a point.
/// </summary>
/// <param name="playerTransform">The transform of the player to return to.</param>
public void ReturnToPlayer(Transform playerTransform)
{
if (_pickupCoroutine != null)
StopCoroutine(_pickupCoroutine);
if (_aiPath != null)
_aiPath.maxSpeed = _followerMaxSpeed;
_pickupCoroutine = StartCoroutine(ReturnToPlayerSequence(playerTransform));
}
private System.Collections.IEnumerator PickupSequence(Vector2 itemPosition, Transform playerTransform)
{
_isManualFollowing = false;
@@ -340,6 +350,63 @@ public class FollowerController: MonoBehaviour
_aiPath.enabled = false;
_pickupCoroutine = null;
}
private System.Collections.IEnumerator GoToPointSequence(Vector2 targetPosition)
{
_isManualFollowing = false;
_isReturningToPlayer = false;
if (_aiPath != null)
{
_aiPath.enabled = true;
_aiPath.maxSpeed = _followerMaxSpeed;
_aiPath.destination = new Vector3(targetPosition.x, targetPosition.y, 0);
}
// Wait until follower reaches target
while (Vector2.Distance(new Vector2(transform.position.x, transform.position.y),
new Vector2(targetPosition.x, targetPosition.y)) > GameManager.Instance.StopThreshold)
{
yield return null;
}
// Signal arrival
OnPickupArrived?.Invoke();
_pickupCoroutine = null;
}
private System.Collections.IEnumerator ReturnToPlayerSequence(Transform playerTransform)
{
if (_aiPath != null && playerTransform != null)
{
_aiPath.maxSpeed = _followerMaxSpeed;
_aiPath.destination = playerTransform.position;
}
_isReturningToPlayer = true;
// Wait until follower returns to player
while (playerTransform != null &&
Vector2.Distance(new Vector2(transform.position.x, transform.position.y),
new Vector2(playerTransform.position.x, playerTransform.position.y)) > GameManager.Instance.StopThreshold)
{
yield return null;
}
_isReturningToPlayer = false;
OnPickupReturned?.Invoke();
// Reset follower speed to normal after pickup
_followerMaxSpeed = _defaultFollowerMaxSpeed;
if (_aiPath != null)
_aiPath.maxSpeed = _followerMaxSpeed;
_isManualFollowing = true;
if (_aiPath != null)
_aiPath.enabled = false;
_pickupCoroutine = null;
}
#endregion Movement
#region ItemInteractions