Skip to content

Commit 7938386

Browse files
authored
Merge branch 'eesast:dev' into dev
2 parents 50f1ce6 + 07d6595 commit 7938386

4 files changed

Lines changed: 185 additions & 60 deletions

File tree

dependency/proto/Message2Clients.proto

Lines changed: 90 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -17,32 +17,36 @@ message MessageOfCharacter
1717
CharacterState character_active_state = 5;
1818

1919
// 位置
20-
int32 x = 17;
21-
int32 y = 18;
20+
int32 x = 6;
21+
int32 y = 7;
2222

23-
double facing_direction = 19;
24-
int32 speed = 20;
25-
int32 view_range = 21;
23+
double facing_direction = 8;
24+
int32 speed = 9;
25+
int32 view_range = 10;
2626

27-
int32 common_attack = 22;
28-
int64 common_attack_cd = 23;
29-
int32 common_attack_range = 24;
27+
int32 common_attack = 11;
28+
int64 common_attack_cd = 12;
29+
int32 common_attack_range = 13;
3030

31-
int32 hp = 28;
31+
int32 hp = 14;
32+
33+
int32 carry_capacity = 15; // 负重上限,产品数量为单位
34+
int32 current_load = 16; // 当前负重
35+
int32 harvest_rate_per_sec = 17; // 每秒采集量
3236
}
3337

3438

3539
message MessageOfMaterialResource
3640
{
37-
MaterialResourceState material_resource_state = 2;
38-
39-
int32 x = 3;
40-
int32 y = 4;
41+
MaterialResourceState material_resource_state = 1;
4142

42-
int32 process = 5; // 采集进度 等价于血量
43+
int32 x = 2;
44+
int32 y = 3;
4345

44-
int32 id = 6;
46+
int32 remaining_amount = 4; // 采集进度 等价于血量
4547

48+
int32 id = 5;
49+
int32 max_amount = 6;
4650
}
4751

4852
message MessageOfMap
@@ -65,49 +69,95 @@ message MessageOfTeam
6569
// int64 guid=5;
6670
}
6771

72+
message MessageOfFactory
73+
{
74+
int64 factory_id = 1;
75+
int64 team_id = 2;
76+
int32 x = 3;
77+
int32 y = 4;
78+
int32 hp = 5;
79+
message ProductStack
80+
{
81+
int32 product_type = 1;
82+
int32 quantity = 2;
83+
}
84+
repeated ProductStack product_inventory = 6; //
85+
int32 producing_line_count = 7; // 生产线数量
86+
}
87+
88+
message MessageOfMarket
89+
{
90+
int64 market_id = 1;
91+
int32 x = 2;
92+
int32 y = 3;
93+
bool high_value = 4; // 是否为高额市场
94+
message PriceEntry
95+
{
96+
ProductType product_type = 1;
97+
int32 price = 2;
98+
}
99+
repeated PriceEntry price_list = 5;
100+
}
101+
102+
message MessageOfComputeCenter
103+
{
104+
int64 center_id = 1;
105+
int32 x = 2;
106+
int32 y = 3;
107+
int64 owner_team_id = 4; // 0表示无人占领
108+
int32 occupy_progress = 5; // 占领进度
109+
}
110+
68111
message MessageOfObj
69112
{
70113
oneof message_of_obj
71114
{
72115
MessageOfCharacter character_message = 1;
73-
MessageOfMaterialResource material_resource_message= 6;
74-
MessageOfMap map_message = 8;
75-
MessageOfNews news_message = 9;
76-
MessageOfTeam team_message = 10;
116+
MessageOfMaterialResource material_resource_message= 2;
117+
MessageOfMap map_message = 3;
118+
MessageOfNews news_message = 4;
119+
MessageOfTeam team_message = 5;
120+
MessageOfFactory factory_message = 6;
121+
MessageOfMarket market_message = 7;
122+
MessageOfComputeCenter compute_center_message = 8;
123+
MessageOfAIEvent ai_event_message = 9; //服务器推送的AI事件/建议
77124
}
78125
}
79126

80-
message MessageOfAll
127+
// 智慧大脑事件
128+
message MessageOfAIEvent
81129
{
82-
int32 game_time = 1;
83-
84-
int32 team1_score=2;
85-
int32 team2_score=3;
86-
int32 team3_score=3;
87-
int32 team4_score=3;
130+
int64 team_id = 1;
131+
int64 from_character_id = 2; // 触发来源(可选)
132+
AIEventType event_type = 3; // 事件类型
133+
string description = 4; // 人类可读说明
134+
string plan_json = 5; // 结构化计划(JSON),客户端可以解析执行
135+
int64 timestamp_ms = 6; // 事件触发时间(ms),便于回放
136+
int64 event_id = 7; // 事件id, 便于追踪
137+
}
88138

