108 [[nodiscard]]
Result<int> registerRecipe(std::string
id,
int inputType,
int inputCount,
int outputType,
109 int outputCount,
float durationSec);
126 [[nodiscard]]
Result<void> removeMachine(
int machineId);
129 [[nodiscard]]
Result<void> placeSource(
int cx,
int cy,
int itemType,
float itemsPerSec,
int layer = 0);
151 [[nodiscard]]
int width() const noexcept {
return width_; }
153 [[nodiscard]]
int height() const noexcept {
return height_; }
155 [[nodiscard]]
int layers() const noexcept {
return layers_; }
157 [[nodiscard]]
float cellSize() const noexcept {
return cellSize_; }
159 [[nodiscard]]
float originX() const noexcept {
return originX_; }
161 [[nodiscard]]
float originY() const noexcept {
return originY_; }
166 [[nodiscard]]
int cellKind(
int cx,
int cy,
int layer = 0) const noexcept;
168 [[nodiscard]]
int cellDir(
int cx,
int cy,
int layer = 0) const noexcept;
170 [[nodiscard]]
int cellMachine(
int cx,
int cy,
int layer = 0) const noexcept;
173 [[nodiscard]]
int itemCount() const noexcept {
return static_cast<int>(itemType_.size()); }
188 [[nodiscard]]
int machineSlotCount() const noexcept {
return static_cast<int>(machines_.size()); }
192 [[nodiscard]] std::string machineOwnerId(
int index)
const;
195 [[nodiscard]]
int sunkTotal() const noexcept {
return sunkTotal_; }
197 [[nodiscard]]
int craftsTotal() const noexcept {
return craftsTotal_; }
200 void setBeltSpeed(
float cellsPerSec)
noexcept { beltSpeed_ = cellsPerSec > 0.f ? cellsPerSec : beltSpeed_; }
202 [[nodiscard]]
float beltSpeed() const noexcept {
return beltSpeed_; }
212 int machineSlot = -1;
214 float spawnRate = 0.f;
215 float spawnAcc = 0.f;
226 int recipeIndex = -1;
228 int outputStored = 0;
229 float craftProgress = 0.f;
230 bool crafting =
false;
239 float progress = 0.f;
243 [[nodiscard]]
bool inBounds(
int cx,
int cy,
int layer)
const noexcept;
244 [[nodiscard]] std::size_t cellIndex(
int cx,
int cy,
int layer)
const noexcept;
245 static void dirDelta(Dir
dir,
int&
dx,
int&
dy)
noexcept;
246 [[nodiscard]] ItemState makeItemState(
const Item& item)
const noexcept;
247 [[nodiscard]] Result<void> ensureConfigured()
const;
248 void destroyItemAt(std::size_t
index);
249 [[nodiscard]]
int findItemAt(
int cx,
int cy,
int layer)
const noexcept;
250 void stepBelts(
float dt, StepReport& report);
251 void stepSources(
float dt, StepReport& report);
252 void stepSinks(StepReport& report);
253 void stepMachines(
float dt, StepReport& report);
254 void tryPullInputs();
255 void tryPushOutputs();
260 float cellSize_ = 16.f;
261 float originX_ = 0.f;
262 float originY_ = 0.f;
263 float beltSpeed_ = 4.f;
264 int bufferCapacity_ = 8;
265 int nextMachineId_ = 1;
267 int craftsTotal_ = 0;
270 std::vector<Cell> cells_;
271 std::vector<Machine> machines_;
272 std::vector<Recipe> recipes_;
274 std::vector<int> itemType_;
275 std::vector<int> itemCellX_;
276 std::vector<int> itemCellY_;
277 std::vector<int> itemLayer_;
278 std::vector<float> itemProgress_;
279 std::vector<std::uint8_t> itemDir_;
280 std::vector<std::int32_t> occupancy_;
#define EVENGINE_API_FOUNDATION
每个链接组(link group)各自的导出宏。
Move-only, checked operation results for the common layer.
Common time values and an injectable deterministic simulation clock.
Signed, fixed-resolution simulation duration in nanoseconds.
EVENGINE_API_FOUNDATION public API.
Move-only operation result carrying either a value or Status.
Deterministic 2D factory logistics: belts, discrete items, machine buffers, crafts.
int machineSlotCount() const noexcept
Live machine count (includes holes after remove; use machineAt).
int height() const noexcept
Grid height in cells.
float beltSpeed() const noexcept
Current belt speed.
~Logistics() override
Destroy logistics storage.
int bufferCapacity() const noexcept
Current buffer capacity.
Logistics()
Construct an empty unconfigured logistics world.
SimulationTick currentTick() const noexcept
Last accepted simulation tick.
float originX() const noexcept
World origin X.
float cellSize() const noexcept
World units per cell.
int sunkTotal() const noexcept
Items destroyed by sinks since configure/clear.
float originY() const noexcept
World origin Y.
int layers() const noexcept
Configured floor count.
int craftsTotal() const noexcept
Crafts completed since configure/clear.
void setBeltSpeed(float cellsPerSec) noexcept
Default belt speed in cells per second.
void setBufferCapacity(int capacity) noexcept
Max items stored in a machine input or output buffer.
int width() const noexcept
Grid width in cells.
Dir
Orthographic belt / port facing on the 2D factory grid (Y grows south).
CellKind
Occupancy kind stored per grid cell.
detail::StrongUint64< detail::SimulationTickTag > SimulationTick
Deterministic simulation time step; it is not wall-clock time.
One deterministic fixed-step emitted by SimulationClock.
Read-only item snapshot for script / GPU packing.
float x
World X (cell center + progress along belt).
Read-only machine snapshot.
Compact recipe: consume inputCount of inputType, emit outputCount of outputType.
One completed fixed logistics step.