【修改转动钥匙挡位按钮】

This commit is contained in:
weizhihong 2023-10-20 13:20:05 +08:00
parent 41460f29c1
commit caeff9b089
3 changed files with 6 additions and 20 deletions

View File

@ -45,7 +45,7 @@ var AlarmDriveType = ecs.NewComponentType[AlarmDrive]()
// 挡位组件
type GearState struct {
Val int
Val int32
}
var GearStateType = ecs.NewComponentType[GearState]()

View File

@ -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
}

View File

@ -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)
}