Advertisement
Guest User

Untitled

a guest
Jul 20th, 2015
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. #include "ChunkMap.h"
  2. #include "ChunkData.h"
  3. #include "Region.h"
  4.  
  5. void ChunkMap::onCreate()
  6. {
  7.  
  8. }
  9.  
  10. void ChunkMap::onDestroy()
  11. {
  12.  
  13. }
  14.  
  15. Chunk* ChunkMap::getChunk(const Vec2i& aCoords)
  16. {
  17. Vec2i regionCoords = ChunkConstants::chunkToRegion(aCoords);
  18.  
  19. for(uint i = 0; i < mRegions.size(); i++)
  20. {
  21. if(mRegions[i]->getCoords() == regionCoords)
  22. {
  23. return mRegions[i]->getChunk(aCoords);
  24. }
  25. }
  26.  
  27. Region* region = GetFramework()->createGameObject()->addComponent<Region>();
  28. region->setCoords(regionCoords);
  29.  
  30. mRegions.push_back(region);
  31.  
  32. return region->getChunk(aCoords);
  33. }
  34.  
  35. Chunk* ChunkMap::findChunk(const Vec2i& aCoords)
  36. {
  37. Vec2i regionCoords = ChunkConstants::chunkToRegion(aCoords);
  38.  
  39. for(uint i = 0; i < mRegions.size(); i++)
  40. {
  41. if(mRegions[i]->getCoords() == regionCoords)
  42. {
  43. return mRegions[i]->findChunk(aCoords);
  44. }
  45. }
  46.  
  47. return nullptr;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement