package iscs_sys import ( "fmt" "joylink.club/ecs" "joylink.club/ecs/filter" "joylink.club/rtsssimulation/component" "joylink.club/rtsssimulation/entity" "joylink.club/rtsssimulation/repository" "joylink.club/rtsssimulation/repository/model/proto" ) // FluidDriverSystem 流体驱动系统 // 实现流体在设备、管线中流动 type FluidDriverSystem struct { query *ecs.Query } func NewFluidDriverSystem() *FluidDriverSystem { return &FluidDriverSystem{ query: ecs.NewQuery(filter.Contains(component.UidType, component.FluidDriverType)), } } // 流体驱动系统依赖的数据 type fluidDriverModel interface { Outputs() []repository.DevicePort Inputs() []repository.DevicePort } func (s *FluidDriverSystem) Update(w ecs.World) { wd := entity.GetWorldData(w) s.query.Each(w, func(entry *ecs.Entry) { fdId := component.UidType.Get(entry).Id fd := component.FluidDriverType.Get(entry) fdModel, fdModelOk := wd.Repo.FindById(fdId).(fluidDriverModel) if !fdModelOk { fmt.Printf("==>>FluidDriverSystem.Update FluidDriver[%s]未实现接口fluidDriverModel\n", fdId) } else { s.fluidDrive(entry, fd, fdModel) } }) } func (s *FluidDriverSystem) fluidDrive(entry *ecs.Entry, fd *component.FluidDriver, fdModel fluidDriverModel) { for _, out := range fdModel.Outputs() { switch out.Device().Type() { case proto.DeviceType_DeviceType_Pipe: } } }