2023-10-11 13:22:14 +08:00
|
|
|
package entity
|
|
|
|
|
2023-10-11 13:38:33 +08:00
|
|
|
import (
|
|
|
|
"joylink.club/ecs"
|
|
|
|
"joylink.club/rtsssimulation/component"
|
|
|
|
)
|
2023-10-11 13:22:14 +08:00
|
|
|
|
2023-10-11 13:38:33 +08:00
|
|
|
// NewLightEntity 创建无色灯实体
|
|
|
|
func NewLightEntity(w ecs.World) *ecs.Entry {
|
|
|
|
return w.Entry(w.Create(component.LightDriveType, component.BitStateType))
|
2023-10-11 13:22:14 +08:00
|
|
|
}
|
2023-10-11 13:46:34 +08:00
|
|
|
|
|
|
|
// NewLightLEntity 创建绿色灯实体
|
|
|
|
func NewLightLEntity(w ecs.World) *ecs.Entry {
|
|
|
|
e := NewLightEntity(w)
|
|
|
|
e.AddComponent(component.LdTag)
|
|
|
|
return e
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewLightHEntity 创建红色灯实体
|
|
|
|
func NewLightHEntity(w ecs.World) *ecs.Entry {
|
|
|
|
e := NewLightEntity(w)
|
|
|
|
e.AddComponent(component.HdTag)
|
|
|
|
return e
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewLightUEntity 创建黄色灯实体
|
|
|
|
func NewLightUEntity(w ecs.World) *ecs.Entry {
|
|
|
|
e := NewLightEntity(w)
|
|
|
|
e.AddComponent(component.UdTag)
|
|
|
|
return e
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewLightBEntity 创建白色灯实体
|
|
|
|
func NewLightBEntity(w ecs.World) *ecs.Entry {
|
|
|
|
e := NewLightEntity(w)
|
|
|
|
e.AddComponent(component.BdTag)
|
|
|
|
return e
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewLightAEntity 创建蓝色灯实体
|
|
|
|
func NewLightAEntity(w ecs.World) *ecs.Entry {
|
|
|
|
e := NewLightEntity(w)
|
|
|
|
e.AddComponent(component.AdTag)
|
|
|
|
return e
|
|
|
|
}
|
2023-10-12 11:00:56 +08:00
|
|
|
|
|
|
|
// NewLights 创建灯位列表(灯位顺序与lightTags一致)
|
2023-10-12 11:06:20 +08:00
|
|
|
func NewLights(w ecs.World, lightTags ...component.DsTag) []*ecs.Entry {
|
2023-10-12 11:00:56 +08:00
|
|
|
ls := make([]*ecs.Entry, 0, len(lightTags))
|
|
|
|
for _, lightTag := range lightTags {
|
|
|
|
lightEntry := NewLightEntity(w)
|
|
|
|
lightEntry.AddComponent(lightTag)
|
|
|
|
ls = append(ls, lightEntry)
|
|
|
|
}
|
|
|
|
return ls
|
|
|
|
}
|