| 21 | } |
| 22 | |
| 23 | Guid Prefab::GetRootObjectId() const |
| 24 | { |
| 25 | ASSERT(IsLoaded()); |
| 26 | ScopeLock lock(Locker); |
| 27 | |
| 28 | // Root is always the first but handle case when prefab root was reordered in the base prefab while the nested prefab has still the old state |
| 29 | // TODO: resave and force sync prefabs during game cooking so this step could be skipped in game |
| 30 | int32 objectIndex = 0; |
| 31 | if (NestedPrefabs.HasItems()) |
| 32 | { |
| 33 | const auto& data = *Data; |
| 34 | const Guid basePrefabId = JsonTools::GetGuid(data[objectIndex], "PrefabID"); |
| 35 | if (const auto basePrefab = Content::Load<Prefab>(basePrefabId)) |
| 36 | { |
| 37 | const Guid basePrefabRootId = basePrefab->GetRootObjectId(); |
| 38 | for (int32 i = 0; i < ObjectsCount; i++) |
| 39 | { |
| 40 | const Guid prefabObjectId = JsonTools::GetGuid(data[i], "PrefabObjectID"); |
| 41 | if (prefabObjectId == basePrefabRootId) |
| 42 | { |
| 43 | objectIndex = i; |
| 44 | break; |
| 45 | } |
| 46 | } |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | return ObjectsIds[objectIndex]; |
| 51 | } |
| 52 | |
| 53 | Actor* Prefab::GetDefaultInstance() |
| 54 | { |
no test coverage detected