package iscs_sys import ( "joylink.club/ecs" "joylink.club/ecs/filter" "joylink.club/rtsssimulation/component" "joylink.club/rtsssimulation/consts" ) type NetworkSystem struct { queryNetworkSwitch *ecs.Query } func NewNetworkSystem() *NetworkSystem { return &NetworkSystem{ queryNetworkSwitch: ecs.NewQuery(filter.Contains(component.NetworkSwitchType)), } } func (s *NetworkSystem) Update(w ecs.World) { s.queryNetworkSwitch.Each(w, func(entry *ecs.Entry) { ns := component.NetworkSwitchType.Get(entry) // ns.Exception = consts.DeviceExceptionNon if entry.HasComponent(component.DeviceAbnormalTag) { ns.Exception = consts.DeviceAbnormal } if entry.HasComponent(component.DeviceCommunicationInterruptTag) { ns.Exception = consts.DeviceCommunicationInterrupt } //正常 ns.Normal = ns.Exception == consts.DeviceExceptionNon }) }