[Interaction] Zip up edge cases, base for interactions is now done

This commit is contained in:
Michal Pikulski
2025-09-04 15:01:28 +02:00
parent 05a8a5445f
commit 4215d4b437
4 changed files with 51 additions and 25 deletions

View File

@@ -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
}
}