Fixed IMGUI Entity Outliner to show net entities

Signed-off-by: Sergey Pereslavtsev <pereslav@amazon.com>
This commit is contained in:
Sergey Pereslavtsev
2021-11-12 13:36:14 +00:00
parent 23faf4d36a
commit 435f839666
2 changed files with 18 additions and 2 deletions
@@ -534,7 +534,7 @@ namespace AzFramework
void TransformComponent::SetParentImpl(AZ::EntityId parentId, bool isKeepWorldTM)
{
if (parentId == GetEntityId())
if (GetEntity() && parentId == GetEntityId())
{
AZ_Warning("TransformComponent", false, "An entity can not be set as its own parent.");
return;
@@ -53,7 +53,7 @@ namespace Multiplayer
;
serializeContext->Class<NetworkPrefabProcessor, PrefabProcessor>()
->Version(3)
->Version(4)
->Field("SerializationFormat", &NetworkPrefabProcessor::m_serializationFormat)
;
}
@@ -146,6 +146,8 @@ namespace Multiplayer
networkSpawnableAsset.Create(networkSpawnable->GetId());
networkSpawnableAsset.SetAutoLoadBehavior(AZ::Data::AssetLoadBehavior::PreLoad);
AZStd::unordered_set<AZ::EntityId> prefabNetEntityIds;
for (auto* prefabEntity : prefabNetEntities)
{
Instance* instance = netEntityToInstanceMap[prefabEntity];
@@ -158,6 +160,20 @@ namespace Multiplayer
netEntity->InvalidateDependencies();
netEntity->EvaluateDependencies();
auto* transformComponent = netEntity->FindComponent<AzFramework::TransformComponent>();
if (transformComponent)
{
AZ::EntityId parentId = transformComponent->GetParentId();
if (parentId.IsValid() && !prefabNetEntityIds.contains(parentId))
{
// Clear parent ID for net entities parented to a non-net entity.
// To be addressed by the spawnable aliases system.
transformComponent->SetParent(AZ::EntityId());
}
}
prefabNetEntityIds.insert(netEntity->GetId());
// Insert the entity into the target net spawnable
netSpawnableEntities.emplace_back(netEntity);
}