| 183 | } |
| 184 | |
| 185 | void sugoi_storage_t::instantiate_prefab(const sugoi_entity_t* src, uint32_t size, uint32_t count, sugoi_view_callback_t callback, void* u) |
| 186 | { |
| 187 | using namespace sugoi; |
| 188 | skr::stl_vector<sugoi_entity_t> ents; |
| 189 | ents.resize(count * size); |
| 190 | entities.new_entities(ents.data(), (EIndex)ents.size()); |
| 191 | struct mapper_t { |
| 192 | sugoi_entity_t* base; |
| 193 | sugoi_entity_t* curr; |
| 194 | uint32_t size; |
| 195 | void move() { curr += size; } |
| 196 | void reset() { curr = base; } |
| 197 | void map(sugoi_entity_t& ent) |
| 198 | { |
| 199 | if (e_id(ent) > size || !e_transient(ent)) |
| 200 | return; |
| 201 | ent = curr[e_id(ent)]; |
| 202 | } |
| 203 | } m; |
| 204 | m.size = size; |
| 205 | skr::stl_vector<sugoi_entity_t> localEnts; |
| 206 | localEnts.resize(count); |
| 207 | forloop (i, 0, size) |
| 208 | { |
| 209 | forloop (j, 0, count) |
| 210 | localEnts[j] = ents[j * size + i]; |
| 211 | auto view = entity_view(src[i]); |
| 212 | auto group = view.chunk->group->cloned; |
| 213 | auto localCount = 0; |
| 214 | while (localCount != count) |
| 215 | { |
| 216 | sugoi_chunk_view_t v = allocate_view(group, count - localCount); |
| 217 | entities.fill_entities(v, localEnts.data() + localCount); |
| 218 | duplicate_view(v, view.chunk, view.start); |
| 219 | m.base = m.curr = ents.data() + localCount * size; |
| 220 | localCount += v.count; |
| 221 | iterator_ref_view(v, m); |
| 222 | if (callback) |
| 223 | callback(u, &v); |
| 224 | } |
| 225 | } |
| 226 | } |
| 227 | |
| 228 | void sugoi_storage_t::instantiate(const sugoi_entity_t src, uint32_t count, sugoi_view_callback_t callback, void* u) |
| 229 | { |
nothing calls this directly
no test coverage detected