35 lines
894 B
Go
35 lines
894 B
Go
package iscs_sys
|
|
|
|
import (
|
|
"joylink.club/ecs"
|
|
"joylink.club/ecs/filter"
|
|
"joylink.club/rtsssimulation/component"
|
|
"joylink.club/rtsssimulation/consts"
|
|
)
|
|
|
|
// NetworkHostSystem 网络设备、网络主机等
|
|
type NetworkHostSystem struct {
|
|
query *ecs.Query
|
|
}
|
|
|
|
func NewNetworkHostSystem() *NetworkHostSystem {
|
|
return &NetworkHostSystem{
|
|
query: ecs.NewQuery(filter.Contains(component.NetworkHostType)),
|
|
}
|
|
}
|
|
func (s *NetworkHostSystem) Update(w ecs.World) {
|
|
s.query.Each(w, func(entry *ecs.Entry) {
|
|
host := component.NetworkHostType.Get(entry)
|
|
//
|
|
host.Exception = consts.DeviceExceptionNon
|
|
if entry.HasComponent(component.DeviceFaultTag) {
|
|
host.Exception = consts.DeviceFault
|
|
}
|
|
if entry.HasComponent(component.DeviceCommunicationInterruptTag) {
|
|
host.Exception = consts.DeviceCommunicationInterrupt
|
|
}
|
|
//
|
|
host.Normal = host.Exception == consts.DeviceExceptionNon
|
|
})
|
|
}
|