| 33 | } |
| 34 | |
| 35 | void entity_registry_t::new_entities(sugoi_entity_t* dst, EIndex count) |
| 36 | { |
| 37 | SMutexLock lock(mutex.mMutex); |
| 38 | EIndex i = 0; |
| 39 | // recycle entities |
| 40 | |
| 41 | auto fn = (EIndex)freeEntries.size(); |
| 42 | auto rn = std::min((EIndex)freeEntries.size(), count); |
| 43 | forloop (j, 0, rn) |
| 44 | { |
| 45 | auto id = freeEntries[fn - rn + j]; |
| 46 | dst[i] = e_version(id, entries[id].version); |
| 47 | i++; |
| 48 | } |
| 49 | freeEntries.resize_default(fn - rn); |
| 50 | if (i == count) |
| 51 | return; |
| 52 | // new entities |
| 53 | EIndex newId = static_cast<EIndex>(entries.size()); |
| 54 | entries.resize_default(entries.size() + count - i); |
| 55 | while (i < count) |
| 56 | { |
| 57 | dst[i] = e_version(newId, entries[newId].version); |
| 58 | i++; |
| 59 | newId++; |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | void entity_registry_t::free_entities(const sugoi_entity_t* dst, EIndex count) |
| 64 | { |
no test coverage detected