Compute the index where we need to insert the new component
| 66 | |
| 67 | // Compute the index where we need to insert the new component |
| 68 | uint32 Components::prepareAddComponent(bool isDisabled) { |
| 69 | |
| 70 | // If we need to allocate more components |
| 71 | if (mNbComponents == mNbAllocatedComponents) { |
| 72 | allocate(mNbAllocatedComponents * 2); |
| 73 | } |
| 74 | |
| 75 | uint32 index; |
| 76 | |
| 77 | // If the component to add is part of a disabled entity or there are no disabled entity |
| 78 | if (isDisabled) { |
| 79 | |
| 80 | // Add the component at the end of the array |
| 81 | index = mNbComponents; |
| 82 | } |
| 83 | // If the component to add is not part of a disabled entity |
| 84 | else { |
| 85 | |
| 86 | // If there already are disabled components |
| 87 | if (mDisabledStartIndex != mNbComponents) { |
| 88 | |
| 89 | // Move the first disabled component to the end of the array |
| 90 | moveComponentToIndex(mDisabledStartIndex, mNbComponents); |
| 91 | } |
| 92 | |
| 93 | index = mDisabledStartIndex; |
| 94 | |
| 95 | mDisabledStartIndex++; |
| 96 | } |
| 97 | |
| 98 | return index; |
| 99 | } |
| 100 | |
| 101 | // Destroy a component at a given index |
| 102 | void Components::destroyComponent(uint32 index) { |
nothing calls this directly
no outgoing calls
no test coverage detected