#pragma once

#include <object/entity.hpp>
#include <renderer/texture.hpp>
#include <renderer/font.hpp>
#include <object/sound.hpp>
#include <game/gamemanager.hpp>
#include <game/agame/enemy.hpp>
#include <game/agame/trash.hpp>
#include <game/agame/friendly.hpp>

namespace Game::AGame {
GAME_ENTITY(Background)
    public:
        void render(Game::Renderer::Renderer* renderer, Game::Renderer::RendererConfig config) override;
        void onWindowResized(int newWidth, int newHeight) override;
        // Spawn a single trash at the given transform. If seaOnly is true the trash
        // will be clamped to the sea side of the land boundary.
        void spawnTrashAt(const Object::Transform& tS, bool seaOnly = false);
    private:
        void spawnLevel(int stage);
        void spawnFriendly(int stage, int count);
        int mW, mH;
        int mMaxLevels = 2;
        float mLandBoundaryX = 0.f;
        bool mPendingLevelSpawn = false;
        int mPendingLevelStage = 0;
        // Periodic friendly spawn settings
        float mFriendlySpawnAvgInterval = 6.f; // average seconds between spawns
        int mMaxAutoFriendlies = 7; // hard cap for total active friendlies
        std::shared_ptr<Game::Renderer::Texture> mSeaTex;
        std::shared_ptr<Game::Renderer::Texture> mEnemyTex;
        std::shared_ptr<Game::Renderer::Texture> mTrashTex;
        std::shared_ptr<Game::Renderer::Texture> mFriendlyTex;
END_GAME_ENTITY()
}