From 90e373d3fd61f0d4f892d08fee7a86a395e96754 Mon Sep 17 00:00:00 2001 From: xzb <223@qq.com> Date: Thu, 12 Oct 2023 11:06:20 +0800 Subject: [PATCH] =?UTF-8?q?signal=202xh1=20=E9=A9=B1=E9=87=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- component/light.go | 13 ++++++++----- component/signal.go | 2 +- entity/light.go | 2 +- entity/signal.go | 2 +- jl-ecs-go | 2 +- 5 files changed, 12 insertions(+), 9 deletions(-) diff --git a/component/light.go b/component/light.go index b18cc05..8cfb011 100644 --- a/component/light.go +++ b/component/light.go @@ -7,13 +7,16 @@ type LightDrive struct { Td bool } +// DsTag 灯色标签定义 +type DsTag = ecs.IComponentType + // 灯色标签 var ( - LdTag = ecs.NewTag() //绿 - HdTag = ecs.NewTag() //红 - UdTag = ecs.NewTag() //黄 - BdTag = ecs.NewTag() //白 - AdTag = ecs.NewTag() //蓝 + LdTag DsTag = ecs.NewTag() //绿 + HdTag = ecs.NewTag() //红 + UdTag = ecs.NewTag() //黄 + BdTag = ecs.NewTag() //白 + AdTag = ecs.NewTag() //蓝 ) // 组件 diff --git a/component/signal.go b/component/signal.go index ef1c894..8f5d13e 100644 --- a/component/signal.go +++ b/component/signal.go @@ -10,7 +10,7 @@ type SignalLights struct { var SignalLightsType = ecs.NewComponentType[SignalLights]() // GetLightByTag 根据标签获取灯位列表中的某个灯 -func (sl *SignalLights) GetLightByTag(dTag ecs.IComponentType) *ecs.Entry { +func (sl *SignalLights) GetLightByTag(dTag DsTag) *ecs.Entry { for _, light := range sl.Lights { if light.HasComponent(dTag) { return light diff --git a/entity/light.go b/entity/light.go index af433e5..d24f85c 100644 --- a/entity/light.go +++ b/entity/light.go @@ -46,7 +46,7 @@ func NewLightAEntity(w ecs.World) *ecs.Entry { } // 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)) for _, lightTag := range lightTags { lightEntry := NewLightEntity(w) diff --git a/entity/signal.go b/entity/signal.go index 5acc291..213cf5b 100644 --- a/entity/signal.go +++ b/entity/signal.go @@ -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...)} } diff --git a/jl-ecs-go b/jl-ecs-go index e779734..af60502 160000 --- a/jl-ecs-go +++ b/jl-ecs-go @@ -1 +1 @@ -Subproject commit e7797346722a572814539d9a453789b89ffe6bf4 +Subproject commit af605020f1bccf1f1b2ab5a4ae4966d1c6c9776c