Deterministic 2D factory logistics: belts, discrete items, machine buffers, crafts. 更多...
#include <Logistics.h>
Public 成员函数 | |
| Module_REG (Logistics) | |
| Logistics () | |
| Construct an empty unconfigured logistics world. | |
| ~Logistics () override | |
| Destroy logistics storage. | |
| Result< void > | configure (int width, int height, int layers, float cellSize, float originX, float originY) |
| Size the factory grid and world mapping. | |
| void | clear () |
| Clear every cell, item, machine, recipe and reset the simulation clock. | |
| Result< int > | registerRecipe (std::string id, int inputType, int inputCount, int outputType, int outputCount, float durationSec) |
| Register or replace a named recipe. | |
| Result< void > | placeBelt (int cx, int cy, int dir, int layer=0) |
Place a belt cell facing dir (0=E,1=S,2=W,3=N) on layer. | |
| Result< void > | clearCell (int cx, int cy, int layer=0) |
| Remove belt/source/sink content from a cell (machines must use removeMachine). | |
| Result< int > | placeMachine (int cx, int cy, int width, int height, std::string_view recipeId, int layer=0) |
| Place a rectangular machine footprint and bind a recipe. | |
| Result< void > | removeMachine (int machineId) |
| Remove a machine by id and free its footprint cells. | |
| Result< void > | placeSource (int cx, int cy, int itemType, float itemsPerSec, int layer=0) |
Place an item emitter that injects itemType onto the eastward adjacent belt. | |
| Result< void > | placeSink (int cx, int cy, int layer=0) |
| Place a sink that destroys items arriving from the westward adjacent belt. | |
| Result< int > | spawnItem (int cx, int cy, int itemType, int layer=0) |
| Spawn one item onto a belt cell at progress 0. | |
| Result< StepReport > | advance (const SimulationStep &step) |
| Advance one fixed logistics step. | |
| Result< StepReport > | advance (float dt) |
| Convenience advance that allocates the next tick from an internal counter. | |
| int | width () const noexcept |
| Grid width in cells. | |
| int | height () const noexcept |
| Grid height in cells. | |
| int | layers () const noexcept |
| Configured floor count. | |
| float | cellSize () const noexcept |
| World units per cell. | |
| float | originX () const noexcept |
| World origin X. | |
| float | originY () const noexcept |
| World origin Y. | |
| SimulationTick | currentTick () const noexcept |
| Last accepted simulation tick. | |
| int | cellKind (int cx, int cy, int layer=0) const noexcept |
| Cell kind at (cx,cy,layer); Empty when out of range. | |
| int | cellDir (int cx, int cy, int layer=0) const noexcept |
| Belt direction at cell, or -1 when not a belt. | |
| int | cellMachine (int cx, int cy, int layer=0) const noexcept |
| Machine id occupying the cell, or -1. | |
| int | itemCount () const noexcept |
| Live item count. | |
| Result< ItemState > | itemAt (int index) const |
| Copy item i; NotFound when index is out of range. | |
| Result< std::vector< float > > | packItemSimFloats () const |
| Pack GPU-friendly floats: [cellX,cellY,progress,dir,type,layer] * itemCount. @cost O(items); amortize once per upload. | |
| Result< std::vector< float > > | packItemWorldFloats () const |
| Pack world positions for CPU draw fallback: [x,y,type] * itemCount. @cost O(items). | |
| int | machineSlotCount () const noexcept |
| Live machine count (includes holes after remove; use machineAt). | |
| Result< MachineState > | machineAt (int index) const |
| Copy machine slot i; NotFound when empty/out of range. | |
| std::string | machineOwnerId (int index) const |
| Stable Production-owner string for machine slot i (empty when invalid). | |
| int | sunkTotal () const noexcept |
| Items destroyed by sinks since configure/clear. | |
| int | craftsTotal () const noexcept |
| Crafts completed since configure/clear. | |
| void | setBeltSpeed (float cellsPerSec) noexcept |
| Default belt speed in cells per second. | |
| float | beltSpeed () const noexcept |
| Current belt speed. | |
| void | setBufferCapacity (int capacity) noexcept |
| Max items stored in a machine input or output buffer. | |
| int | bufferCapacity () const noexcept |
| Current buffer capacity. | |
Public 成员函数 继承自 eve::Module | |
| virtual | ~Module () |
| Module. | |
| virtual std::string | getName () const =0 |
| Returns the name. | |
详细描述
Deterministic 2D factory logistics: belts, discrete items, machine buffers, crafts.
Grid cells are the authority for belt topology. Items are a dense SoA (not one ECS entity per cargo). Machines own input/output buffers and an optional in-module craft timer; they expose machineOwnerId so a game can project the same work onto production WorkQueues.
Layer 0 is the only active floor in the vertical slice; configure accepts layers so a later multi-floor / 3D host can reuse the same cell addressing (x,y,layer).
@thread Simulation owner thread only. @reentrancy No callbacks; no graphics includes.
在文件 Logistics.h 第 82 行定义.
构造及析构函数说明
◆ Logistics()
|
default |
Construct an empty unconfigured logistics world.
◆ ~Logistics()
|
overridedefault |
Destroy logistics storage.
成员函数说明
◆ advance() [1/2]
| Result< StepReport > eve::logistics::Logistics::advance | ( | const SimulationStep & | step | ) |
Advance one fixed logistics step.
- 参数
-
step External tick must be strictly increasing; dt must be positive and finite. @cost O(items + machines + sources); amortize once per simulation tick.
在文件 Logistics.cpp 第 570 行定义.
引用了 eve::Conflict, dt, eve::logistics::StepReport::elapsed, eve::Result< T >::failure(), eve::InvalidArgument, eve::Result< void >::ok(), step, eve::Result< T >::success(), eve::logistics::StepReport::tick , 以及 eve::detail::StrongUint64< Tag >::value().
被这些函数引用 advance().
◆ advance() [2/2]
| Result< StepReport > eve::logistics::Logistics::advance | ( | float | dt | ) |
Convenience advance that allocates the next tick from an internal counter.
- 备注
- Prefer
advance(SimulationStep)for replay; this path is for demos/tests.
在文件 Logistics.cpp 第 588 行定义.
引用了 advance(), dt, duration, eve::Result< T >::failure(), eve::Duration::fromSeconds(), eve::InvalidArgument , 以及 eve::detail::StrongUint64< Tag >::value().
◆ beltSpeed()
|
inlinenoexcept |
Current belt speed.
在文件 Logistics.h 第 202 行定义.
◆ bufferCapacity()
|
inlinenoexcept |
Current buffer capacity.
在文件 Logistics.h 第 206 行定义.
◆ cellDir()
|
noexcept |
Belt direction at cell, or -1 when not a belt.
在文件 Logistics.cpp 第 395 行定义.
引用了 eve::logistics::Belt, cell, cx, cy , 以及 layer.
◆ cellKind()
|
noexcept |
Cell kind at (cx,cy,layer); Empty when out of range.
在文件 Logistics.cpp 第 390 行定义.
引用了 cx, cy, eve::logistics::Empty , 以及 layer.
◆ cellMachine()
|
noexcept |
Machine id occupying the cell, or -1.
在文件 Logistics.cpp 第 401 行定义.
引用了 cell, cx, cy, layer , 以及 eve::logistics::Machine.
◆ cellSize()
|
inlinenoexcept |
◆ clear()
| void eve::logistics::Logistics::clear | ( | ) |
Clear every cell, item, machine, recipe and reset the simulation clock.
在文件 Logistics.cpp 第 62 行定义.
引用了 eve::detail::StrongUint64< detail::SimulationTickTag >::zero().
◆ clearCell()
| Result< void > eve::logistics::Logistics::clearCell | ( | int | cx, |
| int | cy, | ||
| int | layer = 0 |
||
| ) |
Remove belt/source/sink content from a cell (machines must use removeMachine).
在文件 Logistics.cpp 第 149 行定义.
引用了 cell, eve::Conflict, cx, cy, eve::InvalidArgument, layer, eve::logistics::Machine, eve::Result< void >::ok() , 以及 eve::Result< T >::success().
◆ configure()
| Result< void > eve::logistics::Logistics::configure | ( | int | width, |
| int | height, | ||
| int | layers, | ||
| float | cellSize, | ||
| float | originX, | ||
| float | originY | ||
| ) |
Size the factory grid and world mapping.
- 参数
-
width Cell count on X (>0). height Cell count on Y (>0). layers Floor count (>=1); only layer 0 is stepped in this slice. cellSize World units per cell (>0). originX World X of cell (0,0) top-left corner. originY World Y of cell (0,0) top-left corner.
- 返回
- InvalidArgument for non-positive sizes; Applied on success (clears prior state). @cost Allocates O(width*height*layers) cell storage; amortize at factory rebuild.
在文件 Logistics.cpp 第 30 行定义.
引用了 cellSize(), height(), eve::InvalidArgument, layers(), originX(), originY(), eve::Result< T >::success(), width() , 以及 eve::detail::StrongUint64< detail::SimulationTickTag >::zero().
◆ craftsTotal()
|
inlinenoexcept |
Crafts completed since configure/clear.
在文件 Logistics.h 第 197 行定义.
◆ currentTick()
|
inlinenoexcept |
Last accepted simulation tick.
在文件 Logistics.h 第 163 行定义.
◆ height()
|
inlinenoexcept |
◆ itemAt()
Copy item i; NotFound when index is out of range.
在文件 Logistics.cpp 第 318 行定义.
引用了 index, itemCount(), eve::NotFound , 以及 eve::Result< T >::success().
被这些函数引用 packItemWorldFloats().
◆ itemCount()
|
inlinenoexcept |
Live item count.
在文件 Logistics.h 第 173 行定义.
被这些函数引用 itemAt(), packItemSimFloats() , 以及 packItemWorldFloats().
◆ layers()
|
inlinenoexcept |
◆ machineAt()
| Result< MachineState > eve::logistics::Logistics::machineAt | ( | int | index | ) | const |
Copy machine slot i; NotFound when empty/out of range.
在文件 Logistics.cpp 第 364 行定义.
引用了 eve::logistics::MachineState::id, index, eve::logistics::Machine, eve::NotFound, out , 以及 eve::Result< T >::success().
◆ machineOwnerId()
| std::string eve::logistics::Logistics::machineOwnerId | ( | int | index | ) | const |
Stable Production-owner string for machine slot i (empty when invalid).
在文件 Logistics.cpp 第 384 行定义.
引用了 index , 以及 eve::logistics::Machine.
◆ machineSlotCount()
|
inlinenoexcept |
Live machine count (includes holes after remove; use machineAt).
在文件 Logistics.h 第 188 行定义.
◆ Module_REG()
| eve::logistics::Logistics::Module_REG | ( | Logistics | ) |
◆ originX()
|
inlinenoexcept |
◆ originY()
|
inlinenoexcept |
◆ packItemSimFloats()
| Result< std::vector< float > > eve::logistics::Logistics::packItemSimFloats | ( | ) | const |
Pack GPU-friendly floats: [cellX,cellY,progress,dir,type,layer] * itemCount. @cost O(items); amortize once per upload.
在文件 Logistics.cpp 第 331 行定义.
引用了 itemCount() , 以及 out.
◆ packItemWorldFloats()
| Result< std::vector< float > > eve::logistics::Logistics::packItemWorldFloats | ( | ) | const |
Pack world positions for CPU draw fallback: [x,y,type] * itemCount. @cost O(items).
在文件 Logistics.cpp 第 346 行定义.
引用了 itemAt(), itemCount(), out, state, eve::logistics::ItemState::type, eve::logistics::ItemState::x , 以及 eve::logistics::ItemState::y.
◆ placeBelt()
| Result< void > eve::logistics::Logistics::placeBelt | ( | int | cx, |
| int | cy, | ||
| int | dir, | ||
| int | layer = 0 |
||
| ) |
Place a belt cell facing dir (0=E,1=S,2=W,3=N) on layer.
在文件 Logistics.cpp 第 133 行定义.
引用了 eve::logistics::Belt, cell, eve::Conflict, cx, cy, dir, eve::InvalidArgument, layer, eve::logistics::Machine, eve::Result< void >::ok() , 以及 eve::Result< T >::success().
◆ placeMachine()
| Result< int > eve::logistics::Logistics::placeMachine | ( | int | cx, |
| int | cy, | ||
| int | width, | ||
| int | height, | ||
| std::string_view | recipeId, | ||
| int | layer = 0 |
||
| ) |
Place a rectangular machine footprint and bind a recipe.
- 返回
- Stable machine id (>=0).
- 备注
- Input port faces west of origin; output port faces east of origin+width-1.
在文件 Logistics.cpp 第 161 行定义.
引用了 cell, eve::Conflict, cx, cy, eve::logistics::Empty, eve::Result< T >::failure(), height(), eve::InvalidArgument, kind, layer, eve::logistics::Machine, eve::NotFound, eve::Result< void >::ok(), slot, eve::Result< T >::success(), width(), x , 以及 y.
◆ placeSink()
| Result< void > eve::logistics::Logistics::placeSink | ( | int | cx, |
| int | cy, | ||
| int | layer = 0 |
||
| ) |
Place a sink that destroys items arriving from the westward adjacent belt.
在文件 Logistics.cpp 第 239 行定义.
引用了 cell, eve::Conflict, cx, cy, eve::InvalidArgument, layer, eve::logistics::Machine, eve::Result< void >::ok(), eve::logistics::Sink , 以及 eve::Result< T >::success().
◆ placeSource()
| Result< void > eve::logistics::Logistics::placeSource | ( | int | cx, |
| int | cy, | ||
| int | itemType, | ||
| float | itemsPerSec, | ||
| int | layer = 0 |
||
| ) |
Place an item emitter that injects itemType onto the eastward adjacent belt.
在文件 Logistics.cpp 第 222 行定义.
引用了 cell, eve::Conflict, cx, cy, eve::logistics::East, eve::InvalidArgument, layer, eve::logistics::Machine, eve::Result< void >::ok(), eve::logistics::Source , 以及 eve::Result< T >::success().
◆ registerRecipe()
| Result< int > eve::logistics::Logistics::registerRecipe | ( | std::string | id, |
| int | inputType, | ||
| int | inputCount, | ||
| int | outputType, | ||
| int | outputCount, | ||
| float | durationSec | ||
| ) |
◆ removeMachine()
| Result< void > eve::logistics::Logistics::removeMachine | ( | int | machineId | ) |
Remove a machine by id and free its footprint cells.
在文件 Logistics.cpp 第 206 行定义.
引用了 eve::logistics::Machine, eve::NotFound, eve::Result< void >::ok(), eve::Result< T >::success(), x , 以及 y.
◆ setBeltSpeed()
|
inlinenoexcept |
Default belt speed in cells per second.
在文件 Logistics.h 第 200 行定义.
◆ setBufferCapacity()
|
inlinenoexcept |
◆ spawnItem()
| Result< int > eve::logistics::Logistics::spawnItem | ( | int | cx, |
| int | cy, | ||
| int | itemType, | ||
| int | layer = 0 |
||
| ) |
Spawn one item onto a belt cell at progress 0.
在文件 Logistics.cpp 第 284 行定义.
引用了 eve::logistics::Belt, cell, eve::Conflict, cx, cy, eve::Result< T >::failure(), index, eve::InvalidArgument, layer, eve::Result< void >::ok() , 以及 eve::Result< T >::success().
◆ sunkTotal()
|
inlinenoexcept |
Items destroyed by sinks since configure/clear.
在文件 Logistics.h 第 195 行定义.
◆ width()
|
inlinenoexcept |
该类的文档由以下文件生成:
- src/modules/logistics/Logistics.h
- src/modules/logistics/Logistics.cpp
Public 成员函数 继承自