go_dreamfactory/modules/island/configure.go
2023-10-30 15:00:56 +08:00

52 lines
1.2 KiB
Go

package island
import (
"fmt"
"go_dreamfactory/modules"
cfg "go_dreamfactory/sys/configure/structs"
"go_dreamfactory/lego/core"
)
const (
game_item = "game_item.json"
game_potions = "game_potions.json"
// game_propsgroup = "game_propsgroup.json"
// game_propsgrouplist = "game_propsgrouplist.json"
)
// /背包配置管理组件
type ConfigureComp struct {
modules.MCompConfigure
module *IsLand
}
// 组件初始化接口
func (this *ConfigureComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
this.MCompConfigure.Init(service, module, comp, options)
this.module = module.(*IsLand)
err = this.LoadConfigure(game_item, cfg.NewGameItem)
err = this.LoadConfigure(game_potions, cfg.NewGamePotions)
return
}
// 读取物品配置
func (this *ConfigureComp) GetMaterialConfigure(id int32) (configure *cfg.GamePotionsData, err error) {
var (
v interface{}
ok bool
)
if v, err = this.GetConfigure(game_potions); err != nil {
this.module.Errorf("err:%v", err)
return
} else {
if configure, ok = v.(*cfg.GamePotions).GetDataMap()[id]; !ok {
err = fmt.Errorf("no found Material:%d configure", id)
this.module.Errorf("err:%v", err)
return
}
}
return
}