Updating NetworkingSpawnableLibrary to only store network spawnables, instead of all spawnables

Signed-off-by: Gene Walters <genewalt@amazon.com>
This commit is contained in:
Gene Walters
2022-01-18 10:27:10 -08:00
parent 44908a80c6
commit 626b16dbae
2 changed files with 7 additions and 4 deletions
@@ -10,7 +10,6 @@
#include <AzCore/Asset/AssetManagerBus.h>
#include <AzCore/Component/ComponentApplicationLifecycle.h>
#include <AzFramework/Spawnable/Spawnable.h>
#include <AzCore/StringFunc/StringFunc.h>
#include <AzCore/Interface/Interface.h>
namespace Multiplayer
@@ -42,7 +41,8 @@ namespace Multiplayer
auto enumerateCallback = [this](const AZ::Data::AssetId id, const AZ::Data::AssetInfo& info)
{
if (info.m_assetType == AZ::AzTypeInfo<AzFramework::Spawnable>::Uuid())
if (info.m_assetType == AZ::AzTypeInfo<AzFramework::Spawnable>::Uuid() &&
info.m_relativePath.ends_with(".network.spawnable"))
{
ProcessSpawnableAsset(info.m_relativePath, id);
}
@@ -23,12 +23,15 @@ namespace Multiplayer
NetworkSpawnableLibrary();
~NetworkSpawnableLibrary();
/// INetworkSpawnableLibrary overrides.
//! INetworkSpawnableLibrary overrides.
//! @{
// Iterates over all assets (on-disk and in-memory) and stores any spawnables that are "network.spawnables"
// This allows us to look up network spawnable assets by name or id for later use
void BuildSpawnablesList() override;
void ProcessSpawnableAsset(const AZStd::string& relativePath, AZ::Data::AssetId id) override;
AZ::Name GetSpawnableNameFromAssetId(AZ::Data::AssetId assetId) override;
AZ::Data::AssetId GetAssetIdByName(AZ::Name name) override;
//! @}
private:
AZStd::unordered_map<AZ::Name, AZ::Data::AssetId> m_spawnables;