Files
bl/logic/controller/map.go
昔念 e7098e3777
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful
```
feat(space): 更新地图BOSS生成逻辑并优化天气变化处理

- 修改GetMapPlayerList方法中BOSS信息发送方式为调用GenBoss方法
- 注释掉Space结构体中的IsChange字段,不再使用该标志位
- 调整GenBoss方法参数,添加isfrist参数用于区分首次调用
- 重构定时任务中的GenBoss调用逻辑,改为匿名函数包装广播消息
- 移除GenBoss
2026-03-18 01:22:14 +08:00

85 lines
2.4 KiB
Go

package controller
import (
"blazing/common/socket/errorcode"
"blazing/cool"
"blazing/modules/player/service"
"sync/atomic"
"time"
"blazing/logic/service/fight"
"blazing/logic/service/maphot"
"blazing/logic/service/space/info"
"blazing/logic/service/player"
"blazing/logic/service/space"
)
func (h Controller) EnterMap(data *space.InInfo, c *player.Player) (result *info.SimpleInfo, err errorcode.ErrorCode) { //这个时候player应该是空的
if c.Info.MapID != data.MapId {
atomic.StoreUint32(&c.Canmon, 2)
c.MapNPC.Reset(6 * time.Second)
} else {
atomic.StoreUint32(&c.Canmon, 1)
}
c.Info.MapID = data.MapId //登录地图
c.Info.Pos = data.Point
if cool.Config.ServerInfo.IsDebug != 0 {
println("进入地图", c.Info.UserID, c.Info.MapID)
}
// copier.CopyWithOption(result, c.Info, copier.Option{DeepCopy: true})
c.GetSpace().EnterMap(c)
if data.MapId > 10000 && data.MapId != c.Info.UserID {
c.Service.Done.UpdateRoom(1, 0)
service.NewDoneService(data.MapId).UpdateRoom(0, 1)
}
return nil, -1
}
func (h Controller) GetMapHot(data *maphot.InInfo, c *player.Player) (result *maphot.OutInfo, err errorcode.ErrorCode) {
result = &maphot.OutInfo{
HotInfos: space.GetMapHot(),
}
return
}
func (h Controller) LeaveMap(data *space.LeaveMapInboundInfo, c *player.Player) (result *info.LeaveMapOutboundInfo, err errorcode.ErrorCode) { //这个时候player应该是空的
atomic.StoreUint32(&c.Canmon, 0)
c.GetSpace().LeaveMap(c) //玩家离开地图
// 如果有正在运行的刷怪协程,发送停止信号
//c.Info.MapID = 0 // 重置当前地图
return nil, -1
}
func (h Controller) GetMapPlayerList(data *space.ListMapPlayerInboundInfo, c *player.Player) (result *info.ListMapPlayerOutboundInfo, err errorcode.ErrorCode) { //这个时候player应该是空的
result = &info.ListMapPlayerOutboundInfo{
Player: c.GetSpace().GetInfo(c),
}
c.SendPackCmd(2003, result)
if atomic.LoadUint32(&c.GetSpace().TimeBoss.Flag) == 1 {
c.SendPackCmd(2022, &c.GetSpace().TimeBoss)
}
c.SendPackCmd(2021, c.GetSpace().GenBoss(true))
return nil, -1
}
func (h Controller) AttackBoss(data *space.AttackBossInboundInfo, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) { //这个时候player应该是空的
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)
}
}
return
}