89-
int32 team1_material = 4;
90-
int32 team2_material = 4;
91-
int32 team3_material = 4;
92-
int32 team4_material = 4;
139+
message MessageOfAll
140+
{
141+
int32 game_time = 1;
93142

94-
int32 team1_computing_power = 5;
95-
int32 team2_computing_power = 5;
96-
int32 team3_computing_power = 5;
97-
int32 team4_computing_power = 5;
143+
message TeamInfo {
144+
int32 score = 1;
145+
int32 material = 2;
146+
int32 computing_power = 3;
147+
int32 factory_hp = 4;
148+
}
98149

99-
int32 team1_factory_hp = 6;
100-
int32 team2_factory_hp = 6;
101-
int32 team3_factory_hp = 6;
102-
int32 team4_factory_hp = 6;
150+
repeated TeamInfo teams = 2; // teams[0] 对应 team1,teams[1] 对应 team2 ...
151+
}
103152

104-
}
105153

106154
message MessageToClient
107155
{
108156
repeated MessageOfObj obj_message = 1;
109157
GameState game_state = 2;
110-
MessageOfAll all_message = 3;
158+
protobuf.GameMode game_mode = 3;
159+
MessageOfAll all_message = 4;
160+
// MessageGameConfig config = 5; // 可用于下发对局参数
111161
}
112162

113163
message MoveRes // 如果打算设计撞墙保留平行速度分量,且需要返回值则可用这个(大概没啥用)

dependency/proto/Message2Server.proto

Lines changed: 52 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,37 @@ message IDMsg
99
{
1010
int64 character_id = 1;
1111
int64 team_id = 2;
12+
protobuf.GameMode mode = 3; // 客户端发起连接/请求时声明希望的游戏模式
1213
}
1314

14-
/*
15-
message CharacterMsg
15+
16+
message RegisterFactoryMsg
1617
{
17-
int64 character_id = 1;
18+
int64 player_id = 1;
1819
int64 team_id = 2;
19-
CharacterType character_type = 3;
20-
int32 side_flag = 4;
20+
protobuf.GameMode mode = 3;
21+
int32 preferred_spawn_index = 4; // 客户端希望的出生点索引(0表示不指定,由服务器分配)
22+
int32 side_flag = 5; // 客户端希望的阵营标识
2123
}
22-
*/
24+
25+
message CreatCharacterMsg
26+
{
27+
CharacterType character_type = 1;
28+
int64 team_id = 2;
29+
int32 birthpoint_index = 3;
30+
protobuf.GameMode mode = 4; // 创建角色时可以指明模式
31+
}
32+
2333

2434
message MaterialResourceMsg
2535
{
2636
int64 character_id = 1;
27-
int64 team_id = 1;
28-
int32 process = 2;
29-
MaterialResourceType material_resource_type = 3;
37+
int64 team_id = 2;
38+
int64 resource_id = 3;
39+
int32 target_x = 4; // 目标坐标,或许可用
40+
int32 target_y = 5;
41+
int32 amount = 6; // 采集数量
42+
//HarvestAction action = 7; // 采集动作类型
3043
}
3144

3245
message MoveMsg
@@ -80,13 +93,6 @@ message RepairFactory
8093
int32 team_id = 2;
8194
}
8295

83-
message CreatCharacterMsg
84-
{
85-
CharacterType character_type = 1;
86-
int64 team_id = 2;
87-
int32 birthpoint_index = 3;
88-
}
89-
9096
message ProduceProductMeg
9197
{
9298
ProductType product_type = 1;
@@ -116,4 +122,34 @@ message SellMeg
116122
int32 costume_num = 6;
117123
int32 food_num = 7;
118124
int32 marketindex = 8;
125+
}
126+
127+
128+
// 智慧大脑相关
129+
message AskAIRequest
130+
{
131+
int64 team_id = 1;
132+
int64 character_id = 2;
133+
string model = 3; // 模型标识
134+
string prompt = 4; // 自然语言提示
135+
int32 timeout_ms = 5; // 超时时间
136+
bool prefer_structured = 6; // 是否优先返回结构化计划
137+
}
138+
139+
message AIAction
140+
{
141+
AIActionType type = 1;
142+
int64 character_id = 2; // 执行者
143+
string target = 3; // 目标说明
144+
string payload_json = 4; // 额外参数(JSON)
145+
int64 eta_ms = 5; // 建议在多少毫秒后执行
146+
}
147+
148+
message AskAIResponse
149+
{
150+
bool act_success = 1;
151+
string answer_text = 2; // 自然语言回答
152+
string plan_json = 3; // 结构化计划(JSON),便于引擎解析执行
153+
repeated AIAction actions = 4; // 可直接执行的动作列表(结构化)
154+
string error_msg = 5; //
119155
}

