9bool Grid2D::inBounds(
int x,
int y)
const {
10 return x >= 0 &&
y >= 0 &&
x < width_ &&
y < height_;
17 detail_.assign(
size_t(width_ * height_), 0);
24 if (!inBounds(
x,
y))
return;
30 return int(cells_[
size_t(
y * width_ +
x)]);
34 std::fill(cells_.begin(), cells_.end(), uint32_t(
semantic < 0 ? 0 :
semantic));
38 if (!inBounds(
x,
y))
return;
39 detail_[size_t(
y * width_ +
x)] = uint8_t(
value < 0 ? 0 : (
value > 255 ? 255 :
value));
43 if (!inBounds(
x,
y))
return 0;
44 return int(detail_[
size_t(
y * width_ +
x)]);
49std::string
Grid2D::getMeta(
const std::string &key,
const std::string &defaultValue)
const {
50 auto it = meta_.find(key);
51 return it == meta_.end() ? defaultValue : it->second;
69 o.
gid = uint32_t(gid < 0 ? 0 : gid);
70 objects_.push_back(std::move(o));
76 if (i < 0 || i >=
int(objects_.size()))
return {};
77 return objects_[size_t(i)].name;
80 if (i < 0 || i >=
int(objects_.size()))
return {};
81 return objects_[size_t(i)].type;
84 if (i < 0 || i >=
int(objects_.size()))
return 0.f;
85 return objects_[size_t(i)].x;
88 if (i < 0 || i >=
int(objects_.size()))
return 0.f;
89 return objects_[size_t(i)].y;
92 if (i < 0 || i >=
int(objects_.size()))
return 0.f;
93 return objects_[size_t(i)].width;
96 if (i < 0 || i >=
int(objects_.size()))
return 0.f;
97 return objects_[size_t(i)].height;
100 if (i < 0 || i >=
int(objects_.size()))
return 0;
101 return int(objects_[
size_t(i)].gid);
void setDetail(int x, int y, int value)
Per-cell detail layer (0..255), parallel to cells. Semantics stay in cells (palette/GID compatible); ...
std::string getObjectType(int i) const
float getObjectWidth(int i) const
int getDetail(int x, int y) const
void resize(int width, int height)
float getObjectY(int i) const
void setCell(int x, int y, int semantic)
void addObject(const std::string &name, const std::string &type, float x, float y, float width, float height, int gid)
int getCell(int x, int y) const
float getObjectX(int i) const
void addObjectAt(const std::string &name, const std::string &type, float x, float y)
Script-friendly: name/type + tile coords.
int getObjectCount() const
int getObjectGid(int i) const
float getObjectHeight(int i) const
std::string getObjectName(int i) const
void setMeta(const std::string &key, const std::string &value)
std::string getMeta(const std::string &key, const std::string &defaultValue) const
A named, typed rectangle object from a Tiled objectgroup layer. Used by Map::setObjects / getObject* ...
uint32_t gid
Optional tileset GID (tile objects); 0 = none.
float x
Top-left corner in pixels.
float width
Extent in pixels.