29 lines
971 B
Go
29 lines
971 B
Go
package entity
|
|
|
|
import (
|
|
"joylink.club/ecs"
|
|
"joylink.club/rtsssimulation/component"
|
|
"joylink.club/rtsssimulation/repository"
|
|
)
|
|
|
|
// 创建继电器实体
|
|
func NewRelayEntity(w ecs.World, relay *repository.Relay, entityMap map[string]*ecs.Entry) *ecs.Entry {
|
|
uid := relay.Id()
|
|
// model := proto.Relay_Model_name[int32(relay.Model())]
|
|
entry, ok := entityMap[uid]
|
|
if !ok {
|
|
entry = w.Entry(w.Create(component.RelayTag, component.UidType, component.BitStateType))
|
|
component.UidType.SetValue(entry, component.Uid{Id: uid})
|
|
// if strings.Contains(model, "Y") { // 有极继电器
|
|
// entry.AddComponent(component.YjRelayTag)
|
|
// } else if strings.Contains(model, "W") || strings.Contains(model, "Z") || strings.Contains(model, "P") { // 无极继电器
|
|
// entry.AddComponent(component.WjRelayTag)
|
|
// }
|
|
// if strings.Contains(model, "H") { // 缓放继电器
|
|
// entry.AddComponent(component.HfRelayTag)
|
|
// }
|
|
entityMap[uid] = entry
|
|
}
|
|
return entry
|
|
}
|