diff --git a/component/ibp.go b/component/ibp.go index 557aade..131f43e 100644 --- a/component/ibp.go +++ b/component/ibp.go @@ -45,7 +45,7 @@ var AlarmDriveType = ecs.NewComponentType[AlarmDrive]() // 挡位组件 type GearState struct { - Val int + Val int32 } var GearStateType = ecs.NewComponentType[GearState]() diff --git a/entity/ibp.go b/entity/ibp.go index a741456..d442c21 100644 --- a/entity/ibp.go +++ b/entity/ibp.go @@ -153,7 +153,7 @@ func setSpkDefault(spk *component.SpkElectronic) { } // 设置IBP钥匙状态 -func setIbpKeyGearVal(entry *ecs.Entry, val int) { +func setIbpKeyGearVal(entry *ecs.Entry, val int32) { if entry == nil { return } diff --git a/fi/ibp.go b/fi/ibp.go index 52188fd..f017b1e 100644 --- a/fi/ibp.go +++ b/fi/ibp.go @@ -48,28 +48,14 @@ func PressUpButton(w ecs.World, id string) { }) } -// 修改钥匙旋钮关闭状态 -func PutKeyOff(w ecs.World, id string) { +// 修改钥匙挡位 +func SwitchKeyGear(w ecs.World, id string, gear int32) { w.Execute(func() { wd := entity.GetWorldData(w) entry, ok := wd.EntityMap[id] if ok { - state := component.BitStateType.Get(entry) - state.Val = false - } else { - fmt.Printf("未找到id=%s的钥匙开关\n", id) - } - }) -} - -// 修改钥匙旋钮开启状态 -func PutKeyOn(w ecs.World, id string) { - w.Execute(func() { - wd := entity.GetWorldData(w) - entry, ok := wd.EntityMap[id] - if ok { - state := component.BitStateType.Get(entry) - state.Val = true + state := component.GearStateType.Get(entry) + state.Val = gear } else { fmt.Printf("未找到id=%s的钥匙开关\n", id) }