feat 包命名规范
This commit is contained in:
@@ -5,9 +5,9 @@ import (
|
||||
"fmt"
|
||||
"git.hlsq.asia/mmorpg/service-common/discover"
|
||||
"git.hlsq.asia/mmorpg/service-common/log"
|
||||
"git.hlsq.asia/mmorpg/service-common/net/grpc/grpc_client"
|
||||
"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/net/grpc/grpcclient"
|
||||
"git.hlsq.asia/mmorpg/service-common/proto/rs/rspb"
|
||||
"git.hlsq.asia/mmorpg/service-common/proto/ss/sspb"
|
||||
"git.hlsq.asia/mmorpg/service-common/utils"
|
||||
"git.hlsq.asia/mmorpg/service-scene/internal/npc"
|
||||
"go.uber.org/zap"
|
||||
@@ -90,25 +90,25 @@ func (i *Instance) Start(ttl int64) {
|
||||
// 网络帧,将玩家的操作储存起来,到逻辑帧再处理玩家操作
|
||||
func (i *Instance) onEvent(e proto.Message) {
|
||||
switch v := e.(type) {
|
||||
case *grpc_pb.EnterReq:
|
||||
case *rspb.EnterReq:
|
||||
i.players[v.USN] = npc.NewPlayerNode(v.GatewaySID, v.USN)
|
||||
case *grpc_pb.ActionReq:
|
||||
case *rspb.ActionReq:
|
||||
if node, ok := i.players[v.USN]; ok {
|
||||
node.AddAction(v)
|
||||
}
|
||||
case *grpc_pb.LeaveReq:
|
||||
case *rspb.LeaveReq:
|
||||
delete(i.players, v.USN)
|
||||
}
|
||||
}
|
||||
|
||||
// 逻辑帧
|
||||
func (i *Instance) onLogic(delta int64) {
|
||||
positionUpdate := make([]*ss_pb.PositionInfo, 0)
|
||||
positionUpdate := make([]*sspb.PositionInfo, 0)
|
||||
sid := int64(0)
|
||||
// 处理玩家指令
|
||||
for _, node := range i.players {
|
||||
if node.LogicAction(delta) {
|
||||
positionUpdate = append(positionUpdate, &ss_pb.PositionInfo{
|
||||
positionUpdate = append(positionUpdate, &sspb.PositionInfo{
|
||||
USN: node.USN,
|
||||
X: int32(node.Position[0] * 100),
|
||||
Y: int32(node.Position[1] * 100),
|
||||
@@ -117,12 +117,12 @@ func (i *Instance) onLogic(delta int64) {
|
||||
}
|
||||
}
|
||||
if len(positionUpdate) > 0 {
|
||||
payload, _ := proto.Marshal(&ss_pb.S2C_Position{
|
||||
payload, _ := proto.Marshal(&sspb.S2C_Position{
|
||||
Info: positionUpdate,
|
||||
})
|
||||
if err := grpc_client.SendMessageToGateway(sid, grpc_client.FunToClient, &grpc_pb.ToClientReq{
|
||||
if err := grpcclient.SendMessageToGateway(sid, grpcclient.FunToClient, &rspb.ToClientReq{
|
||||
USN: -1,
|
||||
MessageID: int32(ss_pb.MessageID_MESSAGE_ID_POSITION),
|
||||
MessageID: int32(sspb.MessageID_MESSAGE_ID_POSITION),
|
||||
Payload: payload,
|
||||
}); err != nil {
|
||||
i.logger.Errorf("send action err: %v", err)
|
||||
|
||||
Reference in New Issue
Block a user