Files
bl/logic/controller/map.go
昔念 43094c647c refactor(controller): 移除未使用的地图相关函数
- 删除了 controller 包中多个与地图相关的 Go 文件
- 移除了未使用的 MapIn、MapHot、MapOut 和 MapList 函数
- 在 space 包中添加了对玩家地图的特殊处理逻辑
2025-08-20 22:34:45 +08:00

69 lines
1.9 KiB
Go

package controller
import (
"blazing/common/data/entity"
"blazing/common/socket/errorcode"
"blazing/common/socket/handler"
"blazing/logic/service/maphot"
"blazing/logic/service/maps"
"blazing/logic/service/space"
"time"
)
func (h *Controller) MapEnter(data *maps.InInfo, c *entity.Player) (result *maps.OutInfo, err errorcode.ErrorCode) { //这个时候player应该是空的
c.MapId = data.MapId //登录地图
space.GetSpace(c.MapId).Set(c.UserID, c) //添加玩家
tt := maps.NewOutInfo()
tt.UserID = c.UserID
tt.Nick = c.Nick
tt.Pos = data.Point
data.Broadcast(c.MapId, *tt) //同步广播
go func() { //测试刷怪
for {
tt := handler.NewTomeeHeader()
tt.CMD = 2004
tt.Result = 0
tt.UserID = c.UserID
t1 := maps.OgreInfo{}
for i := 0; i < 9; i++ {
t1.Data[i] = 1
}
c.SendPack(tt.Pack(&t1))
<-time.After(10000 * time.Millisecond)
}
}()
return nil, -1
}
func (h Controller) MapHot(data *maphot.InInfo, c *entity.Player) (result *maphot.OutInfo, err errorcode.ErrorCode) {
result = &maphot.OutInfo{
HotInfos: space.GetMapHot(),
}
return
}
func (h *Controller) MapLeave(data *maps.LeaveMapInboundInfo, c *entity.Player) (result *maps.LeaveMapOutboundInfo, err errorcode.ErrorCode) { //这个时候player应该是空的
//result = &maps.LeaveMapOutboundInfo{UserID: c.GetUserID()}
data.Broadcast(c.MapId, maps.LeaveMapOutboundInfo{UserID: c.GetUserID()}) //同步广播
space.GetSpace(c.MapId).Delete(c.UserID)
return nil, -1
}
func (h *Controller) MapList(data *maps.ListMapPlayerInboundInfo, c *entity.Player) (result *maps.ListMapPlayerOutboundInfo, err errorcode.ErrorCode) { //这个时候player应该是空的
result = &maps.ListMapPlayerOutboundInfo{}
result.Player = make([]maps.OutInfo, 0)
result1 := maps.NewOutInfo()
result1.UserID = c.UserID
//result.Pos = model.Pos{X: 500, Y: 400}
result1.Nick = c.Nick
result.Player = append(result.Player, *result1)
return
}