//
//  Generator.hpp
//  Game
//
//  Created by Darvydas on 25/01/2019.
//

#pragma once

#include "cocos2d.h"
/*
namespace Game
{
    namespace Map
    {
        class CGenerator
        {
            
        public:
            
            using Room = cocos2d::Rect;
            using Point = cocos2d::Vec2;
            
            enum class PathType
            {
                Straight,
                Corridor,
                WindingRoad,
            };
            
        public:
            
            virtual ~CGenerator() = default;
            
            const std::wstring& getName() const;
            
            void generate(CMap& map, Rng& rng);
            
        protected:
            
            void setName(const std::wstring& name);
            
            // Cellular automata
            // http://www.jimrandomh.org/misc/caves.html
            void generation(int r1cutoff);
            void generation(int r1cutoff, int r2cutoff);
            void generation(const Room& room, int r1cutoff); // REMOVE:
            void generation(const Room& room, int r1cutoff, int r2cutoff); // REMOVE:
            
            // Remove or connect unconnected regions
            void removeRegions(int removeProb = 100, int minSize = 0);
            void connectRegions(int minSize = 0, PathType type = PathType::Straight, bool allowDiagonalSteps = true);
            void constructBridges(int minSize = 0);
            
            // Lloyd's algorithm (Voronoi iteration)
            void relaxation(std::vector<Point>& points);
            void connectPoints(std::vector<Point>& points, PathType type = PathType::Straight);
            
            // Growing tree
            void growMaze(std::vector<Point>& maze, int x, int y, int windingProb);
            void removeDeadEnds(std::vector<Point>& maze);
            
            //
            void fill(int wallProb);
            void fill(const Room& room, int wallProb); // REMOVE:
            
            bool canCarve(const Room& room) const;
            void carveRoom(const Room& room);
            
            void carvePath(const Point& from, const Point& to);
            void carveCorridor(const Point& from, const Point& to);
            void carveCircle(const Point& center, int radius);
            
            // Used for river generation
            void carveWindingRoad(const Point& from, const Point& to, int perturbation = 10);
            void extendLine(Point& from, Point& to);
            
            void erode(int iterations);
            void erodeTiles(ETile from, ETile to, int r1cutoff);
            
            void removeWalls(); // remove unused walls
            
        private:
            virtual void onGenerate() = 0;
            
            int countTiles(ETile tile, int x, int y) const; // count adjacent tiles
            
            // private:
        protected:
            CMap* map = nullptr;
            Rng* rng = nullptr;
            
            int width = 0;
            int height = 0;
            
            ETile unused = Tile::Unused;
            ETile floor = Tile::Floor;
            ETile corridor = Tile::Corridor;
            ETile wall = Tile::Wall;
            ETile water = Tile::Water;
            ETile bridge = Tile::Bridge;
            
        private:
            std::wstring name;
        };
    }
}
*/
