包重构

This commit is contained in:
xzb 2023-08-23 16:08:21 +08:00
parent c289fd2f6d
commit a52413daf7
2 changed files with 6 additions and 8 deletions

View File

@ -8,7 +8,6 @@ import (
"github.com/yohamta/donburi/filter"
"joylink.club/ecs"
"joylink.club/rtsssimulation/components"
"joylink.club/rtsssimulation/util"
)
// 外界与world交互请求定义
@ -85,7 +84,7 @@ func FindEntityById(world ecs.World, id string) *ecs.Entry {
func QueryEntityById(world ecs.World, q *ecs.Query, id string) *ecs.Entry {
var entry *ecs.Entry = nil
func() {
defer util.Recover()
defer simpleRecover()
q.Each(world, func(e *ecs.Entry) {
if id == components.DeviceIdentityComponent.Get(e).Id {
entry = e
@ -96,3 +95,8 @@ func QueryEntityById(world ecs.World, q *ecs.Query, id string) *ecs.Entry {
//
return entry
}
// 捕获panic并恢复执行
func simpleRecover() {
recover()
}

View File

@ -1,6 +0,0 @@
package util
// 捕获panic并恢复执行
func Recover() {
recover()
}