rts-sim-module/fi/common.go
walker 9401b15142 组件调整
实体加载调整
继电器、断相保护器、道岔转辙机、道岔、道岔电路等系统调整
继电器、道岔对外接口调整
2024-01-12 18:20:21 +08:00

26 lines
590 B
Go

package fi
import (
"fmt"
"joylink.club/ecs"
"joylink.club/rtsssimulation/entity"
)
func updateEntity(w ecs.World, id string, entityName string, updateHandle func(entry *ecs.Entry) error) error {
result := <-ecs.Request[ecs.EmptyType](w, func() ecs.Result[ecs.EmptyType] {
wd := entity.GetWorldData(w)
entry, ok := wd.EntityMap[id]
if ok {
err := updateHandle(entry)
if err != nil {
return ecs.NewErrResult(err)
}
} else {
return ecs.NewErrResult(fmt.Errorf("未找到id=%s的%s", id, entityName))
}
return ecs.NewOkEmptyResult()
})
return result.Err
}