refactor(player): 移除无用依赖并优化定时器实现 移除了未使用的 "blazing/cool" 包导入 将 timer.TimeNoder 类型替换为标准库的 *time.Timer 使用 time.AfterFunc 替代 cron 调度函数来处理地图NPC定时逻辑 ```
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user