using UnityEngine; namespace Minigames.DivingForPictures { /// /// Collision behavior that handles damage from mobile obstacles. /// Uses trigger-based collision detection with shared immunity state. /// public class ObstacleCollision : PlayerCollisionBehavior { protected override void OnEnable() { base.OnEnable(); // Subscribe to immunity events OnImmunityStarted += HandleImmunityStarted; OnImmunityEnded += HandleImmunityEnded; } protected override void OnDisable() { // Unsubscribe from immunity events OnImmunityStarted -= HandleImmunityStarted; OnImmunityEnded -= HandleImmunityEnded; base.OnDisable(); } protected override void HandleCollisionResponse(Collider2D obstacle) { // Mark the obstacle as having dealt damage to prevent multiple hits FloatingObstacle obstacleComponent = obstacle.GetComponent(); if (obstacleComponent != null) { obstacleComponent.MarkDamageDealt(); } Debug.Log($"[ObstacleCollision] Player hit by obstacle {obstacle.gameObject.name}"); } /// /// Handler for immunity started event - replaces OnImmunityStart method /// private void HandleImmunityStarted() { Debug.Log($"[ObstacleCollision] Damage immunity started for {_gameSettings.EndlessDescenderDamageImmunityDuration} seconds"); // Don't block input for obstacle damage - let player keep moving // The shared immunity system will handle the collision prevention } /// /// Handler for immunity ended event - replaces OnImmunityEnd method /// private void HandleImmunityEnded() { Debug.Log($"[ObstacleCollision] Damage immunity ended"); // No special handling needed - shared immunity system handles collider re-enabling } } }