46 lines
825 B
Go
46 lines
825 B
Go
package cstate
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/yohamta/donburi/component"
|
|
)
|
|
|
|
// 此文件中为与设备无关的仿真系统自身的状态定义
|
|
|
|
// 系统时钟,单例
|
|
type SystemTimer struct {
|
|
timer *time.Time
|
|
}
|
|
|
|
// 以指定时间构建
|
|
func NewSystemTimer(time *time.Time) *SystemTimer {
|
|
return &SystemTimer{
|
|
timer: time,
|
|
}
|
|
}
|
|
|
|
// 重置时间
|
|
func (me *SystemTimer) ResetTime(time time.Time) {
|
|
*me.timer = time
|
|
}
|
|
|
|
// 获取当前时间的副本
|
|
func (me *SystemTimer) Now() time.Time {
|
|
return *me.timer
|
|
}
|
|
|
|
// tick系统时钟,单位ms
|
|
func (me *SystemTimer) Tick(tick int) {
|
|
*me.timer = me.timer.Add(time.Duration(tick) * time.Millisecond)
|
|
}
|
|
|
|
/////////////////////////////////////////////////////////
|
|
|
|
// 实体标签
|
|
type EntityTag = component.IComponentType
|
|
|
|
type EntityTagHandler struct {
|
|
Tag EntityTag
|
|
}
|