26 lines
590 B
Go
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
|
|
}
|