Skip to content
Snippets Groups Projects
lib_map_tools.cpp 3.07 KiB
Newer Older
#include "library.h"

namespace py = pybind11;

void define_map_tools(py::module & m)
{
    const CCColor white{ 255, 255, 255 };
    py::class_<MapTools>(m, "MapTools")
David Bergström's avatar
David Bergström committed
        .def_property_readonly("width", &MapTools::width, "The width of the map")
        .def_property_readonly("height", &MapTools::height, "The height of the map")
        //.def("terrainHeight", &MapTools::terrainHeight, py::const_)
        .def("draw_line", py::overload_cast<const CCPosition &, const CCPosition &, const CCColor &>(&MapTools::drawLine, py::const_), py::arg("start"), py::arg("stop"), py::arg("color"))
        //.def("draw_line", py::overload_cast<CCPositionType, CCPositionType, CCPositionType, CCPositionType, const CCColor &>(&MapTools::drawLine, py::const_)); // TODO: Default argument??
        .def("draw_box", py::overload_cast<const CCPosition &, const CCPosition &, const CCColor &>(&MapTools::drawBox, py::const_), py::arg("top_left"), py::arg("bottom_right"), py::arg("color"))
        .def("draw_circle", py::overload_cast<const CCPosition &, CCPositionType, const CCColor &>(&MapTools::drawCircle, py::const_), py::arg("center"), py::arg("radius"), py::arg("color"))
David Bergström's avatar
David Bergström committed
        .def("draw_text", &MapTools::drawText, "position"_a, "text"_a, "color"_a)
        .def("draw_text_screen", &MapTools::drawTextScreen, "percentage_x"_a, "percentage_y"_a, "text"_a, "color"_a);

        /*
        TODO: Left to implement
        drawBox(CCPositionType x1, CCPositionType y1, CCPositionType x2, CCPositionType y2, const CCColor & color = CCColor(255, 255, 255)) const;
        drawCircle(CCPositionType x1, CCPositionType x2, CCPositionType radius, const CCColor & color = CCColor(255, 255, 255)) const;
    
        isValidTile(int tileX, int tileY) const;
        isValidTile(const CCTilePosition & tile) const;
        isValidPosition(const CCPosition & pos) const;
        isPowered(int tileX, int tileY) const;
        isExplored(int tileX, int tileY) const;
        isExplored(const CCPosition & pos) const;
        isExplored(const CCTilePosition & pos) const;
        isVisible(int tileX, int tileY) const;
        canBuildTypeAtPosition(int tileX, int tileY, const UnitType & type) const;

        getDistanceMap(const CCTilePosition & tile) const;
        getDistanceMap(const CCPosition & tile) const;
        getGroundDistance(const CCPosition & src, const CCPosition & dest) const;
        isConnected(int x1, int y1, int x2, int y2) const;
        isConnected(const CCTilePosition & from, const CCTilePosition & to) const;
        isConnected(const CCPosition & from, const CCPosition & to) const;
        isWalkable(int tileX, int tileY) const;
        isWalkable(const CCTilePosition & tile) const;
    
        isBuildable(int tileX, int tileY) const;
        isBuildable(const CCTilePosition & tile) const;
        isDepotBuildableTile(int tileX, int tileY) const;
    
        getLeastRecentlySeenTile() const;

        // returns a list of all tiles on the map, sorted by 4-direcitonal walk distance from the given position
        const std::vector<CCTilePosition> & getClosestTilesTo(const CCTilePosition & pos) const;
        */
}