2024-01-12 18:20:21 +08:00
|
|
|
package entity
|
|
|
|
|
|
|
|
import (
|
|
|
|
"joylink.club/ecs"
|
|
|
|
"joylink.club/rtsssimulation/component"
|
|
|
|
"joylink.club/rtsssimulation/component/relation"
|
|
|
|
"joylink.club/rtsssimulation/component/singleton"
|
|
|
|
"joylink.club/rtsssimulation/modelrepo/model"
|
|
|
|
)
|
|
|
|
|
|
|
|
// 电子元件相关实体创建
|
|
|
|
|
|
|
|
// 创建断相保护器实体
|
2024-01-16 18:08:06 +08:00
|
|
|
func NewDbq(w ecs.World, dbq model.Dbq) *ecs.Entry {
|
2024-01-12 18:20:21 +08:00
|
|
|
uid := dbq.Uid().Id()
|
|
|
|
re := w.Entry(w.Create(component.DBQTag, component.UidType, component.DbqModelRelaType, component.DbqStateType, component.CounterType))
|
|
|
|
component.UidType.Set(re, &component.Uid{Id: uid})
|
|
|
|
component.DbqModelRelaType.Set(re, &relation.DbqModelRela{M: dbq})
|
|
|
|
singleton.GetEntityUidIndex(w).Add(uid, re)
|
|
|
|
return re
|
|
|
|
}
|
|
|
|
|
|
|
|
// 创建继电器实体
|
|
|
|
func NewRelay(w ecs.World, r model.Relay) *ecs.Entry {
|
|
|
|
uid := r.Uid().Id()
|
|
|
|
re := w.Entry(w.Create(component.RelayTag, component.UidType, component.RelayModelRelaType, component.RelayStateType))
|
|
|
|
component.UidType.Set(re, &component.Uid{Id: uid})
|
|
|
|
component.RelayModelRelaType.Set(re, &relation.RelayModelRela{M: r})
|
|
|
|
singleton.GetEntityUidIndex(w).Add(uid, re)
|
|
|
|
return re
|
|
|
|
}
|