map_area_state.go 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. // Code generated by excel export. DO NOT EDIT.
  2. package data
  3. var MapAreaState = &mapAreaStateConfig{}
  4. func init() {
  5. _allList = append(_allList, MapAreaState)
  6. }
  7. type (
  8. MapAreaStateRow struct {
  9. ID int32 `json:"ID"` // 州ID
  10. MapID int32 `json:"MapID"` // 地图ID
  11. Type int32 `json:"Type"` // 类型
  12. BornLimit int32 `json:"BornLimit"` // 出生名额
  13. }
  14. mapAreaStateConfig struct {
  15. baseConfig
  16. list []*MapAreaStateRow // all list
  17. idUniMaps map[int32]*MapAreaStateRow // key:id
  18. mapIDIDUniMaps map[int32]map[int32]*MapAreaStateRow // key:mapID, id
  19. }
  20. )
  21. func (p *mapAreaStateConfig) Name() string {
  22. return "map_area_state"
  23. }
  24. func (p *mapAreaStateConfig) Init() {
  25. p.idUniMaps = map[int32]*MapAreaStateRow{}
  26. p.mapIDIDUniMaps = map[int32]map[int32]*MapAreaStateRow{}
  27. }
  28. func (p *mapAreaStateConfig) OnLoad(maps interface{}, reload bool) (int, error) {
  29. if reload && p.denyLoad {
  30. return 0, nil
  31. }
  32. var list []*MapAreaStateRow
  33. if err := DecodeData(maps, &list); err != nil {
  34. return 0, err
  35. }
  36. p.list = list
  37. idUniMaps := map[int32]*MapAreaStateRow{}
  38. for _, row := range list {
  39. idUniMaps[row.ID] = row
  40. }
  41. p.idUniMaps = idUniMaps
  42. mapIDIDUniMaps := map[int32]map[int32]*MapAreaStateRow{}
  43. for _, row := range list {
  44. itemMap := mapIDIDUniMaps[row.MapID]
  45. if itemMap == nil {
  46. itemMap = map[int32]*MapAreaStateRow{}
  47. mapIDIDUniMaps[row.MapID] = itemMap
  48. }
  49. itemMap[row.ID] = row
  50. }
  51. p.mapIDIDUniMaps = mapIDIDUniMaps
  52. return len(list), nil
  53. }
  54. // func (p *mapAreaStateConfig) OnAfterLoad(_ bool) {
  55. // }
  56. func (p *mapAreaStateConfig) List() []*MapAreaStateRow {
  57. return p.list
  58. }
  59. func (p *mapAreaStateConfig) GetByID(id int32) (*MapAreaStateRow, bool) {
  60. value, found := p.idUniMaps[id]
  61. return value, found
  62. }
  63. func (p *mapAreaStateConfig) ContainID(id int32) bool {
  64. _, found := p.idUniMaps[id]
  65. return found
  66. }
  67. func (p *mapAreaStateConfig) GetByMapIDID(mapID int32, id int32) (*MapAreaStateRow, bool) {
  68. mapItem, found := p.mapIDIDUniMaps[mapID]
  69. if !found {
  70. return nil, false
  71. }
  72. value, found := mapItem[id]
  73. return value, found
  74. }
  75. func (p *mapAreaStateConfig) ContainMapIDID(mapID int32, id int32) bool {
  76. mapItem, found := p.mapIDIDUniMaps[mapID]
  77. if !found {
  78. return false
  79. }
  80. _, found = mapItem[id]
  81. return found
  82. }