载入中...
搜索中...
未找到
HexTerrainAbsent.cpp
浏览该文件的文档.
1
7
8#include "common/Diagnostic.h"
9#include "common/Result.h"
11#include "common/Value.h"
13#include "procgen/Procgen.h"
15
16#include <simplesquirrel/simplesquirrel.hpp>
17
18#include <string>
19
20namespace eve::procgen {
21namespace {
22
23[[nodiscard]] Result<Value> missingAlgorithm(const char* name) {
25 DiagnosticCode::NotFound, std::string(name) + " requires the hexmap module", "algorithm", {}, "procgen"));
26}
27
28} // namespace
29
30void registerHexTerrainAlgorithms(GeneratorRegistry&) {}
31
32Result<Value> generateHexTerrain(const Params&) { return missingAlgorithm("generateHexTerrain"); }
33
34Result<Value> generateHexSphere(const Params&) { return missingAlgorithm("generateHexSphere"); }
35
36void exposeHexTerrain(ssq::Class& cls) {
37 const auto missing = [](HSQUIRRELVM vm, const char* name) {
38 return eve::script::projectResult(vm, missingAlgorithm(name), [](Value value) { return value; });
39 };
40 cls.addFunc("generateHexTerrain", [vm = cls.getHandle(), missing](Procgen*, ScriptProcgenParams*) -> ssq::Table {
41 return missing(vm, "generateHexTerrain");
42 });
43 cls.addFunc("generateHexSphere", [vm = cls.getHandle(), missing](Procgen*, ScriptProcgenParams*) -> ssq::Table {
44 return missing(vm, "generateHexSphere");
45 });
46}
47
48} // namespace eve::procgen
double value
struct SQVM * HSQUIRRELVM
Stable, structured diagnostics shared by engine modules.
HSQUIRRELVM vm
Definition ECS.cpp:20
HSQOBJECT cls
Definition ECS.cpp:21
Optional hexmap terrain bake bindings for Procgen.
std::string name
Move-only, checked operation results for the common layer.
The single Squirrel projection for common Result, Status and Value.
Owning, renderer-independent dynamic values.
static Diagnostic error(DiagnosticCode code, std::string message, std::string path={}, DiagnosticDetails details={}, std::string source={})
Construct an error diagnostic with the standard error severity.
Definition Diagnostic.h:125
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:175
void registerHexTerrainAlgorithms(GeneratorRegistry &registry)
Register hex.terrain / hex.sphere schemas when hexmap is present.
Result< Value > generateHexTerrain(const Params &params)
Bake a planar hex map into the script Value hexmap applies.
Result< Value > generateHexSphere(const Params &params)
Bake a spherical hex map into the script Value hexmap applies.
void exposeHexTerrain(ssq::Class &cls)
Expose generateHexTerrain / generateHexSphere on the Procgen class.
ssq::Table projectResult(HSQUIRRELVM vm, Result< void > &&result)
Consume and project a void native Result using the common schema.