You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
77 lines
1.7 KiB
77 lines
1.7 KiB
#pragma once
|
|
#include <vector>
|
|
#include <utility>
|
|
#include <string>
|
|
#include <random>
|
|
#include <algorithm>
|
|
#include <fmt/core.h>
|
|
#include "point.hpp"
|
|
#include "tser.hpp"
|
|
#include "lights.hpp"
|
|
#include "pathing.hpp"
|
|
#include "matrix.hpp"
|
|
|
|
#define INV_WALL 0
|
|
#define INV_SPACE 1
|
|
#define WALL_VALUE 1
|
|
#define SPACE_VALUE 0
|
|
|
|
using lighting::LightSource;
|
|
|
|
struct Room {
|
|
int depth;
|
|
size_t x = 0;
|
|
size_t y = 0;
|
|
size_t width = 0;
|
|
size_t height = 0;
|
|
Point entry;
|
|
Point exit;
|
|
|
|
DEFINE_SERIALIZABLE(Room, x, y, width, height);
|
|
};
|
|
|
|
void dump_map(const std::string &msg, Matrix &map, int show_x=-1, int show_y=-1);
|
|
|
|
class Map {
|
|
public:
|
|
int $limit;
|
|
size_t $width;
|
|
size_t $height;
|
|
Matrix $walls;
|
|
Pathing $paths;
|
|
std::vector<Room> $rooms;
|
|
|
|
Map(size_t width, size_t height);
|
|
|
|
Map(Matrix &walls, Pathing &paths, int limit);
|
|
|
|
// disable copying
|
|
Map(Map &map) = delete;
|
|
|
|
Matrix& paths() { return $paths.paths(); }
|
|
Matrix& input_map() { return $paths.input(); }
|
|
Matrix& walls() { return $walls; }
|
|
int limit() { return $limit; }
|
|
size_t width() { return $width; }
|
|
size_t height() { return $height; }
|
|
int distance(Point to) { return $paths.distance(to); }
|
|
|
|
Room &room(size_t at) { return $rooms[at]; }
|
|
size_t room_count() { return $rooms.size(); }
|
|
|
|
Point place_entity(size_t room_index);
|
|
bool inmap(size_t x, size_t y);
|
|
bool iswall(size_t x, size_t y);
|
|
bool can_move(Point move_to);
|
|
bool neighbors(Point &out, bool random=false);
|
|
|
|
void make_paths();
|
|
void set_target(const Point &at, int value=0);
|
|
void clear_target(const Point &at);
|
|
|
|
Point map_to_camera(const Point &loc, const Point &cam_orig);
|
|
Point center_camera(const Point &around, size_t view_x, size_t view_y);
|
|
|
|
void dump(int show_x=-1, int show_y=-1);
|
|
bool INVARIANT();
|
|
};
|
|
|