diff options
Diffstat (limited to 'js/helper-classes/RDGE/src/core/script/objectManager.js')
-rwxr-xr-x | js/helper-classes/RDGE/src/core/script/objectManager.js | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/js/helper-classes/RDGE/src/core/script/objectManager.js b/js/helper-classes/RDGE/src/core/script/objectManager.js index cb9847e6..768768ff 100755 --- a/js/helper-classes/RDGE/src/core/script/objectManager.js +++ b/js/helper-classes/RDGE/src/core/script/objectManager.js | |||
@@ -37,18 +37,18 @@ RDGE.objectManager = function() { | |||
37 | this.objects = []; | 37 | this.objects = []; |
38 | this.numObjects = 0; | 38 | this.numObjects = 0; |
39 | this.freelist = []; | 39 | this.freelist = []; |
40 | 40 | ||
41 | this.reset = function() { | 41 | this.reset = function() { |
42 | this.objects = []; | 42 | this.objects = []; |
43 | this.freelist = []; | 43 | this.freelist = []; |
44 | this.guidCounter = 0; | 44 | this.guidCounter = 0; |
45 | } | 45 | } |
46 | 46 | ||
47 | // validHandle | 47 | // validHandle |
48 | this.validHandle = function(h) { | 48 | this.validHandle = function(h) { |
49 | return this.handleToIndex(h) != -1; | 49 | return this.handleToIndex(h) != -1; |
50 | } | 50 | } |
51 | 51 | ||
52 | // handleToIndex | 52 | // handleToIndex |
53 | this.handleToIndex = function(h) { | 53 | this.handleToIndex = function(h) { |
54 | var index = ( h >> 16 ) & 0xFFFF; | 54 | var index = ( h >> 16 ) & 0xFFFF; |
@@ -58,35 +58,35 @@ RDGE.objectManager = function() { | |||
58 | return -1; | 58 | return -1; |
59 | } | 59 | } |
60 | 60 | ||
61 | // handleToObject | 61 | // handleToObject |
62 | this.handleToObject = function(h) { | 62 | this.handleToObject = function(h) { |
63 | var index = this.handleToIndex( h ); | 63 | var index = this.handleToIndex( h ); |
64 | if( index != -1 ) { | 64 | if( index != -1 ) { |
65 | return this.objects[index]; | 65 | return this.objects[index]; |
66 | } | 66 | } |
67 | return null; | 67 | return null; |
68 | } | 68 | } |
69 | 69 | ||
70 | // add object | 70 | // add object |
71 | this.addObject = function(ob) { | 71 | this.addObject = function(ob) { |
72 | var index = this.objects.length; | 72 | var index = this.objects.length; |
73 | 73 | ||
74 | if( this.freelist.length > 0 ) { | 74 | if( this.freelist.length > 0 ) { |
75 | index = this.freelist.pop(); | 75 | index = this.freelist.pop(); |
76 | } | 76 | } |
77 | if( ++this.guidCounter >= 0xFFFF ) { | 77 | if( ++this.guidCounter >= 0xFFFF ) { |
78 | // wrap the counter, zero is reserved for invalid handles. | 78 | // wrap the counter, zero is reserved for invalid handles. |
79 | this.guidCounter = 1; | 79 | this.guidCounter = 1; |
80 | } | 80 | } |
81 | ob.handle = ( index << 16 | ++this.guidCounter ); | 81 | ob.handle = ( index << 16 | ++this.guidCounter ); |
82 | this.objects[index] = ob; | 82 | this.objects[index] = ob; |
83 | 83 | ||
84 | return ob.handle; | 84 | return ob.handle; |
85 | } | 85 | } |
86 | 86 | ||
87 | // remove object | 87 | // remove object |
88 | this.removeObject = function(h) { | 88 | this.removeObject = function(h) { |
89 | var index = this.handleToIndex( h ); | 89 | var index = this.handleToIndex( h ); |
90 | if( index != -1 ) { | 90 | if( index != -1 ) { |
91 | if( this.objects[index].onremove != undefined ) { | 91 | if( this.objects[index].onremove != undefined ) { |
92 | this.objects[index].onremove(); | 92 | this.objects[index].onremove(); |