55 lines
1.0 KiB
Go
55 lines
1.0 KiB
Go
package cstate
|
||
|
||
import (
|
||
"time"
|
||
|
||
"github.com/yohamta/donburi/component"
|
||
"joylink.club/rtsssimulation/umi"
|
||
)
|
||
|
||
// 此文件中为与设备无关的仿真系统自身的状态定义
|
||
|
||
// 系统时钟,单例
|
||
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
|
||
}
|
||
|
||
/////////////////////////////////////////////////////////
|
||
|
||
// 模型仓库引用
|
||
// 用于world内使用,查询模型
|
||
type ModelStorageRef struct {
|
||
ModelManager umi.IModelManager
|
||
}
|