feat 包命名规范

This commit is contained in:
2026-02-11 14:49:52 +08:00
parent 146c1734fa
commit 185518257f
8 changed files with 49 additions and 51 deletions

View File

@@ -1,8 +1,8 @@
package npc
import (
"git.hlsq.asia/mmorpg/service-common/proto/rs/grpc_pb"
"git.hlsq.asia/mmorpg/service-common/proto/ss/ss_pb"
"git.hlsq.asia/mmorpg/service-common/proto/rs/rspb"
"git.hlsq.asia/mmorpg/service-common/proto/ss/sspb"
)
// PlayerNode 定义玩家节点结构体
@@ -11,10 +11,10 @@ type PlayerNode struct {
GatewaySID int64 // 网关服务ID
MoveSpeed float32 // 移动速度
Position [2]float32 // 二维坐标 [x, y]
MoveDirection [2]int8 // 移动方向 [x, y]
MoveCount int8 // 移动指令使用计数
Action []*grpc_pb.ActionReq // 其他操作
Position [2]float32 // 二维坐标 [x, y]
MoveDirection [2]int8 // 移动方向 [x, y]
MoveCount int8 // 移动指令使用计数
Action []*rspb.ActionReq // 其他操作
}
func NewPlayerNode(gatewaySID int64, usn int64) *PlayerNode {
@@ -23,12 +23,12 @@ func NewPlayerNode(gatewaySID int64, usn int64) *PlayerNode {
GatewaySID: gatewaySID,
MoveSpeed: 5 * 0.00001,
Position: [2]float32{0, 0},
Action: make([]*grpc_pb.ActionReq, 0),
Action: make([]*rspb.ActionReq, 0),
}
}
// AddAction 将指令存储到玩家身上
func (p *PlayerNode) AddAction(e *grpc_pb.ActionReq) {
func (p *PlayerNode) AddAction(e *rspb.ActionReq) {
p.Action = append(p.Action, e)
}
@@ -36,14 +36,14 @@ func (p *PlayerNode) AddAction(e *grpc_pb.ActionReq) {
// return 是否更新玩家状态
func (p *PlayerNode) LogicAction(delta int64) bool {
for _, a := range p.Action {
switch ss_pb.ActionID(a.Action) {
case ss_pb.ActionID_ACTION_ID_MOVE:
switch sspb.ActionID(a.Action) {
case sspb.ActionID_ACTION_ID_MOVE:
p.MoveDirection = [2]int8{int8(a.DirX), int8(a.DirY)}
p.MoveCount = 0
case ss_pb.ActionID_ACTION_ID_ATTACK:
case sspb.ActionID_ACTION_ID_ATTACK:
}
}
p.Action = make([]*grpc_pb.ActionReq, 0)
p.Action = make([]*rspb.ActionReq, 0)
return p.move(delta)
}