rts-sim-module/operate/balise_operation.go
2023-08-23 16:01:01 +08:00

29 lines
781 B
Go

package operate
import (
"github.com/yohamta/donburi/filter"
"joylink.club/ecs"
"joylink.club/rtsssimulation/components"
"joylink.club/rtsssimulation/components/cstate"
"joylink.club/rtsssimulation/system"
)
// 应答器查询
var baliseQuery *ecs.Query = ecs.NewQuery(filter.Contains(components.DeviceIdentityComponent, components.BaliseStateComponent))
//
// 发送消息到应答器
// 当要清空应答器中报文时,则message=nil
func SendMessageToTransponder(world ecs.World, transponderId string, message *cstate.BaliseContent) bool {
transponderEntry := system.QueryEntityById(world, baliseQuery, transponderId)
//
if transponderEntry == nil {
return false
}
//
components.BaliseStateComponent.Get(transponderEntry).Content = message
//
return true
}