载入中...
搜索中...
未找到
HouseGenerator.cpp
浏览该文件的文档.
13const HouseComponent *pick(const std::vector<const HouseComponent *> &choices, std::mt19937 &rng) {
28 return std::find(component->tags.begin(), component->tags.end(), "window") != component->tags.end();
31std::vector<const HouseComponent *> facadeVariant(const std::vector<const HouseComponent *> &choices,
82 else if (shape == "t_shape") active = y <= cutY || (x >= minX + stemInset && x <= maxX - stemInset);
101std::vector<const HouseComponent *> compatibleOnFace(const std::vector<const HouseComponent *> &choices,
120bool HouseGenerator::generate(const HouseRequest &r, HouseLayout &out, std::string *error) const {
177 for (int y = 0; y < r.depth; ++y) for (int x = 0; x < r.width; ++x) if (active(mask, r.width, r.depth, x, y)) {
183 if (maxX < minX || maxY < minY) { if (error) *error = "footprint collapsed after inset"; return false; }
197 for (int side = 0; side < 4; ++side) if (!active(mask, r.width, r.depth, x + dx[side], y + dy[side])) {
204 std::sort(entranceCandidates.begin(), entranceCandidates.end(), [](const Face &a, const Face &b) {
208 if (z == 0 && !entranceCandidates.empty()) entranceFace = entranceCandidates[entranceCandidates.size() / 2];
218 const int facadeAxis = (face == SocketDirection::North || face == SocketDirection::South) ? x : y;
224 if (error) *error = "no socket-compatible " + std::string(isEntrance ? "door" : "wall") + " component";
231 if (active(mask, r.width, r.depth, x, y)) out.instances.push_back({pick(roof, rng)->id, x, y, z + 1, 0});
std::vector< const HouseComponent * > byCategory(const std::string &category, const std::string &style={}) const
按分类(可选风格)查询组件。
Definition HouseComponentLibrary.cpp:163
bool generate(const HouseRequest &request, HouseLayout &out, std::string *error=nullptr) const
生成布局;失败返回 false 并写入 error。
Definition HouseGenerator.cpp:120
Definition HouseComponentLibrary.cpp:10