2025-08-20 22:34:45 +08:00
|
|
|
|
package controller
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
|
"blazing/common/socket/errorcode"
|
2026-01-20 02:25:02 +08:00
|
|
|
|
"blazing/cool"
|
2026-02-14 07:36:05 +08:00
|
|
|
|
"blazing/modules/player/service"
|
2025-11-20 05:57:29 +08:00
|
|
|
|
"sync/atomic"
|
2025-12-17 09:52:44 +00:00
|
|
|
|
"time"
|
2025-09-14 01:35:16 +08:00
|
|
|
|
|
2025-12-09 14:52:55 +08:00
|
|
|
|
"blazing/logic/service/fight"
|
2025-08-20 22:34:45 +08:00
|
|
|
|
"blazing/logic/service/maphot"
|
2025-12-12 19:10:09 +00:00
|
|
|
|
"blazing/logic/service/space/info"
|
|
|
|
|
|
|
2025-09-14 01:35:16 +08:00
|
|
|
|
"blazing/logic/service/player"
|
2025-08-20 22:34:45 +08:00
|
|
|
|
"blazing/logic/service/space"
|
|
|
|
|
|
)
|
|
|
|
|
|
|
2026-04-01 20:10:29 +08:00
|
|
|
|
// EnterMap 处理玩家进入地图。
|
|
|
|
|
|
func (h Controller) EnterMap(data *space.InInfo, c *player.Player) (result *info.SimpleInfo, err errorcode.ErrorCode) {
|
2026-02-12 00:31:41 +08:00
|
|
|
|
if c.Info.MapID != data.MapId {
|
|
|
|
|
|
atomic.StoreUint32(&c.Canmon, 2)
|
2026-02-13 22:57:05 +08:00
|
|
|
|
c.MapNPC.Reset(6 * time.Second)
|
2026-02-13 06:13:56 +08:00
|
|
|
|
} else {
|
2026-02-12 22:19:27 +08:00
|
|
|
|
atomic.StoreUint32(&c.Canmon, 1)
|
2026-02-12 00:31:41 +08:00
|
|
|
|
}
|
2026-04-01 20:10:29 +08:00
|
|
|
|
|
|
|
|
|
|
c.Info.MapID = data.MapId // 更新当前地图ID。
|
2026-02-07 19:40:51 +08:00
|
|
|
|
c.Info.Pos = data.Point
|
2026-01-20 02:25:02 +08:00
|
|
|
|
|
|
|
|
|
|
if cool.Config.ServerInfo.IsDebug != 0 {
|
2026-04-01 20:10:29 +08:00
|
|
|
|
println("enter map", c.Info.UserID, c.Info.MapID)
|
2026-01-20 02:25:02 +08:00
|
|
|
|
}
|
2026-02-07 19:40:51 +08:00
|
|
|
|
|
2026-02-12 00:31:41 +08:00
|
|
|
|
c.GetSpace().EnterMap(c)
|
2026-02-14 23:14:43 +08:00
|
|
|
|
if data.MapId > 10000 && data.MapId != c.Info.UserID {
|
|
|
|
|
|
c.Service.Done.UpdateRoom(1, 0)
|
|
|
|
|
|
service.NewDoneService(data.MapId).UpdateRoom(0, 1)
|
|
|
|
|
|
}
|
2026-02-07 19:40:51 +08:00
|
|
|
|
return nil, -1
|
2025-08-20 22:34:45 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-04-01 20:10:29 +08:00
|
|
|
|
func (h Controller) GetMapHot(data *maphot.InInfo, c *player.Player) (result *maphot.OutInfo, err errorcode.ErrorCode) {
|
2025-08-20 22:34:45 +08:00
|
|
|
|
result = &maphot.OutInfo{
|
|
|
|
|
|
HotInfos: space.GetMapHot(),
|
|
|
|
|
|
}
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
2025-12-17 06:56:55 +00:00
|
|
|
|
|
2026-04-01 20:10:29 +08:00
|
|
|
|
// LeaveMap 处理玩家离开地图。
|
|
|
|
|
|
func (h Controller) LeaveMap(data *space.LeaveMapInboundInfo, c *player.Player) (result *info.LeaveMapOutboundInfo, err errorcode.ErrorCode) {
|
|
|
|
|
|
atomic.StoreUint32(&c.Canmon, 0)
|
2025-11-16 11:56:57 +08:00
|
|
|
|
|
2026-04-01 20:10:29 +08:00
|
|
|
|
c.GetSpace().LeaveMap(c) // 从当前空间移除玩家。
|
2025-09-21 08:00:58 +00:00
|
|
|
|
|
2026-04-01 20:10:29 +08:00
|
|
|
|
// 这里不直接清空 MapID,由后续进入地图流程接管。
|
2026-02-12 00:31:41 +08:00
|
|
|
|
return nil, -1
|
2025-08-20 22:34:45 +08:00
|
|
|
|
}
|
2026-02-12 00:31:41 +08:00
|
|
|
|
|
2026-04-01 20:10:29 +08:00
|
|
|
|
// GetMapPlayerList 获取当前地图内的玩家列表与地图广播信息。
|
|
|
|
|
|
func (h Controller) GetMapPlayerList(data *space.ListMapPlayerInboundInfo, c *player.Player) (result *info.ListMapPlayerOutboundInfo, err errorcode.ErrorCode) {
|
2025-11-16 11:56:57 +08:00
|
|
|
|
result = &info.ListMapPlayerOutboundInfo{
|
2025-12-09 16:14:47 +00:00
|
|
|
|
Player: c.GetSpace().GetInfo(c),
|
2025-11-16 11:56:57 +08:00
|
|
|
|
}
|
2026-02-21 19:53:05 +08:00
|
|
|
|
c.SendPackCmd(2003, result)
|
|
|
|
|
|
if atomic.LoadUint32(&c.GetSpace().TimeBoss.Flag) == 1 {
|
2026-04-01 20:10:29 +08:00
|
|
|
|
c.SendPackCmd(2021, &c.GetSpace().TimeBoss)
|
2026-02-21 19:53:05 +08:00
|
|
|
|
}
|
2026-04-01 20:10:29 +08:00
|
|
|
|
c.SendPackCmd(2022, c.GetSpace().GenBoss(true))
|
2026-02-25 19:05:50 +08:00
|
|
|
|
|
2026-02-21 19:53:05 +08:00
|
|
|
|
return nil, -1
|
2025-08-20 22:34:45 +08:00
|
|
|
|
}
|
2025-12-09 14:52:55 +08:00
|
|
|
|
|
2026-04-01 20:10:29 +08:00
|
|
|
|
// AttackBoss 调试扣减当前地图广播BOSS血量。
|
|
|
|
|
|
func (h Controller) AttackBoss(data *space.AttackBossInboundInfo, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
|
2026-02-25 21:16:36 +08:00
|
|
|
|
for i := 0; i < len(c.GetSpace().MapBossSInfo.INFO); i++ {
|
|
|
|
|
|
if atomic.LoadInt32(&c.GetSpace().MapBossSInfo.INFO[i].Hp) > 0 {
|
|
|
|
|
|
atomic.AddInt32(&c.GetSpace().MapBossSInfo.INFO[i].Hp, -1)
|
2026-02-25 19:05:50 +08:00
|
|
|
|
}
|
2025-12-09 14:52:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|