Refactored to store entities by entity ids

Signed-off-by: AMZN-Olex <5432499+AMZN-Olex@users.noreply.github.com>
This commit is contained in:
AMZN-Olex
2021-07-26 23:45:09 -04:00
parent a2f3066fa3
commit 59f65f2656
4 changed files with 23 additions and 32 deletions
@@ -119,15 +119,15 @@ namespace MultiplayerDiagnostics
if (ImGui::CollapsingHeader("Receiving Entities"))
{
for (auto& entityPair : m_receivingEntityReports)
for (AZStd::pair<AZ::EntityId, EntityReporter>& entityPair : m_receivingEntityReports)
{
if (!filter.PassFilter(entityPair.first.c_str()))
if (!filter.PassFilter(entityPair.second.GetEntityName()))
{
continue;
}
ImGui::Separator();
if (ReplicatedStateTreeNode(entityPair.first, entityPair.second, k_ImGuiDusk))
if (ReplicatedStateTreeNode(entityPair.second.GetEntityName(), entityPair.second, k_ImGuiDusk))
{
DisplayReplicatedStateReport(entityPair.second.GetComponentReports(), m_replicatedStateKbpsWarn, m_replicatedStateMaxSizeWarn);
ImGui::TreePop();
@@ -137,15 +137,16 @@ namespace MultiplayerDiagnostics
if (ImGui::CollapsingHeader("Sending Entities"))
{
for (auto& entityPair : m_sendingEntityReports)
for (AZStd::pair<AZ::EntityId, EntityReporter>& entityPair : m_sendingEntityReports)
{
if (!filter.PassFilter(entityPair.first.c_str()))
const char* name = entityPair.second.GetEntityName();
if (!filter.PassFilter(name))
{
continue;
}
ImGui::Separator();
if (ReplicatedStateTreeNode(entityPair.first, entityPair.second, k_ImGuiDusk))
if (ReplicatedStateTreeNode(name, entityPair.second, k_ImGuiDusk))
{
DisplayReplicatedStateReport(entityPair.second.GetComponentReports(), m_replicatedStateKbpsWarn, m_replicatedStateMaxSizeWarn);
ImGui::TreePop();
@@ -162,9 +163,11 @@ namespace MultiplayerDiagnostics
{
case AzNetworking::SerializerMode::ReadFromObject:
m_currentSendingEntityReport.Reset();
m_currentSendingEntityReport.SetEntityName(entityName);
break;
case AzNetworking::SerializerMode::WriteToObject:
m_currentReceivingEntityReport.Reset();
m_currentReceivingEntityReport.SetEntityName(entityName);
break;
}
}
@@ -183,15 +186,15 @@ namespace MultiplayerDiagnostics
}
void MultiplayerDebugPerEntityReporter::RecordEntitySerializeStop(AzNetworking::SerializerMode mode,
[[maybe_unused]] AZ::EntityId entityId, const char* entityName)
[[maybe_unused]] AZ::EntityId entityId, [[maybe_unused]] const char* entityName)
{
switch (mode)
{
case AzNetworking::SerializerMode::ReadFromObject:
m_sendingEntityReports[entityName].Combine(m_currentSendingEntityReport);
m_sendingEntityReports[entityId].Combine(m_currentSendingEntityReport);
break;
case AzNetworking::SerializerMode::WriteToObject:
m_receivingEntityReports[entityName].Combine(m_currentReceivingEntityReport);
m_receivingEntityReports[entityId].Combine(m_currentReceivingEntityReport);
break;
}
}