From 18c7a33cdc463ac6a2e2772f4e12fc740459657f Mon Sep 17 00:00:00 2001 From: xzb <223@qq.com> Date: Tue, 26 Sep 2023 15:28:29 +0800 Subject: [PATCH] =?UTF-8?q?=E9=81=93=E5=B2=94=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/test1/sjzdj9/main.go | 9 +-------- system/percentage_system.go | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/examples/test1/sjzdj9/main.go b/examples/test1/sjzdj9/main.go index 18594c8..cf21134 100644 --- a/examples/test1/sjzdj9/main.go +++ b/examples/test1/sjzdj9/main.go @@ -44,14 +44,7 @@ func Test() { system.Switch2jZdj9DriveFc(world, "sw1", true) // time.Sleep(12 * time.Second) - system.Switch2jZdj9DriveYc(world, "sw1", false) - system.Switch2jZdj9DriveFc(world, "sw1", false) - time.Sleep(1 * time.Second) - //联锁驱动定操 - system.Switch2jZdj9DriveYc(world, "sw1", true) - system.Switch2jZdj9DriveDc(world, "sw1", true) - // - time.Sleep(12 * time.Second) + world.Close() } diff --git a/system/percentage_system.go b/system/percentage_system.go index a1c534d..af7118f 100644 --- a/system/percentage_system.go +++ b/system/percentage_system.go @@ -71,19 +71,19 @@ func NewPercentageMovableSystem() *PercentageMovableSystem { // Update world 执行 func (me *PercentageMovableSystem) Update(w ecs.World) { me.query.Each(w, func(e *ecs.Entry) { - var state *PercentageDeviceState if e.HasComponent(PercentageDeviceStateComponent) { - state = PercentageDeviceStateComponent.Get(e) - } - if e.HasComponent(PercentageDeviceState1Component) { - state = PercentageDeviceState1Component.Get(e) - } - if e.HasComponent(PercentageDeviceState2Component) { - state = PercentageDeviceState2Component.Get(e) - } - if state != nil { + state := PercentageDeviceStateComponent.Get(e) me.move(w, state) } + if e.HasComponent(PercentageDeviceState1Component) { + state := PercentageDeviceState1Component.Get(e) + me.move(w, state) + } + if e.HasComponent(PercentageDeviceState2Component) { + state := PercentageDeviceState2Component.Get(e) + me.move(w, state) + } + }) } func (me *PercentageMovableSystem) move(w ecs.World, state *PercentageDeviceState) {