| 422 | } |
| 423 | |
| 424 | bool ImmediateWorldCache::PrepareAddComponent(EntityHandle entity, ComponentTypeIndex type, void*& component) |
| 425 | { |
| 426 | auto typeInfo = EntityWorld->ComponentRegistry_.Get(type); |
| 427 | if (EntityWorld->GetRawComponent(entity, type, typeInfo->InlineSize, false)) { |
| 428 | return false; |
| 429 | } |
| 430 | |
| 431 | auto changes = GetOrAddComponentChanges(type); |
| 432 | auto change = changes->Components.find(entity); |
| 433 | |
| 434 | if (!change) { |
| 435 | ComponentFrameStorageIndex index; |
| 436 | component = changes->FrameStorage.Allocate(index); |
| 437 | change = changes->Components.add(entity, ComponentChange{ |
| 438 | .Ptr = component, |
| 439 | .StorageIndex = index |
| 440 | }); |
| 441 | return true; |
| 442 | } else { |
| 443 | WARN("A change for component [%d] already exists on entity [%016llx]!", type, entity.Handle); |
| 444 | return false; |
| 445 | } |
| 446 | } |
| 447 | |
| 448 | void ImmediateWorldCache::FinalizeAddComponent(EntityHandle entity, ComponentTypeIndex type, void* component) |
| 449 | { |
no test coverage detected