map_res.go 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. // Code generated by excel export. DO NOT EDIT.
  2. package data
  3. import (
  4. "f1-game/internal/types"
  5. )
  6. var MapRes = &mapResConfig{}
  7. func init() {
  8. _allList = append(_allList, MapRes)
  9. }
  10. type (
  11. MapResRow struct {
  12. ConfigID int32 `json:"ConfigID"` // 资源配置ID
  13. Level int32 `json:"Level"` // 等级
  14. ItemID int32 `json:"ItemID"` // 产出ID
  15. Yield int64 `json:"Yield"` // 每小时产出量
  16. Armies types.List[int32] `json:"Armies"` // 守军部队
  17. }
  18. mapResConfig struct {
  19. baseConfig
  20. list []*MapResRow // all list
  21. configIDUniMaps map[int32]*MapResRow // key:configID
  22. }
  23. )
  24. func (p *mapResConfig) Name() string {
  25. return "map_res"
  26. }
  27. func (p *mapResConfig) Init() {
  28. p.configIDUniMaps = map[int32]*MapResRow{}
  29. }
  30. func (p *mapResConfig) OnLoad(maps interface{}, reload bool) (int, error) {
  31. if reload && p.denyLoad {
  32. return 0, nil
  33. }
  34. var list []*MapResRow
  35. if err := DecodeData(maps, &list); err != nil {
  36. return 0, err
  37. }
  38. p.list = list
  39. configIDUniMaps := map[int32]*MapResRow{}
  40. for _, row := range list {
  41. configIDUniMaps[row.ConfigID] = row
  42. }
  43. p.configIDUniMaps = configIDUniMaps
  44. return len(list), nil
  45. }
  46. // func (p *mapResConfig) OnAfterLoad(_ bool) {
  47. // }
  48. func (p *mapResConfig) List() []*MapResRow {
  49. return p.list
  50. }
  51. func (p *mapResConfig) GetByConfigID(configID int32) (*MapResRow, bool) {
  52. value, found := p.configIDUniMaps[configID]
  53. return value, found
  54. }
  55. func (p *mapResConfig) ContainConfigID(configID int32) bool {
  56. _, found := p.configIDUniMaps[configID]
  57. return found
  58. }