Finalize work on the dump controller switching
This commit is contained in:
@@ -46,6 +46,114 @@ namespace Input
|
||||
}
|
||||
}
|
||||
|
||||
#region IInteractingCharacter Override
|
||||
|
||||
/// <summary>
|
||||
/// PlayerTouchController-specific interaction movement.
|
||||
/// Handles main character movement + follower dispatch based on interactable.characterToInteract setting.
|
||||
/// </summary>
|
||||
public override async System.Threading.Tasks.Task<bool> MoveToInteractableAsync(Interactions.InteractableBase interactable)
|
||||
{
|
||||
var characterToInteract = interactable.characterToInteract;
|
||||
|
||||
// If None, skip movement
|
||||
if (characterToInteract == Interactions.CharacterToInteract.None)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// Determine stop distance based on interaction type
|
||||
float stopDistance;
|
||||
if (characterToInteract == Interactions.CharacterToInteract.Trafalgar)
|
||||
{
|
||||
// Move ONLY main character directly to item (close distance)
|
||||
stopDistance = Core.GameManager.Instance.PlayerStopDistanceDirectInteraction;
|
||||
}
|
||||
else // Pulver or Both
|
||||
{
|
||||
// Move main character to radius (far distance)
|
||||
stopDistance = Core.GameManager.Instance.PlayerStopDistance;
|
||||
}
|
||||
|
||||
// Calculate stop position for main character
|
||||
Vector3 stopPoint = interactable.transform.position;
|
||||
bool customTargetFound = false;
|
||||
|
||||
// Check for custom CharacterMoveToTarget for main character
|
||||
var moveTargets = interactable.GetComponentsInChildren<Interactions.CharacterMoveToTarget>();
|
||||
foreach (var target in moveTargets)
|
||||
{
|
||||
if (target.characterType == Interactions.CharacterToInteract.Trafalgar ||
|
||||
target.characterType == Interactions.CharacterToInteract.Both)
|
||||
{
|
||||
stopPoint = target.GetTargetPosition();
|
||||
customTargetFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// If no custom target, calculate based on distance
|
||||
if (!customTargetFound)
|
||||
{
|
||||
stopPoint = Utils.MovementUtilities.CalculateStopPosition(
|
||||
interactable.transform.position,
|
||||
transform.position,
|
||||
stopDistance
|
||||
);
|
||||
}
|
||||
|
||||
// Move main character
|
||||
bool mainCharacterArrived = await Utils.MovementUtilities.MoveToPositionAsync(this, stopPoint);
|
||||
|
||||
if (!mainCharacterArrived)
|
||||
{
|
||||
return false; // Movement cancelled
|
||||
}
|
||||
|
||||
// Handle follower dispatch based on interaction type
|
||||
if (characterToInteract == Interactions.CharacterToInteract.Pulver ||
|
||||
characterToInteract == Interactions.CharacterToInteract.Both)
|
||||
{
|
||||
// Find follower and dispatch to interactable
|
||||
var followerController = FindFirstObjectByType<FollowerController>();
|
||||
if (followerController != null)
|
||||
{
|
||||
// Determine follower target position
|
||||
Vector3 followerTarget = interactable.transform.position;
|
||||
|
||||
// Check for custom target for Pulver
|
||||
foreach (var target in moveTargets)
|
||||
{
|
||||
if (target.characterType == Interactions.CharacterToInteract.Pulver ||
|
||||
target.characterType == Interactions.CharacterToInteract.Both)
|
||||
{
|
||||
followerTarget = target.GetTargetPosition();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Wait for follower to arrive
|
||||
var tcs = new System.Threading.Tasks.TaskCompletionSource<bool>();
|
||||
|
||||
void OnFollowerArrived()
|
||||
{
|
||||
followerController.OnPickupArrived -= OnFollowerArrived;
|
||||
followerController.ReturnToPlayer(transform);
|
||||
tcs.TrySetResult(true);
|
||||
}
|
||||
|
||||
followerController.OnPickupArrived += OnFollowerArrived;
|
||||
followerController.GoToPoint(followerTarget);
|
||||
|
||||
await tcs.Task;
|
||||
}
|
||||
}
|
||||
|
||||
return true; // Success
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region Save/Load Lifecycle Hooks
|
||||
|
||||
|
||||
Reference in New Issue
Block a user