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-01-17 00:47:41 +08:00
|
|
|
func (h Controller) EnterMap(data *space.InInfo, c *player.Player) (result *info.SimpleInfo, err errorcode.ErrorCode) { //这个时候player应该是空的
|
2025-08-28 21:35:56 +00:00
|
|
|
|
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-02-07 19:40:51 +08:00
|
|
|
c.Info.MapID = data.MapId //登录地图
|
|
|
|
|
c.Info.Pos = data.Point
|
2026-01-20 02:25:02 +08:00
|
|
|
|
|
|
|
|
if cool.Config.ServerInfo.IsDebug != 0 {
|
|
|
|
|
println("进入地图", c.Info.UserID, c.Info.MapID)
|
|
|
|
|
}
|
2026-02-07 19:40:51 +08:00
|
|
|
|
|
|
|
|
// copier.CopyWithOption(result, c.Info, copier.Option{DeepCopy: true})
|
2025-11-22 22:57:32 +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 {
|
2025-11-22 22:57:32 +08:00
|
|
|
|
2026-02-14 23:14:43 +08:00
|
|
|
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
|
|
|
}
|
2025-12-24 19:03:11 +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-24 19:03:11 +08:00
|
|
|
func (h Controller) LeaveMap(data *space.LeaveMapInboundInfo, c *player.Player) (result *info.LeaveMapOutboundInfo, err errorcode.ErrorCode) { //这个时候player应该是空的
|
2025-12-13 21:47:07 +08:00
|
|
|
atomic.StoreUint32(&c.Canmon, 0)
|
2025-12-17 06:56:55 +00:00
|
|
|
|
2026-02-12 00:31:41 +08:00
|
|
|
c.GetSpace().LeaveMap(c) //玩家离开地图
|
2025-11-16 11:56:57 +08:00
|
|
|
|
2025-08-23 17:44:12 +08:00
|
|
|
// 如果有正在运行的刷怪协程,发送停止信号
|
2025-09-21 08:00:58 +00:00
|
|
|
|
2025-11-16 12:23:30 +08:00
|
|
|
//c.Info.MapID = 0 // 重置当前地图
|
2026-02-12 00:31:41 +08:00
|
|
|
return nil, -1
|
2025-08-20 22:34:45 +08:00
|
|
|
}
|
2025-12-24 19:03:11 +08:00
|
|
|
func (h Controller) GetMapPlayerList(data *space.ListMapPlayerInboundInfo, c *player.Player) (result *info.ListMapPlayerOutboundInfo, err errorcode.ErrorCode) { //这个时候player应该是空的
|
2026-02-12 00:31:41 +08:00
|
|
|
|
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 {
|
|
|
|
|
c.SendPackCmd(2022, &c.GetSpace().TimeBoss)
|
|
|
|
|
}
|
|
|
|
|
if c.GetSpace().MapBossInfo.Pos != 200 {
|
|
|
|
|
var t info.MapBossSInfo
|
|
|
|
|
t.INFO = append(t.INFO, c.GetSpace().MapBossInfo)
|
|
|
|
|
c.SendPackCmd(2021, &t)
|
2025-10-10 20:46:16 +08:00
|
|
|
|
2026-02-21 19:53:05 +08:00
|
|
|
}
|
|
|
|
|
c.SendPackCmd(50004, &info.S2C_50004{Id: uint32(c.GetSpace().Weather)}) //获取天气
|
|
|
|
|
return nil, -1
|
2025-08-20 22:34:45 +08:00
|
|
|
}
|
2025-12-24 19:03:11 +08:00
|
|
|
func (h Controller) AttackBoss(data *space.AttackBossInboundInfo, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) { //这个时候player应该是空的
|
2025-12-09 14:52:55 +08:00
|
|
|
|
|
|
|
|
if atomic.LoadInt32(&c.GetSpace().MapBossInfo.Hp) > 0 {
|
|
|
|
|
atomic.AddInt32(&c.GetSpace().MapBossInfo.Hp, -1)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return
|
|
|
|
|
}
|