Advertisement
Guest User

Untitled

a guest
Aug 21st, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. this.public.beforeUnloadChunk = function beforeUnloadChunk (cx, cy) {
  2. var chunkBeingLoaded = (this.public.requestChunkCallbackList[chunkX] && this.public.requestChunkCallbackList[chunkX][chunkY]) ||
  3. (this.background.requestChunkCallbackList[chunkX] && this.background.requestChunkCallbackList[chunkX][chunkY])
  4.  
  5. var publicCanBeUnloaded = this.public.canBeUnloaded(cx, cy) || (this.public.chunks[cx] && this.public.chunks[cx][cy] == "empty");
  6. var backgroundCanBeUnloaded = this.background.canBeUnloaded(cx, cy) || (this.background.chunks[cx] && this.background.chunks[cx][cy] == "empty");
  7.  
  8. if( !chunkBeingLoaded && (publicCanBeUnloaded || backgroundCanBeUnloaded) ) {
  9.  
  10. console.log("Unloading chunk", cx, cy);
  11. if(publicCanBeUnloaded){
  12. this.background.chunks[cx][cy] = null;
  13. delete this.background.chunks[cx][cy];
  14. }
  15. if(backgroundCanBeUnloaded){
  16. this.public.chunks[cx][cy] = null;
  17. delete this.public.chunks[cx][cy];
  18. }
  19. return true;
  20. }
  21.  
  22. return false;
  23. }.bind(this);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement