using UnityEngine;
using Zenject;
using FlappyBird.Core;

namespace FlappyBird.Gameplay.Pipes
{
    /// <summary>
    /// Thin MonoBehaviour ticker — the only pipe-related MonoBehaviour in the scene.
    /// Responsibilities:
    ///   - Forward Update to IPipeSpawner.Tick
    /// NO spawn logic lives here.
    /// </summary>
    public sealed class PipeSpawnerTicker : MonoBehaviour
    {
        private IPipeSpawner      _spawner;
        private IGameStateManager _gameStateManager;

        [Inject]
        private void Construct(IPipeSpawner spawner, IGameStateManager gameStateManager)
        {
            _spawner          = spawner;
            _gameStateManager = gameStateManager;
        }

        private void Update()
        {
            if (_gameStateManager.CurrentState != GameState.Playing) return;
            _spawner.Tick(Time.deltaTime);
        }
    }
}