【修改IBP接口请求】

This commit is contained in:
weizhihong 2023-10-24 17:58:28 +08:00
parent af7cb83fa8
commit 60eca82a83

View File

@ -9,43 +9,49 @@ import (
) )
// 按下按钮 // 按下按钮
func PressDownButton(w ecs.World, id string) { func PressDownButton(w ecs.World, id string) error {
w.Execute(func() { result := <-ecs.Request[ecs.EmptyType](w, func() ecs.Result[ecs.EmptyType] {
wd := entity.GetWorldData(w) wd := entity.GetWorldData(w)
entry, ok := wd.EntityMap[id] entry, ok := wd.EntityMap[id]
if ok { if ok {
state := component.BitStateType.Get(entry) state := component.BitStateType.Get(entry)
state.Val = true state.Val = true
} else { } else {
fmt.Printf("未找到id=%s的按钮\n", id) return ecs.NewErrResult(fmt.Errorf("未找到id=%s的按钮", id))
} }
return ecs.NewOkEmptyResult()
}) })
return result.Err
} }
// 抬起拉起按钮 // 抬起拉起按钮
func PressUpButton(w ecs.World, id string) { func PressUpButton(w ecs.World, id string) error {
w.Execute(func() { result := <-ecs.Request[ecs.EmptyType](w, func() ecs.Result[ecs.EmptyType] {
wd := entity.GetWorldData(w) wd := entity.GetWorldData(w)
entry, ok := wd.EntityMap[id] entry, ok := wd.EntityMap[id]
if ok { if ok {
state := component.BitStateType.Get(entry) state := component.BitStateType.Get(entry)
state.Val = false state.Val = false
} else { } else {
fmt.Printf("未找到id=%s的按钮\n", id) return ecs.NewErrResult(fmt.Errorf("未找到id=%s的按钮", id))
} }
return ecs.NewOkEmptyResult()
}) })
return result.Err
} }
// 修改钥匙挡位 // 修改钥匙挡位
func SwitchKeyGear(w ecs.World, id string, gear int32) { func SwitchKeyGear(w ecs.World, id string, gear int32) error {
w.Execute(func() { result := <-ecs.Request[ecs.EmptyType](w, func() ecs.Result[ecs.EmptyType] {
wd := entity.GetWorldData(w) wd := entity.GetWorldData(w)
entry, ok := wd.EntityMap[id] entry, ok := wd.EntityMap[id]
if ok { if ok {
state := component.GearStateType.Get(entry) state := component.GearStateType.Get(entry)
state.Val = gear state.Val = gear
} else { } else {
fmt.Printf("未找到id=%s的钥匙开关\n", id) return ecs.NewErrResult(fmt.Errorf("未找到id=%s的钥匙开关", id))
} }
return ecs.NewOkEmptyResult()
}) })
return result.Err
} }