载入中...
搜索中...
未找到
PlacementSession.h
浏览该文件的文档.
1#pragma once
2
3// 放置会话:封装「选择建筑 -> 跟随指针 -> 校验 -> 放置 / 拆除」的交互状态。
4// 纯逻辑、不接输入设备;脚本每帧喂指针坐标 / 表面命中,会话内部驱动 Ghost。
5
6#include <string>
7
8namespace eve::building {
9
10class PlacementWorld;
11class Ghost;
12
14public:
16 ~PlacementSession() = default;
17
20
21 void destroy();
22
23 bool startPlacement(PlacementWorld *world, const std::string &buildingId);
24 void stopPlacement();
25 bool isActive() const { return active_; }
26 PlacementWorld *getWorld() const { return world_; }
27 std::string getBuildingId() const;
28 Ghost *getGhost() const { return ghost_; }
29
31 void setMode(const std::string &mode);
32 std::string getMode() const { return mode_; }
33
34 void setRotationDeg(float deg);
35 void rotateBy(float deltaDeg);
36 float getRotationDeg() const;
37
39 bool updateFromWorld(PlacementWorld *world, float worldX, float worldY);
41 bool updateFromWorld3D(PlacementWorld *world, float worldX, float worldY, float worldZ);
43 bool updateFromSurface(PlacementWorld *world, const std::string &surface, float x, float y);
44
45 bool isValid() const;
46 std::string getReason() const;
47
53 int execute();
54
55private:
56 void refreshValidate();
57
58 PlacementWorld *world_ = nullptr;
59 Ghost *ghost_ = nullptr;
60 std::string mode_ = "place";
61 bool active_ = false;
62};
63
64} // namespace eve::building
int y
Definition Grass.cpp:135
int x
Definition Grass.cpp:135
PlacementSession(const PlacementSession &)=delete
PlacementWorld * getWorld() const
void setMode(const std::string &mode)
bool startPlacement(PlacementWorld *world, const std::string &buildingId)
bool updateFromWorld3D(PlacementWorld *world, float worldX, float worldY, float worldZ)
PlacementSession & operator=(const PlacementSession &)=delete
bool updateFromWorld(PlacementWorld *world, float worldX, float worldY)
bool updateFromSurface(PlacementWorld *world, const std::string &surface, float x, float y)
格子型建筑放置世界(脚本可直接操作)。
建筑放置模块入口:定义 / 放置世界 / 鬼影 / 变更事件的脚本绑定点。 设计文档:docs/dev/建筑放置系统设计.md
Definition Building.cpp:7