载入中...
搜索中...
未找到
BuildingTypes.h
浏览该文件的文档.
1#pragma once
2
8#include <cstdint>
9#include <string>
10#include <unordered_map>
11#include <vector>
12
13namespace eve::building {
14
17 std::string id;
18 std::string displayName;
19 std::string category;
22 std::string channel;
24 std::string renderMode;
25 int footprintW = 1;
26 int footprintH = 1;
28 std::vector<uint8_t> footprintMask;
30 std::string snapMode = "grid";
32 std::string rotationMode = "cardinal";
34 std::string validateRule = "default";
35 std::vector<std::string> tags;
37 std::vector<int> requireTerrain;
38 std::vector<int> forbidTerrain;
40 std::string requireAdjacentTag;
43 std::unordered_map<std::string, int> cost;
44 std::unordered_map<std::string, std::string> extra;
46 std::unordered_map<std::string, std::string> visual2d;
48 std::unordered_map<std::string, std::string> visual3d;
49
51 bool hasTag(const std::string &tag) const;
52 std::string getExtra(const std::string &key, const std::string &fallback = {}) const;
53 std::string getVisual2d(const std::string &key, const std::string &fallback = {}) const;
54 std::string getVisual3d(const std::string &key, const std::string &fallback = {}) const;
55 int getCost(const std::string &resource, int fallback = 0) const;
57 bool maskAt(int localX, int localY) const;
58};
59
62 int instanceId = 0;
63 std::string buildingId;
64 int originCellX = 0;
65 int originCellY = 0;
66 float worldX = 0.f;
67 float worldY = 0.f;
69 float elevation = 0.f;
70 float rotationDeg = 0.f;
71 std::string channel;
72 std::unordered_map<std::string, std::string> props;
73 std::vector<std::string> tags;
74
75 bool hasTag(const std::string &tag) const;
76 std::string getProp(const std::string &key, const std::string &fallback = {}) const;
77 void setProp(const std::string &key, const std::string &value);
78};
79
82 std::string action;
83 std::string worldId;
84 std::string buildingId;
85 int instanceId = 0;
86 int cellX = -1;
87 int cellY = -1;
88 int otherCellX = -1;
89 int otherCellY = -1;
90 float rotationDeg = 0.f;
91 float worldX = 0.f;
92 float worldY = 0.f;
93 float elevation = 0.f;
94 std::string channel;
95};
96
99 std::string buildingId;
100 int cellX = 0;
101 int cellY = 0;
102 float worldX = 0.f;
103 float worldY = 0.f;
104 float elevation = 0.f;
105 float rotationDeg = 0.f;
107};
108
111 int cellX = 0;
112 int cellY = 0;
113 float worldX = 0.f;
114 float worldY = 0.f;
115 float elevation = 0.f;
116};
117
118} // namespace eve::building
std::string value
建筑放置模块入口:定义 / 放置世界 / 鬼影 / 变更事件的脚本绑定点。 设计文档:docs/dev/建筑放置系统设计.md
Definition Building.cpp:7
一次成功放置变更的事件(供脚本 poll / C++ hook)。
std::string action
place / remove / move / rotate
建筑模板(进程级注册表中的定义)。
std::unordered_map< std::string, std::string > visual2d
std::unordered_map< std::string, int > cost
std::unordered_map< std::string, std::string > visual3d
std::string channel
占地格子尺寸。
bool maskAt(int localX, int localY) const
占地掩码在局部坐标 (localX, localY) 处是否占用。
std::unordered_map< std::string, std::string > extra
std::string requireAdjacentTag
非空:邻格需有带该 tag 的建筑。
std::vector< int > requireTerrain
空 = 不限制地形语义。
std::string getVisual2d(const std::string &key, const std::string &fallback={}) const
std::string rotationMode
none | cardinal | free。
std::string validateRule
default | boundsOnly | overlapOk | 自定义。
int getCost(const std::string &resource, int fallback=0) const
std::string getExtra(const std::string &key, const std::string &fallback={}) const
std::string snapMode
grid | cell | free | 自定义。
std::vector< uint8_t > footprintMask
可选占地掩码,长度 footprintW*footprintH;空表示实心矩形。行主序、原点在最小 x/y。
bool hasTag(const std::string &tag) const
查询辅助。
std::vector< std::string > tags
int requireAdjacentTerrain
>=0:邻格地形语义;-1 = 不限。
std::string getVisual3d(const std::string &key, const std::string &fallback={}) const
已放置的建筑实例。
std::vector< std::string > tags
void setProp(const std::string &key, const std::string &value)
std::string getProp(const std::string &key, const std::string &fallback={}) const
std::unordered_map< std::string, std::string > props
bool hasTag(const std::string &tag) const
校验上下文:传给可插拔规则。
int excludeInstanceId
move 时排除自身占用