载入中...
搜索中...
未找到
Ghost.h
浏览该文件的文档.
1#pragma once
2
3// 鬼影预览:候选建筑姿态 + 最近一次校验结果,供 UI 着色与确认放置。
4
6
7#include <string>
8
9namespace eve::building {
10
11class PlacementWorld;
12
13class Ghost {
14public:
15 Ghost() = default;
16 ~Ghost() = default;
17
18 void destroy();
19
20 std::string getBuildingId() const { return buildingId_; }
21 void setBuildingId(const std::string &id);
22
23 int getCellX() const { return cellX_; }
24 int getCellY() const { return cellY_; }
25 void setCell(int cellX, int cellY);
26
27 float getWorldX() const { return worldX_; }
28 float getWorldY() const { return worldY_; }
29 void setWorld(float worldX, float worldY);
30 float getElevation() const { return elevation_; }
31 void setElevation(float elevation);
32
33 float getRotationDeg() const { return rotationDeg_; }
34 void setRotationDeg(float deg);
35 void rotateBy(float deltaDeg);
36
37 bool isValid() const { return valid_; }
38 std::string getReason() const { return reason_; }
39
41 void setFromWorld(PlacementWorld *world, float worldX, float worldY);
43 void setFromWorld3D(PlacementWorld *world, float worldX, float worldY, float worldZ);
45 void setFromSurface(PlacementWorld *world, const std::string &surface, float x, float y);
47 bool validate(PlacementWorld *world);
48
49private:
50 friend class PlacementSystem;
51
52 std::string buildingId_;
53 int cellX_ = 0;
54 int cellY_ = 0;
55 float worldX_ = 0.f;
56 float worldY_ = 0.f;
57 float elevation_ = 0.f;
58 float rotationDeg_ = 0.f;
59 bool valid_ = false;
60 std::string reason_;
61};
62
63} // namespace eve::building
int y
Definition Grass.cpp:135
int x
Definition Grass.cpp:135
float getElevation() const
Definition Ghost.h:30
int getCellY() const
Definition Ghost.h:24
float getWorldY() const
Definition Ghost.h:28
void setFromWorld(PlacementWorld *world, float worldX, float worldY)
按世界吸附模式,从世界坐标刷新格子与世界位姿。
Definition Ghost.cpp:45
void setRotationDeg(float deg)
Definition Ghost.cpp:35
int getCellX() const
Definition Ghost.h:23
void setElevation(float elevation)
Definition Ghost.cpp:29
bool validate(PlacementWorld *world)
对当前姿态做校验,写入 valid_/reason_。
Definition Ghost.cpp:80
void setFromWorld3D(PlacementWorld *world, float worldX, float worldY, float worldZ)
Definition Ghost.cpp:57
std::string getReason() const
Definition Ghost.h:38
bool isValid() const
Definition Ghost.h:37
float getWorldX() const
Definition Ghost.h:27
float getRotationDeg() const
Definition Ghost.h:33
std::string getBuildingId() const
Definition Ghost.h:20
void setWorld(float worldX, float worldY)
Definition Ghost.cpp:22
void rotateBy(float deltaDeg)
Definition Ghost.cpp:41
void setCell(int cellX, int cellY)
Definition Ghost.cpp:15
void setFromSurface(PlacementWorld *world, const std::string &surface, float x, float y)
Definition Ghost.cpp:69
void setBuildingId(const std::string &id)
Definition Ghost.cpp:9
格子型建筑放置世界(脚本可直接操作)。
建筑放置模块入口:定义 / 放置世界 / 鬼影 / 变更事件的脚本绑定点。 设计文档:docs/dev/建筑放置系统设计.md
Definition Building.cpp:7