map_tile.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. // Code generated by excel export. DO NOT EDIT.
  2. package data
  3. var MapTile = &mapTileConfig{}
  4. func init() {
  5. _allList = append(_allList, MapTile)
  6. }
  7. type (
  8. MapTileRow struct {
  9. ConfigID int32 `json:"ConfigID"` // 地块配置ID
  10. IsWalkable bool `json:"IsWalkable"` // 可行走
  11. }
  12. mapTileConfig struct {
  13. baseConfig
  14. list []*MapTileRow // all list
  15. configIDUniMaps map[int32]*MapTileRow // key:configID
  16. }
  17. )
  18. func (p *mapTileConfig) Name() string {
  19. return "map_tile"
  20. }
  21. func (p *mapTileConfig) Init() {
  22. p.configIDUniMaps = map[int32]*MapTileRow{}
  23. }
  24. func (p *mapTileConfig) OnLoad(maps interface{}, reload bool) (int, error) {
  25. if reload && p.denyLoad {
  26. return 0, nil
  27. }
  28. var list []*MapTileRow
  29. if err := DecodeData(maps, &list); err != nil {
  30. return 0, err
  31. }
  32. p.list = list
  33. configIDUniMaps := map[int32]*MapTileRow{}
  34. for _, row := range list {
  35. configIDUniMaps[row.ConfigID] = row
  36. }
  37. p.configIDUniMaps = configIDUniMaps
  38. return len(list), nil
  39. }
  40. // func (p *mapTileConfig) OnAfterLoad(_ bool) {
  41. // }
  42. func (p *mapTileConfig) List() []*MapTileRow {
  43. return p.list
  44. }
  45. func (p *mapTileConfig) GetByConfigID(configID int32) (*MapTileRow, bool) {
  46. value, found := p.configIDUniMaps[configID]
  47. return value, found
  48. }
  49. func (p *mapTileConfig) ContainConfigID(configID int32) bool {
  50. _, found := p.configIDUniMaps[configID]
  51. return found
  52. }