rts-sim-module/state/system_state.go

46 lines
824 B
Go
Raw Normal View History

2023-08-15 16:50:24 +08:00
package state
2023-08-16 18:13:18 +08:00
import (
"time"
"github.com/yohamta/donburi/component"
)
2023-08-15 16:50:24 +08:00
// 此文件中为与设备无关的仿真系统自身的状态定义
// 系统时钟,单例
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)
}
2023-08-16 18:13:18 +08:00
/////////////////////////////////////////////////////////
// 实体标签
type EntityTag = component.IComponentType
type EntityTagHandler struct {
Tag EntityTag
}