aozhiwei 51763fc58a 1
2024-06-21 11:36:18 +08:00

38 lines
612 B
Go

package mt
import (
"q5"
"f5"
"mtb"
"strings"
)
type Item struct {
mtb.Item
lowerName string
}
type ItemTable struct {
f5.IdMetaTable[Item]
itemIdHash *q5.ConcurrentMap[int64, *Item]
}
func (this *Item) Init1() {
this.lowerName = strings.ToLower(this.GetName())
}
func (this *ItemTable) Load() {
this.itemIdHash = new(q5.ConcurrentMap[int64, *Item])
}
func (this *ItemTable) Search(name string, itemIds map[int32]int32) {
name = strings.ToLower(name)
this.Traverse(
func (ele *Item) bool {
if strings.Contains(ele.lowerName, name) {
itemIds[ele.GetId()] = 1
}
return true
})
}