feat sc改名ss
This commit is contained in:
2
go.mod
2
go.mod
@@ -3,7 +3,7 @@ module git.hlsq.asia/mmorpg/service-scene
|
||||
go 1.23.1
|
||||
|
||||
require (
|
||||
git.hlsq.asia/mmorpg/service-common v0.0.0-20260112035311-ec291d4332e5
|
||||
git.hlsq.asia/mmorpg/service-common v0.0.0-20260112040622-d433cd03a956
|
||||
github.com/judwhite/go-svc v1.2.1
|
||||
go.uber.org/zap v1.27.0
|
||||
google.golang.org/grpc v1.71.1
|
||||
|
||||
2
go.sum
2
go.sum
@@ -6,6 +6,8 @@ git.hlsq.asia/mmorpg/service-common v0.0.0-20260112034651-8c09b125a49d h1:R74eiD
|
||||
git.hlsq.asia/mmorpg/service-common v0.0.0-20260112034651-8c09b125a49d/go.mod h1:xv6m1I2jUA6mudKVznygpnzMoshBQarthHD1QnkW4qc=
|
||||
git.hlsq.asia/mmorpg/service-common v0.0.0-20260112035311-ec291d4332e5 h1:SauhRmcRxeQj/luQRyIt9iHORp/U9cpm2I5o65rUeGg=
|
||||
git.hlsq.asia/mmorpg/service-common v0.0.0-20260112035311-ec291d4332e5/go.mod h1:xv6m1I2jUA6mudKVznygpnzMoshBQarthHD1QnkW4qc=
|
||||
git.hlsq.asia/mmorpg/service-common v0.0.0-20260112040622-d433cd03a956 h1:UfdH/8hH1MOnWzsMEvI8e31O7u5IJO5NaJjgK+BR1iY=
|
||||
git.hlsq.asia/mmorpg/service-common v0.0.0-20260112040622-d433cd03a956/go.mod h1:xv6m1I2jUA6mudKVznygpnzMoshBQarthHD1QnkW4qc=
|
||||
github.com/BurntSushi/toml v1.2.0 h1:Rt8g24XnyGTyglgET/PRUNlrUeu9F5L+7FilkXfZgs0=
|
||||
github.com/BurntSushi/toml v1.2.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
|
||||
github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs=
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"context"
|
||||
"git.hlsq.asia/mmorpg/service-common/log"
|
||||
"git.hlsq.asia/mmorpg/service-common/proto/rs/grpc_pb"
|
||||
"git.hlsq.asia/mmorpg/service-common/proto/sc/sc_pb"
|
||||
"git.hlsq.asia/mmorpg/service-common/proto/ss/ss_pb"
|
||||
instance2 "git.hlsq.asia/mmorpg/service-scene/internal/instance"
|
||||
"google.golang.org/protobuf/proto"
|
||||
"sync"
|
||||
@@ -23,8 +23,8 @@ func (s *Server) Enter(ctx context.Context, req *grpc_pb.EnterReq) (*grpc_pb.Ent
|
||||
}
|
||||
i.EventIn <- req
|
||||
|
||||
payload, _ := proto.Marshal(&sc_pb.S2C_EnterInstance{
|
||||
Info: &sc_pb.PositionInfo{
|
||||
payload, _ := proto.Marshal(&ss_pb.S2C_EnterInstance{
|
||||
Info: &ss_pb.PositionInfo{
|
||||
USN: req.USN,
|
||||
X: 1,
|
||||
Y: 1,
|
||||
@@ -33,7 +33,7 @@ func (s *Server) Enter(ctx context.Context, req *grpc_pb.EnterReq) (*grpc_pb.Ent
|
||||
return &grpc_pb.EnterResp{
|
||||
SceneSID: s.SID,
|
||||
UniqueNo: i.UniqueNo,
|
||||
MessageID: int32(sc_pb.MessageID_MESSAGE_ID_ENTER_INSTANCE),
|
||||
MessageID: int32(ss_pb.MessageID_MESSAGE_ID_ENTER_INSTANCE),
|
||||
Payload: payload,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"git.hlsq.asia/mmorpg/service-common/discover"
|
||||
"git.hlsq.asia/mmorpg/service-common/log"
|
||||
"git.hlsq.asia/mmorpg/service-common/proto/rs/grpc_pb"
|
||||
"git.hlsq.asia/mmorpg/service-common/proto/sc/sc_pb"
|
||||
"git.hlsq.asia/mmorpg/service-common/proto/ss/ss_pb"
|
||||
"git.hlsq.asia/mmorpg/service-common/utils"
|
||||
"git.hlsq.asia/mmorpg/service-scene/internal/grpc_server/stream_client"
|
||||
"git.hlsq.asia/mmorpg/service-scene/internal/npc"
|
||||
@@ -103,12 +103,12 @@ func (i *Instance) onEvent(e proto.Message) {
|
||||
|
||||
// 逻辑帧
|
||||
func (i *Instance) onLogic(delta int64) {
|
||||
positionUpdate := make([]*sc_pb.PositionInfo, 0)
|
||||
positionUpdate := make([]*ss_pb.PositionInfo, 0)
|
||||
sid := ""
|
||||
// 处理玩家指令
|
||||
for _, node := range i.players {
|
||||
if node.LogicAction(delta) {
|
||||
positionUpdate = append(positionUpdate, &sc_pb.PositionInfo{
|
||||
positionUpdate = append(positionUpdate, &ss_pb.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(&sc_pb.S2C_Position{
|
||||
payload, _ := proto.Marshal(&ss_pb.S2C_Position{
|
||||
Info: positionUpdate,
|
||||
})
|
||||
if err := stream_client.SendMessageToGateway(sid, stream_client.FunToClient, &grpc_pb.ToClientReq{
|
||||
USN: "",
|
||||
MessageID: int32(sc_pb.MessageID_MESSAGE_ID_POSITION),
|
||||
MessageID: int32(ss_pb.MessageID_MESSAGE_ID_POSITION),
|
||||
Payload: payload,
|
||||
}); err != nil {
|
||||
i.logger.Errorf("send action err: %v", err)
|
||||
|
||||
@@ -2,7 +2,7 @@ package npc
|
||||
|
||||
import (
|
||||
"git.hlsq.asia/mmorpg/service-common/proto/rs/grpc_pb"
|
||||
"git.hlsq.asia/mmorpg/service-common/proto/sc/sc_pb"
|
||||
"git.hlsq.asia/mmorpg/service-common/proto/ss/ss_pb"
|
||||
)
|
||||
|
||||
// PlayerNode 定义玩家节点结构体
|
||||
@@ -36,11 +36,11 @@ func (p *PlayerNode) AddAction(e *grpc_pb.ActionReq) {
|
||||
// return 是否更新玩家状态
|
||||
func (p *PlayerNode) LogicAction(delta int64) bool {
|
||||
for _, a := range p.Action {
|
||||
switch sc_pb.ActionID(a.Action) {
|
||||
case sc_pb.ActionID_ACTION_ID_MOVE:
|
||||
switch ss_pb.ActionID(a.Action) {
|
||||
case ss_pb.ActionID_ACTION_ID_MOVE:
|
||||
p.MoveDirection = [2]int8{int8(a.DirX), int8(a.DirY)}
|
||||
p.MoveCount = 0
|
||||
case sc_pb.ActionID_ACTION_ID_ATTACK:
|
||||
case ss_pb.ActionID_ACTION_ID_ATTACK:
|
||||
}
|
||||
}
|
||||
p.Action = make([]*grpc_pb.ActionReq, 0)
|
||||
|
||||
Reference in New Issue
Block a user