map_monster_area.go 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. // Code generated by excel export. DO NOT EDIT.
  2. package data
  3. var MapMonsterArea = &mapMonsterAreaConfig{}
  4. func init() {
  5. _allList = append(_allList, MapMonsterArea)
  6. }
  7. type (
  8. MapMonsterAreaRow struct {
  9. MonsterAreaID int32 `json:"MonsterAreaID"` // 怪物区域ID
  10. MonsterConfigID int32 `json:"MonsterConfigID"` // 怪物配置ID
  11. Num int32 `json:"Num"` // 数量
  12. }
  13. mapMonsterAreaConfig struct {
  14. baseConfig
  15. list []*MapMonsterAreaRow // all list
  16. monsterAreaIDListMaps map[int32][]*MapMonsterAreaRow // key:monsterAreaID
  17. }
  18. )
  19. func (p *mapMonsterAreaConfig) Name() string {
  20. return "map_monster_area"
  21. }
  22. func (p *mapMonsterAreaConfig) Init() {
  23. p.monsterAreaIDListMaps = map[int32][]*MapMonsterAreaRow{}
  24. }
  25. func (p *mapMonsterAreaConfig) OnLoad(maps interface{}, reload bool) (int, error) {
  26. if reload && p.denyLoad {
  27. return 0, nil
  28. }
  29. var list []*MapMonsterAreaRow
  30. if err := DecodeData(maps, &list); err != nil {
  31. return 0, err
  32. }
  33. p.list = list
  34. monsterAreaIDListMaps := map[int32][]*MapMonsterAreaRow{}
  35. for _, row := range list {
  36. monsterAreaIDListMaps[row.MonsterAreaID] = append(monsterAreaIDListMaps[row.MonsterAreaID], row)
  37. }
  38. p.monsterAreaIDListMaps = monsterAreaIDListMaps
  39. return len(list), nil
  40. }
  41. // func (p *mapMonsterAreaConfig) OnAfterLoad(_ bool) {
  42. // }
  43. func (p *mapMonsterAreaConfig) List() []*MapMonsterAreaRow {
  44. return p.list
  45. }
  46. func (p *mapMonsterAreaConfig) ListByMonsterAreaID(monsterAreaID int32) ([]*MapMonsterAreaRow, bool) {
  47. value, found := p.monsterAreaIDListMaps[monsterAreaID]
  48. return value, found
  49. }
  50. func (p *mapMonsterAreaConfig) ListContainMonsterAreaID(monsterAreaID int32) bool {
  51. _, found := p.monsterAreaIDListMaps[monsterAreaID]
  52. return found
  53. }