添加道岔位置根据转辙机位置更新的系统
This commit is contained in:
parent
04b1e2b6d7
commit
fb39939e3b
@ -24,7 +24,7 @@ func LoadTurnouts(w ecs.World) error {
|
||||
case proto.Turnout_ZDJ9_Double:
|
||||
err = LoadTurnoutZdj9Two(w, turnout, entry, data.EntityMap)
|
||||
default:
|
||||
fmt.Println("id=", turnout.Id(), "的道岔没有转辙机类型")
|
||||
err = fmt.Errorf("id=%s的道岔没有转辙机型号", turnout.Id())
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
|
38
sys/device_sys/turnout.go
Normal file
38
sys/device_sys/turnout.go
Normal file
@ -0,0 +1,38 @@
|
||||
package device_sys
|
||||
|
||||
import (
|
||||
"github.com/yohamta/donburi/filter"
|
||||
"joylink.club/ecs"
|
||||
"joylink.club/rtsssimulation/component"
|
||||
)
|
||||
|
||||
// 道岔位置更新系统
|
||||
type TurnoutSys struct {
|
||||
query *ecs.Query
|
||||
}
|
||||
|
||||
func NewTurnoutSys() *TurnoutSys {
|
||||
return &TurnoutSys{
|
||||
query: ecs.NewQuery(filter.Contains(component.TurnoutPositionType, component.TurnoutZzjType)),
|
||||
}
|
||||
}
|
||||
|
||||
func (s *TurnoutSys) Update(w ecs.World) {
|
||||
s.query.Each(w, func(entry *ecs.Entry) {
|
||||
zzjs := component.TurnoutZzjType.Get(entry)
|
||||
tp := component.TurnoutPositionType.Get(entry)
|
||||
dw := true
|
||||
fw := true
|
||||
for _, zzj := range zzjs.ZzjList {
|
||||
state := component.ZzjStateType.Get(zzj)
|
||||
if !(!state.JD12 && !state.JD34) {
|
||||
dw = false
|
||||
}
|
||||
if !(state.JD12 && state.JD34) {
|
||||
fw = false
|
||||
}
|
||||
}
|
||||
tp.Dw = dw
|
||||
tp.Fw = fw
|
||||
})
|
||||
}
|
Loading…
Reference in New Issue
Block a user