```
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful

refactor(player): 移除无用依赖并优化定时器实现

移除了未使用的 "blazing/cool" 包导入
将 timer.TimeNoder 类型替换为标准库的 *time.Timer
使用 time.AfterFunc 替代 cron 调度函数来处理地图NPC定时逻辑
```
This commit is contained in:
昔念
2026-02-02 23:25:05 +08:00
parent b25f033939
commit dc647cdfbb
2 changed files with 2 additions and 7 deletions

View File

@@ -1,7 +1,6 @@
package player
import (
"blazing/cool"
"blazing/logic/service/common"
"blazing/modules/base/service"
"blazing/modules/player/model"
@@ -19,12 +18,9 @@ func NewPlayer(opts ...PlayerOption) *Player {
p.User = service.NewBaseSysUserService()
p.monsters = generateThreeUniqueNumbers()
p.Done = NewDone(p) //发布订阅事件
p.MapNPC = cool.Cron.ScheduleFunc(10*time.Second, func() {
// 获取当前地图的怪物配置
p.MapNPC = time.AfterFunc(10*time.Second, func() {
p.GenMonster() //生成野怪
})
for _, opt := range opts {

View File

@@ -18,7 +18,6 @@ import (
blservice "blazing/modules/player/service"
"context"
"github.com/antlabs/timer"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/util/gconv"
csmap "github.com/mhmtszr/concurrent-swiss-map"
@@ -68,7 +67,7 @@ type Player struct {
IsLogin bool //是否登录
Done
MapNPC timer.TimeNoder
MapNPC *time.Timer
context.Context
Fightinfo info.Fightinfo // 当前邀请的玩家ID