载入中...
搜索中...
未找到
ModuleAssemblyScript.cpp
浏览该文件的文档.
2#include <simplesquirrel/simplesquirrel.hpp>
5
6namespace eve::procgen {
7void exposeModuleAssembly(ssq::Table& table) {
8 auto vm = table.getHandle();
9 auto assembly = table.addClass<ModuleAssemblyPlan>(
10 "ProcgenModuleAssemblyPlan", std::function<ModuleAssemblyPlan*()>([] { return new ModuleAssemblyPlan(); }),
11 true);
12 assembly.addFunc(
13 "configure", [vm](ModuleAssemblyPlan* value, float cellSize, float floorHeight, int minCellX, int maxCellX,
14 int minCellZ, int maxCellZ, int maxLevels, bool bounded, bool requireConnection) {
15 return eve::script::projectResult(vm, value->configure(cellSize, floorHeight, minCellX, maxCellX, minCellZ,
16 maxCellZ, maxLevels, bounded, requireConnection));
17 });
18 assembly.addFunc(
19 "setAllowedQuarterTurns", [vm](ModuleAssemblyPlan* value, bool turn0, bool turn90, bool turn180, bool turn270) {
20 return eve::script::projectResult(vm, value->setAllowedQuarterTurns(turn0, turn90, turn180, turn270));
21 });
22 assembly.addFunc("setMinimumSupportRatio", [vm](ModuleAssemblyPlan* value, float ratio) {
23 return eve::script::projectResult(vm, value->setMinimumSupportRatio(ratio));
24 });
25 assembly.addFunc("applyConfigJson", [vm](ModuleAssemblyPlan* value, const std::string& json) {
26 return eve::script::projectResult(vm, value->applyConfigJson(json));
27 });
28 assembly.addFunc("registerModule",
29 [vm](ModuleAssemblyPlan* value, const std::string& id, int widthCells, int depthCells) {
30 return eve::script::projectResult(vm, value->registerModuleType(id, widthCells, depthCells));
31 });
32 assembly.addFunc("registerVolumeModule", [vm](ModuleAssemblyPlan* value, const std::string& id, int widthCells,
33 int depthCells, int heightLevels) {
35 value->registerVolumeModuleType(id, widthCells, depthCells, heightLevels));
36 });
37 assembly.addFunc("addConnector", [vm](ModuleAssemblyPlan* value, const std::string& id, int cellX, int cellZ,
38 int facing, const std::string& tag, const std::string& accepts) {
39 return eve::script::projectResult(vm, value->addConnector(id, cellX, cellZ, facing, tag, accepts));
40 });
41 assembly.addFunc("addVolumeConnector",
42 [vm](ModuleAssemblyPlan* value, const std::string& id, int cellX, int cellZ, int levelOffset,
43 int facing, const std::string& tag, const std::string& accepts) {
45 vm, value->addVolumeConnector(id, cellX, cellZ, levelOffset, facing, tag, accepts));
46 });
47 assembly.addFunc("place", [vm](ModuleAssemblyPlan* value, const std::string& id, int cellX, int cellZ, int level,
48 int quarterTurn) {
49 return eve::script::projectResult(vm, value->place({id, cellX, cellZ, level, quarterTurn}));
50 });
51 assembly.addFunc("getPlacementCount", [](ModuleAssemblyPlan* value) { return value->getPlacementCount(); });
52 assembly.addFunc("getPlacementModule",
53 [](ModuleAssemblyPlan* value, int index) { return value->getPlacementModule(index); });
54 assembly.addFunc("getPlacementX", [](ModuleAssemblyPlan* value, int index) { return value->getPlacementX(index); });
55 assembly.addFunc("getPlacementY", [](ModuleAssemblyPlan* value, int index) { return value->getPlacementY(index); });
56 assembly.addFunc("getPlacementZ", [](ModuleAssemblyPlan* value, int index) { return value->getPlacementZ(index); });
57 assembly.addFunc("getPlacementYawDegrees",
58 [](ModuleAssemblyPlan* value, int index) { return value->getPlacementYawDegrees(index); });
59}
60} // namespace eve::procgen
double value
HSQUIRRELVM vm
Definition ECS.cpp:20
const std::string * accepts
ModuleFacing facing
int level
const std::string * tag
The single Squirrel projection for common Result, Status and Value.
uint32_t index
Deterministic owner of a validated modular assembly plan.
void exposeModuleAssembly(ssq::Table &table)
Bind the VM-owned assembly planner synchronously on the VM owner thread.
ssq::Table projectResult(HSQUIRRELVM vm, Result< void > &&result)
Consume and project a void native Result using the common schema.