rtss-core/component/resourse/world_time.go

35 lines
510 B
Go

package resourse
import (
"time"
"joylink.club/ecs"
)
// WorldTimeType 世界时间组件类型
var WorldTimeType = ecs.NewComponentType[WorldTime]()
// 世界时间
type WorldTime struct {
time int64
}
// 获取时间
func (wt *WorldTime) UnixTime() int64 {
return wt.time
}
func (wt *WorldTime) Time() time.Time {
return time.UnixMilli(wt.time)
}
// 设置时间
func (wt *WorldTime) SetTime(time int64) {
wt.time = time
}
// 时间增加
func (wt *WorldTime) Tick(ms int64) {
wt.time += ms
}