载入中...
搜索中...
未找到
GridGraph.h
浏览该文件的文档.
1#pragma once
3
5#include "procgen/Grid2D.h"
6#include "procgen/PointSet.h"
7
8#include <cstdint>
9#include <memory>
10#include <string>
11#include <string_view>
12#include <unordered_map>
13#include <variant>
14#include <vector>
15
16namespace eve::procgen {
17
18class PointGraph;
19
21using GridGraphValue = std::variant<Grid2D, PointSet>;
22
24enum class GridGraphValueType : std::uint8_t { Grid, PointSet };
25
37public:
39 [[nodiscard]] Result<void> addNode(std::string id, std::string operation);
41 [[nodiscard]] Result<void> connect(std::string_view fromId, std::string_view toId, int inputIndex = 0);
43 [[nodiscard]] Result<void> setNodeGrid(std::string_view id, const Grid2D& grid);
45 [[nodiscard]] Result<void> setNodeInt(std::string_view id, std::string key, int value);
47 [[nodiscard]] Result<void> setNodeFloat(std::string_view id, std::string key, float value);
49 [[nodiscard]] Result<void> setNodeString(std::string_view id, std::string key, std::string value);
55 [[nodiscard]] Result<void> setNodePointSubgraph(std::string_view id, const PointGraph& graph, std::string inputNode,
56 std::string outputNode);
57
63 [[nodiscard]] Result<GridGraphValue> execute(std::string_view outputId);
65 [[nodiscard]] Result<void> validate(std::string_view outputId) const;
67 void clearCache();
69 [[nodiscard]] std::uint64_t revision() const noexcept { return revision_; }
71 [[nodiscard]] std::string serializeDefinition() const;
73 [[nodiscard]] Result<void> deserializeDefinition(std::string_view definition);
74
76 [[nodiscard]] static int operationCount();
78 [[nodiscard]] static std::string operationId(int index);
80 [[nodiscard]] static Result<GridGraphValueType> operationOutputType(std::string_view operation);
81
82private:
83 struct Node {
84 std::string id;
85 std::string operation;
86 std::string inputs[3];
87 std::unordered_map<std::string, int> ints;
88 std::unordered_map<std::string, float> floats;
89 std::unordered_map<std::string, std::string> strings;
90 Grid2D inputGrid;
91 bool hasInputGrid = false;
92 std::shared_ptr<PointGraph> pointSubgraph;
93 std::string pointInputNode;
94 std::string pointOutputNode;
95 GridGraphValue cache;
96 bool cacheValid = false;
97 };
98
99 [[nodiscard]] ResultRef<const GridGraphValue> evaluate(std::string_view id,
100 std::unordered_map<std::string, int>& states);
101 void invalidateFrom(std::string_view id);
102
103 std::unordered_map<std::string, Node> nodes_;
104 std::vector<std::string> order_;
105 std::uint64_t revision_ = 0;
106};
107
108} // namespace eve::procgen
ActionParameterOperation operation
Vocabulary aliases for nullable and checked borrowed references.
SQObjectPtr key
Definition ECS.cpp:155
EnvironmentTest definition
#define EVENGINE_API_DOMAINS
Definition Export.h:110
int inputs
Definition GridGraph.cpp:23
std::string id
ScriptMotionSinkStore< ScriptMotionFloatSink > floats
std::map< std::string, std::vector< std::string > > graph
Definition Package.cpp:173
Object::Ptr value
Share string attribute map operations through the Windows Foundation DLL.
uint32_t index
Move-only operation result carrying either a value or Status.
Definition Result.h:176
Intermediate 2D generation result. cells store semantic ids (see Semantic.h), not tile GIDs — convert...
Definition Grid2D.h:37
Deterministic data-flow graph for grid generation and explicit grid-to-point composition.
Definition GridGraph.h:36
std::uint64_t revision() const noexcept
Monotonic authoring revision; successful mutations increment it.
Definition GridGraph.h:69
EVENGINE_API_DOMAINS public API.
Definition PointGraph.h:67
Script-friendly collection of attributed 3D samples.
Definition PointSet.h:59
GridGraphValueType
Declared output kind of a GridGraph operation.
Definition GridGraph.h:24
std::variant< Grid2D, PointSet > GridGraphValue
Strong runtime value passed between typed GridGraph ports.
Definition GridGraph.h:21