signal 2xh1 驱采

This commit is contained in:
xzb 2023-10-12 11:06:20 +08:00
parent 3e8fe93701
commit 90e373d3fd
5 changed files with 12 additions and 9 deletions

View File

@ -7,13 +7,16 @@ type LightDrive struct {
Td bool Td bool
} }
// DsTag 灯色标签定义
type DsTag = ecs.IComponentType
// 灯色标签 // 灯色标签
var ( var (
LdTag = ecs.NewTag() //绿 LdTag DsTag = ecs.NewTag() //绿
HdTag = ecs.NewTag() //红 HdTag = ecs.NewTag() //红
UdTag = ecs.NewTag() //黄 UdTag = ecs.NewTag() //黄
BdTag = ecs.NewTag() //白 BdTag = ecs.NewTag() //白
AdTag = ecs.NewTag() //蓝 AdTag = ecs.NewTag() //蓝
) )
// 组件 // 组件

View File

@ -10,7 +10,7 @@ type SignalLights struct {
var SignalLightsType = ecs.NewComponentType[SignalLights]() var SignalLightsType = ecs.NewComponentType[SignalLights]()
// GetLightByTag 根据标签获取灯位列表中的某个灯 // GetLightByTag 根据标签获取灯位列表中的某个灯
func (sl *SignalLights) GetLightByTag(dTag ecs.IComponentType) *ecs.Entry { func (sl *SignalLights) GetLightByTag(dTag DsTag) *ecs.Entry {
for _, light := range sl.Lights { for _, light := range sl.Lights {
if light.HasComponent(dTag) { if light.HasComponent(dTag) {
return light return light

View File

@ -46,7 +46,7 @@ func NewLightAEntity(w ecs.World) *ecs.Entry {
} }
// NewLights 创建灯位列表(灯位顺序与lightTags一致) // NewLights 创建灯位列表(灯位顺序与lightTags一致)
func NewLights(w ecs.World, lightTags ...ecs.IComponentType) []*ecs.Entry { func NewLights(w ecs.World, lightTags ...component.DsTag) []*ecs.Entry {
ls := make([]*ecs.Entry, 0, len(lightTags)) ls := make([]*ecs.Entry, 0, len(lightTags))
for _, lightTag := range lightTags { for _, lightTag := range lightTags {
lightEntry := NewLightEntity(w) lightEntry := NewLightEntity(w)

View File

@ -74,6 +74,6 @@ func newSignalEntity(w ecs.World, uid string, worldData *component.WorldData) *e
} }
// 新建灯位列表 // 新建灯位列表
func newSignalLights(w ecs.World, lightTags ...ecs.IComponentType) *component.SignalLights { func newSignalLights(w ecs.World, lightTags ...component.DsTag) *component.SignalLights {
return &component.SignalLights{Lights: NewLights(w, lightTags...)} return &component.SignalLights{Lights: NewLights(w, lightTags...)}
} }

@ -1 +1 @@
Subproject commit e7797346722a572814539d9a453789b89ffe6bf4 Subproject commit af605020f1bccf1f1b2ab5a4ae4966d1c6c9776c