rts-sim-module/sys/world_time.go
walker c56feb3bdf 道岔电路驱动系统实现
仿真单例组件定义(暂定)
仿真道岔相关实体构建(未完)
2023-09-27 18:39:18 +08:00

25 lines
483 B
Go

package sys
import (
"github.com/yohamta/donburi/filter"
"joylink.club/ecs"
"joylink.club/rtsssimulation/component"
)
// 世界世界更新系统
type WorldTimeSys struct {
query *ecs.Query
}
func NewWorldTimeSys() *WorldTimeSys {
return &WorldTimeSys{
query: ecs.NewQuery(filter.Contains(component.WorldDataType)),
}
}
func (s *WorldTimeSys) Update(w ecs.World) {
entry, _ := s.query.First(w)
data := component.WorldDataType.Get(entry)
data.Time += int64(w.Tick())
}