diff --git a/examples/rtss-cg/main.go b/examples/rtss-cg/main.go index fdc68d9..1028da8 100644 --- a/examples/rtss-cg/main.go +++ b/examples/rtss-cg/main.go @@ -48,7 +48,6 @@ func main() { // simWorld.AddSystem(system.NewSwitchSystem()) simWorld.AddSystem(system.NewTrainSystem()) - //simWorld.AddSystem(system.NewCiSystem()) simWorld.AddSystem(system.NewSectionSystem()) // simWorld.StartUp() diff --git a/examples/rtss-cg/system/ci_system.go b/examples/rtss-cg/system/ci_system.go deleted file mode 100644 index 7e11e4f..0000000 --- a/examples/rtss-cg/system/ci_system.go +++ /dev/null @@ -1,50 +0,0 @@ -package system - -import ( - "fmt" - "strings" - - "github.com/yohamta/donburi/filter" - "joylink.club/ecs" - "joylink.club/ecs/examples/rtss-cg/simulation" -) - -// 把长轨道当成物理区段,列车当成一个点,来计算物理区段的占用空闲状态 -type CiSystem struct { - //轨道查询 - linkQuery *ecs.Query - //列车查询 - trainQuery *ecs.Query -} - -func (me *CiSystem) Update(w ecs.World) { - //key linkId,value bool - linkOccupyMap := make(map[string]bool) - me.trainQuery.Each(w, func(e *ecs.Entry) { - train := simulation.ComTrainState.Get(e) - - if len(strings.TrimSpace(train.LinkId)) > 0 { - linkOccupyMap[train.LinkId] = true - } - }) - //轨道是否被列车占用 - me.linkQuery.Each(w, func(e *ecs.Entry) { - link := simulation.ComLinkState.Get(e) - if linkOccupied, ok := linkOccupyMap[link.Id]; ok { - link.Occupied = linkOccupied - } else { - link.Occupied = false - } - }) - me.linkQuery.Each(w, func(e *ecs.Entry) { - link := simulation.ComLinkState.Get(e) - fmt.Println("==>>轨道(", link.Id, ") 上有车(", link.Occupied, ")") - }) -} - -func NewCiSystem() *CiSystem { - return &CiSystem{ - linkQuery: ecs.NewQuery(filter.Contains(simulation.ComLinkState)), - trainQuery: ecs.NewQuery(filter.Contains(simulation.ComTrainState)), - } -}