载入中...
搜索中...
未找到
ModuleAssembly.h
浏览该文件的文档.
1#pragma once
2
3#include "common/Export.h"
4#include "common/Result.h"
5
6#include <array>
7#include <string>
8#include <vector>
9
10namespace eve::procgen {
11
13enum class ModuleFacing : unsigned char { North, East, South, West, Up, Down };
14
17 int cellX = 0;
18 int cellZ = 0;
20 std::string tag;
21 std::string accepts;
22 int levelOffset = 0;
23};
24
27 std::string id;
28 int widthCells = 1;
29 int depthCells = 1;
30 std::vector<ModuleConnector> connectors;
31 int heightLevels = 1;
32};
33
36 std::string moduleId;
37 int cellX = 0;
38 int cellZ = 0;
39 int level = 0;
40 int quarterTurn = 0;
41};
42
45 float cellSize = 4.0f;
46 float floorHeight = 4.0f;
47 int minCellX = 0;
48 int maxCellX = 0;
49 int minCellZ = 0;
50 int maxCellZ = 0;
51 int maxLevels = 1;
52 std::array<bool, 4> allowedQuarterTurns{true, true, true, true};
53 bool bounded = false;
54 bool requireConnection = true;
55 float minimumSupportRatio = 0.0f;
56};
57
70public:
72 ModuleAssemblyPlan() = default;
75
77 [[nodiscard]] Result<void> configure(float cellSize, float floorHeight, int minCellX, int maxCellX, int minCellZ,
78 int maxCellZ, int maxLevels, bool bounded, bool requireConnection);
79
81 [[nodiscard]] Result<void> setAllowedQuarterTurns(bool turn0, bool turn90, bool turn180, bool turn270);
82
89 [[nodiscard]] Result<void> setMinimumSupportRatio(float ratio);
90
98 [[nodiscard]] Result<void> applyConfigJson(const std::string& json);
99
101 [[nodiscard]] Result<void> registerModuleType(std::string id, int widthCells, int depthCells);
102
104 [[nodiscard]] Result<void> registerVolumeModuleType(std::string id, int widthCells, int depthCells,
105 int heightLevels);
106
108 [[nodiscard]] Result<void> addConnector(const std::string& moduleId, int cellX, int cellZ, int facing,
109 std::string tag, std::string accepts);
110
112 [[nodiscard]] Result<void> addVolumeConnector(const std::string& moduleId, int cellX, int cellZ, int levelOffset,
113 int facing, std::string tag, std::string accepts);
114
116 [[nodiscard]] Result<void> registerModule(ModuleDefinition definition);
117
122 [[nodiscard]] Result<void> place(ModulePlacement placement);
123
125 [[nodiscard]] const std::vector<ModulePlacement>& placements() const noexcept { return placements_; }
127 [[nodiscard]] int getPlacementCount() const noexcept { return static_cast<int>(placements_.size()); }
129 [[nodiscard]] std::string getPlacementModule(int index) const;
131 [[nodiscard]] float getPlacementX(int index) const noexcept;
133 [[nodiscard]] float getPlacementY(int index) const noexcept;
135 [[nodiscard]] float getPlacementZ(int index) const noexcept;
137 [[nodiscard]] float getPlacementYawDegrees(int index) const noexcept;
139 [[nodiscard]] const ModuleAssemblyConstraints& constraints() const noexcept { return constraints_; }
140
141private:
142 ModuleAssemblyConstraints constraints_;
143 std::vector<ModuleDefinition> definitions_;
144 std::vector<ModulePlacement> placements_;
145};
146
147} // namespace eve::procgen
#define EVENGINE_API_DOMAINS
Definition Export.h:110
const std::string * accepts
ModuleFacing facing
const std::string * tag
Move-only, checked operation results for the common layer.
LogicalId definition
uint32_t index
Move-only operation result carrying either a value or Status.
Definition Result.h:155
Deterministic owner of a validated modular assembly plan.
const ModuleAssemblyConstraints & constraints() const noexcept
Return the immutable constraint configuration.
int getPlacementCount() const noexcept
Return the number of accepted placements.
const std::vector< ModulePlacement > & placements() const noexcept
Borrow the accepted placements in deterministic insertion order.
ModuleAssemblyPlan()=default
Construct an empty plan with default constraints.
ModuleFacing
Horizontal or vertical face used by grid-module connection constraints.
Configurable limits shared by automatic modular-map generators.
A typed connection exposed on one occupied cell edge.
Immutable footprint and connection contract for one modular asset.
std::vector< ModuleConnector > connectors
World-grid placement accepted by a ModuleAssemblyPlan.