rts-sim-module/system/emp_relay_system.go

39 lines
1.1 KiB
Go
Raw Normal View History

2023-08-29 16:22:39 +08:00
package system
import (
"github.com/yohamta/donburi/filter"
"joylink.club/ecs"
"joylink.club/rtsssimulation/components"
"joylink.club/rtsssimulation/umi"
)
// 紧急停车按钮继电器系统
type EmpRelaySystem struct {
relaySystem
// 紧急停车按钮查询
query *ecs.Query
}
func NewEmpRelaySystem() *EmpRelaySystem {
return &EmpRelaySystem{
relaySystem: relaySystem{relayQuery: make(map[string]*ecs.Query)},
query: ecs.NewQuery(filter.Contains(components.EmpStateComponent)),
}
}
// world 执行
func (me *EmpRelaySystem) Update(world ecs.World) {
me.query.Each(world, func(empEntry *ecs.Entry) {
//key-继电器作用名value-继电器实体
usageRelayMapper := make(map[string]*ecs.Entry)
//迭代关联的所有继电器
me.getDeviceRelayQuery(empEntry).Each(world, func(empRelayEntry *ecs.Entry) {
relayId := components.DeviceIdentityComponent.Get(empRelayEntry).Id
relayModel := (WorldModelStorage(world).FindById(relayId)).(umi.IRelayModel)
usageRelayMapper[relayModel.UsageName()] = empRelayEntry
})
//根据具体业务逻辑处理继电器
2023-08-29 17:38:20 +08:00
2023-08-29 16:22:39 +08:00
})
}