From 648ee61ae84216d0236e0dbc211addc13b2cfa3a Mon Sep 17 00:00:00 2001 From: Kris Kowal Date: Fri, 6 Jul 2012 11:52:06 -0700 Subject: Expand tabs --- .../RDGE/src/core/script/objectManager.js | 120 ++++++++++----------- 1 file changed, 60 insertions(+), 60 deletions(-) (limited to 'js/helper-classes/RDGE/src/core/script/objectManager.js') diff --git a/js/helper-classes/RDGE/src/core/script/objectManager.js b/js/helper-classes/RDGE/src/core/script/objectManager.js index 66e06cde..cb9847e6 100755 --- a/js/helper-classes/RDGE/src/core/script/objectManager.js +++ b/js/helper-classes/RDGE/src/core/script/objectManager.js @@ -33,66 +33,66 @@ var RDGE = RDGE || {}; /* generic handle-based object manager */ RDGE.objectManager = function() { - this.guidCounter = 0; - this.objects = []; - this.numObjects = 0; - this.freelist = []; - - this.reset = function() { - this.objects = []; - this.freelist = []; - this.guidCounter = 0; - } - - // validHandle - this.validHandle = function(h) { - return this.handleToIndex(h) != -1; - } - - // handleToIndex - this.handleToIndex = function(h) { - var index = ( h >> 16 ) & 0xFFFF; - if( this.objects[index] != null && h == this.objects[index].handle ) { - return index; - } - return -1; - } + this.guidCounter = 0; + this.objects = []; + this.numObjects = 0; + this.freelist = []; + + this.reset = function() { + this.objects = []; + this.freelist = []; + this.guidCounter = 0; + } + + // validHandle + this.validHandle = function(h) { + return this.handleToIndex(h) != -1; + } + + // handleToIndex + this.handleToIndex = function(h) { + var index = ( h >> 16 ) & 0xFFFF; + if( this.objects[index] != null && h == this.objects[index].handle ) { + return index; + } + return -1; + } - // handleToObject - this.handleToObject = function(h) { - var index = this.handleToIndex( h ); - if( index != -1 ) { - return this.objects[index]; - } - return null; - } - - // add object - this.addObject = function(ob) { - var index = this.objects.length; + // handleToObject + this.handleToObject = function(h) { + var index = this.handleToIndex( h ); + if( index != -1 ) { + return this.objects[index]; + } + return null; + } + + // add object + this.addObject = function(ob) { + var index = this.objects.length; - if( this.freelist.length > 0 ) { - index = this.freelist.pop(); - } - if( ++this.guidCounter >= 0xFFFF ) { - // wrap the counter, zero is reserved for invalid handles. - this.guidCounter = 1; - } - ob.handle = ( index << 16 | ++this.guidCounter ); - this.objects[index] = ob; - - return ob.handle; - } - - // remove object - this.removeObject = function(h) { - var index = this.handleToIndex( h ); - if( index != -1 ) { - if( this.objects[index].onremove != undefined ) { - this.objects[index].onremove(); - } - this.objects[index] = null; - this.freelist.push(index); - } - } + if( this.freelist.length > 0 ) { + index = this.freelist.pop(); + } + if( ++this.guidCounter >= 0xFFFF ) { + // wrap the counter, zero is reserved for invalid handles. + this.guidCounter = 1; + } + ob.handle = ( index << 16 | ++this.guidCounter ); + this.objects[index] = ob; + + return ob.handle; + } + + // remove object + this.removeObject = function(h) { + var index = this.handleToIndex( h ); + if( index != -1 ) { + if( this.objects[index].onremove != undefined ) { + this.objects[index].onremove(); + } + this.objects[index] = null; + this.freelist.push(index); + } + } } -- cgit v1.2.3