Program Listing for File AABB.h

Return to documentation for file (libs/mcg/include/mcg/AABB.h)

#pragma once

#include "Block.h"
#include "Connection.h"
#include "Door.h"
#include "Entity.h"
#include "Object.h"
#include <memory>
#include <random>
#include <vector>

class AABB {

  protected:
    std::string id;
    std::string material;
    std::string type;
    Pos topLeft;
    Pos bottomRight;
    bool isHollow;
    bool hasRoof;
    bool autoAdjust;
    std::vector<std::unique_ptr<Block>> blockList;
    std::vector<std::unique_ptr<Entity>> entityList;
    std::vector<std::unique_ptr<Object>> objectList;
    std::vector<std::unique_ptr<AABB>> aabbList;
    std::vector<std::unique_ptr<Connection>> connectionList;

    void recalculateOverallBoundary();

  public:
    std::string getID();

    std::string getMaterial();

    std::string getType();

    Pos getTopLeft();

    Pos getBottomRight();

    std::vector<std::unique_ptr<Block>>& getBlockList();

    std::vector<std::unique_ptr<Entity>>& getEntityList();

    std::vector<std::unique_ptr<Object>>& getObjectList();

    std::vector<std::unique_ptr<AABB>>& getAABBList();

    std::vector<std::unique_ptr<Connection>>& getConnectionList();

    int getMidpointX();

    int getMidpointY();

    int getMidpointZ();

    int getSizeX();

    int getSizeY();

    int getSizeZ();

    Pos virtual getRandomPos(std::mt19937_64& gen,
                             int offsetPosX = 0,
                             int offsetNegX = 0,
                             int offsetPosY = 0,
                             int offsetNegY = 0,
                             int offsetPosZ = 0,
                             int offsetNegZ = 0);

    std::vector<Pos> virtual getEdgeMidpointAtBase();

    AABB* getSubAABB(std::string id);

    void setTopLeft(Pos& topLeft);

    void setBottomRight(Pos& bottomRight);

    void setMaterial(std::string material);

    void addBlock(std::unique_ptr<Block> block);

    void addEntity(std::unique_ptr<Entity> entity);

    void addObject(std::unique_ptr<Object> object);

    void addAABB(std::unique_ptr<AABB> aabb);

    void addConnection(std::unique_ptr<Connection> connection);

    bool virtual intersects(AABB& other);

    void virtual generateBox(std::string material,
                             int offsetPosX = 0,
                             int offsetNegX = 0,
                             int offsetPosY = 0,
                             int offsetNegY = 0,
                             int offsetPosZ = 0,
                             int offsetNegZ = 0);

    void virtual addRandomBlocks(int n,
                                 std::string material,
                                 std::mt19937_64& gen,
                                 int offsetPosX = 0,
                                 int offsetNegX = 0,
                                 int offsetPosY = 0,
                                 int offsetNegY = 0,
                                 int offsetPosZ = 0,
                                 int offsetNegZ = 0);

    void virtual generateAllDoorsInAABB();

    void shiftX(int shift);

    void shiftY(int shift);

    void shiftZ(int shift);

    void shift(int shiftX, int shiftY, int shiftZ);

    void virtual toSemanticMapJSON(nlohmann::json& json_base);

    void virtual toLowLevelMapJSON(nlohmann::json& json_base);

    AABB(std::string id,
         std::string type,
         std::string material,
         Pos& topLeft,
         Pos& bottomRight,
         bool isHollow = true,
         bool hasRoof = false,
         bool autoAdjust = true);

    AABB(std::string id);

    virtual ~AABB();
};