载入中...
搜索中...
未找到
BuildingAssembly.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
3
6#include "common/Identity.h"
8
9#include <memory>
10#include <span>
11
12namespace eve::building {
13class PlacementWorld;
14struct PreparedAssemblyData;
15
17struct AssemblyIdTag {};
21 uint32_t value = 0;
22 bool operator==(const BlueprintPartId&) const = default;
23};
32 int x = 0;
33 int y = 0;
34 int level = 0;
35 int quarterTurns = 0;
36 float elevation = 0.f;
37};
50 uint64_t version = 1;
51 float cellSize = 1.f;
52 float floorHeight = 3.f;
53 std::vector<BlueprintPart> parts;
54 std::vector<codec::EdgeCurvePayload> curves;
56};
74public:
76 PreparedAssembly& operator=(PreparedAssembly&&) noexcept;
79 PreparedAssembly& operator=(const PreparedAssembly&) = delete;
81 std::span<const PlacedBuilding> preview() const;
82
83private:
84 friend class AssemblyService;
85 friend EVENGINE_API_WORLD Result<Value> executeHouseRequest(PlacementWorld& world, const Value& request);
86 explicit PreparedAssembly(std::unique_ptr<PreparedAssemblyData> data);
87 std::unique_ptr<PreparedAssemblyData> data_;
88};
95
103public:
109 [[nodiscard]] static Result<BuildingBlueprint> capture(const PlacementWorld& world, std::span<const int> members,
116 [[nodiscard]] static Result<PreparedAssembly> preparePlacement(const PlacementWorld& world,
117 const BuildingBlueprint& blueprint, AssemblyId id,
123 [[nodiscard]] static Result<PreparedAssembly> prepareMove(const PlacementWorld& world, AssemblyId id,
129 [[nodiscard]] static Result<PreparedAssembly> prepareRemoval(const PlacementWorld& world, AssemblyId id);
135 [[nodiscard]] static Result<PreparedAssembly> prepareRemodel(const PlacementWorld& world, AssemblyId id,
136 std::span<const PlacedBuilding> members);
142 [[nodiscard]] static Result<AssemblyReceipt> commit(PlacementWorld& world, PreparedAssembly token);
144 [[nodiscard]] static Result<BuildingAssembly> assembly(const PlacementWorld& world, AssemblyId id);
146 [[nodiscard]] static Result<BuildingAssembly> resolve(const PlacementWorld& world, AssemblyHandle handle);
148 [[nodiscard]] static Result<AssemblyHandle> handle(const PlacementWorld& world, AssemblyId id);
150 static std::optional<AssemblyId> owner(const PlacementWorld& world, int member);
152 static std::vector<AssemblyId> assemblies(const PlacementWorld& world);
157 [[nodiscard]] static Result<Value> encodeBlueprint(const BuildingBlueprint& blueprint);
162 [[nodiscard]] static Result<BuildingBlueprint> decodeBlueprint(const Value& value);
167 [[nodiscard]] static Result<Value> snapshotWorld(const PlacementWorld& world);
172 [[nodiscard]] static Result<void> restoreWorld(PlacementWorld& world, const Value& value);
177 [[nodiscard]] static Result<void> applyReceipt(PlacementWorld& world, const Value& expected, const Value& desired);
178
179private:
180 static Value admissionStamp(const PlacementWorld& world);
181 static Result<PreparedAssembly> prepareState(const PlacementWorld& world, std::unique_ptr<PlacementWorld> candidate,
182 AssemblyId id);
183 static Result<void> validateFinal(PlacementWorld& world);
184 static Result<std::unique_ptr<PlacementWorld>> decodeWorld(const Value& value);
185};
186} // namespace eve::building
eve::EntitySpatialPose pose
#define EVENGINE_API_WORLD
Definition Export.h:109
const GltfImportRequest & request
Strong identity values shared by persistence, content and logical-name APIs.
OceanGpuFrameToken token
std::shared_ptr< OceanGpuSpectrum > owner
glm::dvec3 origin
PrimitiveHandle handle
Object::Ptr value
Strong generation-qualified handles for non-ECS runtime registries.
float(ui::Theme::* member)[4]
std::map< std::string, std::span< const std::uint8_t > > members
Move-only operation result carrying either a value or Status.
Definition Result.h:176
Process-local slot identity tagged by the registry that owns it.
Canonical house composition, blueprint and persistence operations. @thread World/registry owner-threa...
格子型建筑放置世界(脚本可直接操作)。
Move-only proof of a fully validated house operation. @ownership Owns its candidate; destruction canc...
PreparedAssembly(PreparedAssembly &&) noexcept
EVENGINE_API_FOUNDATION public API.
Definition Json.h:39
建筑放置模块入口:定义 / 放置世界 / 鬼影 / 变更事件的脚本绑定点。 设计文档:docs/dev/建筑放置系统设计.md
Definition Building.cpp:10
Owner-scoped, generation-checked runtime identity of a house.
eve::RuntimeHandle< AssemblyHandleTag > slot
Persistent identity of one placed house; distinct from a blueprint asset.
Integer grid-vertex origin, floor offset and quarter turns: (x,y) maps to (y,-x) for one turn.
Owning before/after domain states for exact, conflict-checked undo and redo.
Stable blueprint-local part key, preserved through capture and instantiation.
bool operator==(const BlueprintPartId &) const =default
One owning local part, independent of the source world and its runtime ids.
BuildingInstanceSnapshot local
Owning house membership; poses remain authoritative on the world instances.
std::map< uint32_t, int > members
uint32_t nextPartKey
Monotonic local identity; deleted part keys are never reused.
Versioned house recipe; admission validates all fields before use. @ownership Owns local parts,...
std::vector< BlueprintPart > parts
std::vector< codec::EdgeCurvePayload > curves
Complete runtime-neutral placed-building snapshot.
已放置的建筑实例。