31 lines
963 B
Go
31 lines
963 B
Go
|
package device_sys
|
||
|
|
||
|
import (
|
||
|
"github.com/yohamta/donburi"
|
||
|
"joylink.club/ecs"
|
||
|
"joylink.club/ecs/filter"
|
||
|
"joylink.club/rtsssimulation/component"
|
||
|
"joylink.club/rtsssimulation/entity"
|
||
|
)
|
||
|
|
||
|
type AxleCountingSectionSystem struct {
|
||
|
axleCountingSectionQuery *ecs.Query
|
||
|
}
|
||
|
|
||
|
func NewAxleCountingSectionSystem() *AxleCountingSectionSystem {
|
||
|
return &AxleCountingSectionSystem{
|
||
|
axleCountingSectionQuery: ecs.NewQuery(filter.Contains(entity.AxleCountingSectionBaseComponentTypes...)),
|
||
|
}
|
||
|
}
|
||
|
|
||
|
func (a *AxleCountingSectionSystem) Update(w ecs.World) {
|
||
|
a.axleCountingSectionQuery.Each(w, func(entry *donburi.Entry) {
|
||
|
wd := entity.GetWorldData(w)
|
||
|
uid := component.UidType.Get(entry).Id
|
||
|
section := wd.Repo.FindAxleCountingSection(uid)
|
||
|
physicalSectionEntry := wd.EntityMap[section.PhysicalSection().Id()]
|
||
|
occupied := component.PhysicalSectionManagerType.Get(physicalSectionEntry).Occupied
|
||
|
component.AxleCountingSectionStateType.Get(entry).Occupied = occupied
|
||
|
})
|
||
|
}
|