[Interaction] Zip up edge cases, base for interactions is now done
This commit is contained in:
@@ -16,7 +16,8 @@ public class Pickup : MonoBehaviour
|
||||
interactable = GetComponent<Interactable>();
|
||||
if (interactable != null)
|
||||
{
|
||||
interactable.Interacted += OnInteracted;
|
||||
interactable.StartedInteraction += OnStartedInteraction;
|
||||
interactable.InteractionComplete += OnInteractionComplete;
|
||||
}
|
||||
ApplyItemData();
|
||||
}
|
||||
@@ -25,7 +26,8 @@ public class Pickup : MonoBehaviour
|
||||
{
|
||||
if (interactable != null)
|
||||
{
|
||||
interactable.Interacted -= OnInteracted;
|
||||
interactable.StartedInteraction -= OnStartedInteraction;
|
||||
interactable.InteractionComplete -= OnInteractionComplete;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,7 +69,7 @@ public class Pickup : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
private void OnInteracted()
|
||||
private void OnStartedInteraction()
|
||||
{
|
||||
if (pickupInProgress) return;
|
||||
var playerObj = GameObject.FindGameObjectWithTag("Player");
|
||||
@@ -84,16 +86,14 @@ public class Pickup : MonoBehaviour
|
||||
Debug.LogWarning("Pickup: PlayerTouchController or FollowerController missing.");
|
||||
return;
|
||||
}
|
||||
// Use GameManager for playerStopDistance and followerPickupDelay
|
||||
float playerStopDistance = GameManager.Instance.PlayerStopDistance;
|
||||
float followerPickupDelay = GameManager.Instance.FollowerPickupDelay;
|
||||
// Subscribe to cancellation event
|
||||
cachedPlayerController = playerController;
|
||||
void OnPlayerArrived()
|
||||
{
|
||||
playerController.OnArrivedAtTarget -= OnPlayerArrived;
|
||||
playerController.OnMoveToCancelled -= OnPlayerMoveCancelled;
|
||||
pickupInProgress = true; // Only lock when follower is about to be dispatched
|
||||
pickupInProgress = true;
|
||||
StartCoroutine(DispatchFollower());
|
||||
}
|
||||
void OnPlayerMoveCancelled()
|
||||
@@ -138,4 +138,11 @@ public class Pickup : MonoBehaviour
|
||||
playerController.MoveToAndNotify(stopPoint);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnInteractionComplete(bool success)
|
||||
{
|
||||
// Only handle post-pickup logic here (e.g., feedback, item destruction)
|
||||
if (!success) return;
|
||||
// Optionally, add logic to disable the pickup or provide feedback
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user