﻿#pragma once

#include <array>
#include <cstddef>

#include "Shooting/PlayerShot.h"

namespace dxgame::shooting
{
    class ImageManager;

    // プレイヤー弾を固定数所有し生成、更新、描画、再利用を管理する
    class PlayerShotManager
    {
    public:
        // 停止中の弾の中心をstartPositionに合わせて生成する
        // 空きがない場合は生成せずfalseを返す
        bool Spawn(const Vector2& startPosition);

        // 所有するすべてのプレイヤー弾を更新する
        // deltaTimeは1フレームの経過秒数
        void Update(float deltaTime);

        // 所有するすべてのプレイヤー弾を描く
        void Draw(const ImageManager& images) const;

        // 所有するすべてのプレイヤー弾を停止して空の状態へ戻す
        void Reset();

    private:
        // 停止中の要素を再利用しゲーム中にはメモリを確保しない
        static constexpr std::size_t Capacity = 48;

        std::array<PlayerShot, Capacity> shots = {};
    };
}