dependency/proto/MessageType.proto

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22
syntax = "proto3";
33
package protobuf;
44

5+
enum GameMode {
6+
NULL_GAME_MODE = 0;
7+
GAME_MODE_PVE = 1;
8+
GAME_MODE_PVP = 2;
9+
}
10+
11+
512
enum GameState //
613
{
714
NULL_GAME_STATE = 0;
@@ -79,6 +86,15 @@ enum MaterialResourceState //
7986
BEING_HARVESTED = 2;
8087
HARVESTED = 3;
8188
}
89+
/*
90+
enum HarvestAction // 采集动作类型
91+
{
92+
NULL_HARVEST_ACTION = 0;
93+
START_HARVEST = 1;
94+
STOP_HARVEST = 2;
95+
QUERY_HARVEST = 3; // 查询采集状态
96+
}
97+
*/
8298

8399
enum NewsType // 用于角色间通信?或许咱们需要
84100
{
@@ -87,7 +103,7 @@ enum NewsType // 用于角色间通信?或许咱们需要
87103
BINARY = 2;
88104
}
89105

90-
cnum ProductType
106+
enum ProductType
91107
{
92108
NULL_PRODUCT_TYPE = 0;
93109

@@ -96,4 +112,23 @@ cnum ProductType
96112
HANDIWORK = 3;
97113
COSTUME = 4;
98114
FOOD = 5;
115+
}
116+
117+
enum AIEventType {
118+
NULL_AI_EVENT = 0; // 默认值,未指定事件类型
119+
AI_SUGGESTION = 1; // 推荐性建议
120+
AI_EXPLANATION = 2; // 解释性信息
121+
AI_ALERT = 3; // 警告,需要注意的紧急事件
122+
}
123+
124+
enum AIActionType {
125+
UNKNOWN = 0; // 未知或未定义动作
126+
PRODUCE = 1;
127+
HARVEST = 2;
128+
MOVE = 3;
129+
ATTACK = 4;
130+
REPAIR = 5;
131+
SELL = 6;
132+
OCCUPY = 7;
133+
CUSTOM = 100; // 自定义动作:使用 payload_json 等字段描述任意扩展动作
99134
}

dependency/proto/Services.proto

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ service AvailableService
99
rpc TryConnection(IDMsg) returns (BoolRes);
1010

1111
// 游戏开局调用一次的服务
12-
rpc AddCharacter(CharacterMsg) returns (stream MessageToClient); // 连接上后等待游戏开始,server会定时通过该服务向所有client发送消息
12+
rpc RegisterFactory(RegisterFactoryMsg) returns (stream MessageToClient); // 连接上后等待游戏开始,server会定时通过该服务向所有client发送消息
1313
rpc GetMap(NullRequest) returns (MessageOfMap);
1414

1515
// 游戏过程中普通角色执行操作的服务
@@ -25,7 +25,11 @@ service AvailableService
2525
rpc Sell(SellMeg) returns (BoolRes); // 出售产品
2626

2727
// 游戏过程中核心角色(工厂)可以另外执行操作的服务
28-
rpc CreatCharacter(CreatCharacterMsg) returns (BoolRes); // 创建角色
28+
rpc CreatCharacter(CreatCharacterMsg) returns (BoolRes); // 创建角色
2929
rpc CreatCharacterRID(CreatCharacterMsg) returns (CreatCharacterRes); // 获取角色编号
30-
rpc EndAllAction(IDMsg) returns (BoolRes); // 结束所有动作
30+
rpc EndAllAction(IDMsg) returns (BoolRes); // 结束所有动作
31+
32+
// 智慧大脑相关 RPC
33+
rpc AskAI(AskAIRequest) returns (AskAIResponse); // 客户端请求AI建议
34+
rpc AskAIStream(AskAIRequest) returns (stream AskAIResponse); // 客户端请求AI建议(流式响应)
3135
}

0 commit comments

Comments
 (0)