rts-sim-module/sys/device_sys/balise.go

42 lines
1.1 KiB
Go
Raw Normal View History

2023-11-23 13:55:43 +08:00
package device_sys
import (
"joylink.club/ecs"
"joylink.club/ecs/filter"
"joylink.club/rtsssimulation/component"
"joylink.club/rtsssimulation/entity"
)
type BaliseSystem struct {
baliseQuery *ecs.Query
}
func NewBaliseSystem() *BaliseSystem {
return &BaliseSystem{baliseQuery: ecs.NewQuery(filter.Contains(component.UidType, component.BaliseStateType))}
}
func (s *BaliseSystem) Update(w ecs.World) {
s.baliseQuery.Each(w, func(entry *ecs.Entry) {
baliseState := component.BaliseStateType.Get(entry)
baliseState.ValidTelegram = s.findValidTelegram(w, entry)
})
}
// 获取应答器有效报文
func (s *BaliseSystem) findValidTelegram(w ecs.World, entry *ecs.Entry) []byte {
wd := entity.GetWorldData(w)
id := component.UidType.Get(entry).Id
if entry.HasComponent(component.BaliseFB) {
baliseModel := wd.Repo.FindTransponder(id)
return baliseModel.FixedTelegram()
} else if entry.HasComponent(component.BaliseDB) {
} else if entry.HasComponent(component.BaliseIB) {
} else if entry.HasComponent(component.BaliseVB) {
} else if entry.HasComponent(component.BaliseWB) {
}
return nil
}