| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- // Code generated by excel export. DO NOT EDIT.
- package data
- import (
- "f1-game/internal/types"
- )
- var MapBuildUpgrade = &mapBuildUpgradeConfig{}
- func init() {
- _allList = append(_allList, MapBuildUpgrade)
- }
- type (
- MapBuildUpgradeRow struct {
- ConfigID int32 `json:"ConfigID"` // 建筑配置ID
- Level int32 `json:"Level"` // 等级
- UpgradeCost types.Assets `json:"UpgradeCost"` // 升级消耗
- UpgradeTime int64 `json:"UpgradeTime"` // 升级时间
- Durability int32 `json:"Durability"` // 耐久
- ViewRange int32 `json:"ViewRange"` // 视野范围
- LeagueBuildAttrs types.Attrs `json:"LeagueBuildAttrs"` // 联盟建筑属性
- }
- mapBuildUpgradeConfig struct {
- baseConfig
- list []*MapBuildUpgradeRow // all list
- configIDListMaps map[int32][]*MapBuildUpgradeRow // key:configID
- configIDLevelUniMaps map[int32]map[int32]*MapBuildUpgradeRow // key:configID, level
- }
- )
- func (p *mapBuildUpgradeConfig) Name() string {
- return "map_build_upgrade"
- }
- func (p *mapBuildUpgradeConfig) Init() {
- p.configIDListMaps = map[int32][]*MapBuildUpgradeRow{}
- p.configIDLevelUniMaps = map[int32]map[int32]*MapBuildUpgradeRow{}
- }
- func (p *mapBuildUpgradeConfig) OnLoad(maps interface{}, reload bool) (int, error) {
- if reload && p.denyLoad {
- return 0, nil
- }
- var list []*MapBuildUpgradeRow
- if err := DecodeData(maps, &list); err != nil {
- return 0, err
- }
- p.list = list
- configIDListMaps := map[int32][]*MapBuildUpgradeRow{}
- for _, row := range list {
- configIDListMaps[row.ConfigID] = append(configIDListMaps[row.ConfigID], row)
- }
- p.configIDListMaps = configIDListMaps
- configIDLevelUniMaps := map[int32]map[int32]*MapBuildUpgradeRow{}
- for _, row := range list {
- itemMap := configIDLevelUniMaps[row.ConfigID]
- if itemMap == nil {
- itemMap = map[int32]*MapBuildUpgradeRow{}
- configIDLevelUniMaps[row.ConfigID] = itemMap
- }
- itemMap[row.Level] = row
- }
- p.configIDLevelUniMaps = configIDLevelUniMaps
- return len(list), nil
- }
- // func (p *mapBuildUpgradeConfig) OnAfterLoad(_ bool) {
- // }
- func (p *mapBuildUpgradeConfig) List() []*MapBuildUpgradeRow {
- return p.list
- }
- func (p *mapBuildUpgradeConfig) ListByConfigID(configID int32) ([]*MapBuildUpgradeRow, bool) {
- value, found := p.configIDListMaps[configID]
- return value, found
- }
- func (p *mapBuildUpgradeConfig) ListContainConfigID(configID int32) bool {
- _, found := p.configIDListMaps[configID]
- return found
- }
- func (p *mapBuildUpgradeConfig) GetByConfigIDLevel(configID int32, level int32) (*MapBuildUpgradeRow, bool) {
- mapItem, found := p.configIDLevelUniMaps[configID]
- if !found {
- return nil, false
- }
- value, found := mapItem[level]
- return value, found
- }
- func (p *mapBuildUpgradeConfig) ContainConfigIDLevel(configID int32, level int32) bool {
- mapItem, found := p.configIDLevelUniMaps[configID]
- if !found {
- return false
- }
- _, found = mapItem[level]
- return found
- }
|