﻿#include "Shooting/ImageManager.h"

#include "Shooting/PlayerShotManager.h"

namespace dxgame::shooting
{
    bool PlayerShotManager::Spawn(const Vector2& startPosition)
    {
        // 先頭から停止中の弾を探して再利用する
        for (PlayerShot& shot : shots)
        {
            if (shot.IsActive())
                continue;

            shot.Spawn(startPosition);
            return true;
        }
        return false;
    }

    void PlayerShotManager::Update(float deltaTime)
    {
        for (PlayerShot& shot : shots)
            shot.Update(deltaTime);
    }

    void PlayerShotManager::Draw(const ImageManager& images) const
    {
        for (const PlayerShot& shot : shots)
            shot.Draw(images);
    }

    void PlayerShotManager::Reset()
    {
        for (PlayerShot& shot : shots)
            shot.Deactivate();
    }
}
