package entity import ( "fmt" "joylink.club/ecs" "joylink.club/rtsssimulation/component" "joylink.club/rtsssimulation/consts" "joylink.club/rtsssimulation/repository" ) func loadSignal3xh4(w ecs.World, signal *repository.Signal, signalEntry *ecs.Entry, elecs []repository.IGroupedElectronicComponent, entityMap map[string]*ecs.Entry) error { if len(elecs) == 4 { //3xh4组合类型包含4个继电器 signalEntry.AddComponent(component.Signal3XH4ElectronicType) signalEntry.AddComponent(component.Signal3XH4FilamentType) // elecState := &component.Signal3XH4Electronic{} for _, elec := range elecs { switch elec.Code() { case consts.SIGNAL_DDJ: elecState.Z3XH4_DDJ = NewRelayEntity(w, elec.(*repository.Relay), entityMap) case consts.SIGNAL_DJ: elecState.Z3XH4_DJ = NewRelayEntity(w, elec.(*repository.Relay), entityMap) case consts.SIGNAL_LXJ: elecState.Z3XH4_LXJ = NewRelayEntity(w, elec.(*repository.Relay), entityMap) case consts.SIGNAL_ZXJ: elecState.Z3XH4_ZXJ = NewRelayEntity(w, elec.(*repository.Relay), entityMap) default: return fmt.Errorf("id=[%s]的信号机3xh4,无效电子元器件名称[%s]", signal.Id(), elec.Code()) } } // component.Signal3XH4ElectronicType.Set(signalEntry, elecState) component.Signal3XH4FilamentType.Set(signalEntry, &component.Signal3XH4Filament{Uf: true, Lf: true, Hf: true, U: false, L: false, H: false}) } else { return fmt.Errorf("id=[%s]的信号机3xh4,电子元器件数量须为4", signal.Id()) } return nil }