| 225 | }; |
| 226 | |
| 227 | void PrefabInstanceData::CollectPrefabInstances(PrefabInstancesData& prefabInstancesData, const Guid& prefabId, Actor* defaultInstance, Actor* targetActor) |
| 228 | { |
| 229 | ScopeLock lock(PrefabManager::PrefabsReferencesLocker); |
| 230 | if (auto instancesPtr = PrefabManager::PrefabsReferences.TryGet(prefabId)) |
| 231 | { |
| 232 | auto& instances = *instancesPtr; |
| 233 | int32 usedCount = 0; |
| 234 | for (int32 instanceIndex = 0; instanceIndex < instances.Count(); instanceIndex++) |
| 235 | { |
| 236 | const auto instance = instances[instanceIndex]; |
| 237 | if (EnumHasAnyFlags(instance->Flags, ObjectFlags::WasMarkedToDelete)) |
| 238 | continue; |
| 239 | if (instance != defaultInstance && targetActor != instance && !targetActor->HasActorInHierarchy(instance)) |
| 240 | usedCount++; |
| 241 | } |
| 242 | prefabInstancesData.Resize(usedCount); |
| 243 | int32 dataIndex = 0; |
| 244 | for (int32 instanceIndex = 0; instanceIndex < instances.Count(); instanceIndex++) |
| 245 | { |
| 246 | // Skip default instance because it will be recreated, skip input actor because it needs just to be linked |
| 247 | Actor* instance = instances[instanceIndex]; |
| 248 | if (EnumHasAnyFlags(instance->Flags, ObjectFlags::WasMarkedToDelete)) |
| 249 | continue; |
| 250 | if (instance != defaultInstance && targetActor != instance && !targetActor->HasActorInHierarchy(instance)) |
| 251 | { |
| 252 | auto& data = prefabInstancesData[dataIndex++]; |
| 253 | data.TargetActor = instance; |
| 254 | data.OrderInParent = instance->GetOrderInParent(); |
| 255 | } |
| 256 | } |
| 257 | } |
| 258 | } |
| 259 | |
| 260 | void PrefabInstanceData::SerializePrefabInstances(PrefabInstancesData& prefabInstancesData, rapidjson_flax::StringBuffer& tmpBuffer, const Prefab* prefab) |
| 261 | { |
nothing calls this directly
no test coverage detected