rts-sim-module/fi/ibp.go
2023-10-12 15:03:11 +08:00

78 lines
1.6 KiB
Go

package fi
import (
"fmt"
"joylink.club/ecs"
"joylink.club/rtsssimulation/component"
"joylink.club/rtsssimulation/entity"
)
// 按下按钮
func PressDownButton(w ecs.World, id string) {
w.Execute(func() {
wd := entity.GetWorldData(w)
entry, ok := wd.EntityMap[id]
if ok {
state := component.BitStateType.Get(entry)
if entry.HasComponent(component.NoResetUpBtn) {
state.Val = false
} else if entry.HasComponent(component.ResetUpBtn) {
state.Val = false
} else {
state.Val = true
}
} else {
fmt.Printf("未找到id=%s的按钮\n", id)
}
})
}
// 抬起拉起按钮
func PressUpButton(w ecs.World, id string) {
w.Execute(func() {
wd := entity.GetWorldData(w)
entry, ok := wd.EntityMap[id]
if ok {
state := component.BitStateType.Get(entry)
if entry.HasComponent(component.NoResetUpBtn) {
state.Val = true
} else if entry.HasComponent(component.ResetUpBtn) {
state.Val = true
} else {
state.Val = false
}
} else {
fmt.Printf("未找到id=%s的按钮\n", id)
}
})
}
// 修改钥匙旋钮关闭状态
func PutKeyOff(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 = 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
} else {
fmt.Printf("未找到id=%s的钥匙开关\n", id)
}
})
}