rts-sim-module/sys/world_time.go

25 lines
483 B
Go
Raw Normal View History

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())
}