Removed OnEntityAdded/OnEntityRemoved from NetworkEntityManager

This commit is contained in:
pereslav
2021-04-20 17:49:17 +01:00
parent 4e75a099b8
commit 2b6b4f5d17
2 changed files with 0 additions and 36 deletions
@@ -34,8 +34,6 @@ namespace Multiplayer
: m_networkEntityAuthorityTracker(*this)
, m_removeEntitiesEvent([this] { RemoveEntities(); }, AZ::Name("NetworkEntityManager remove entities event"))
, m_updateEntityDomainEvent([this] { UpdateEntityDomain(); }, AZ::Name("NetworkEntityManager update entity domain event"))
, m_entityAddedEventHandler([this](AZ::Entity* entity) { OnEntityAdded(entity); })
, m_entityRemovedEventHandler([this](AZ::Entity* entity) { OnEntityRemoved(entity); })
{
AZ::Interface<INetworkEntityManager>::Register(this);
AzFramework::RootSpawnableNotificationBus::Handler::BusConnect();
@@ -52,12 +50,6 @@ namespace Multiplayer
m_hostId = hostId;
m_entityDomain = AZStd::move(entityDomain);
m_updateEntityDomainEvent.Enqueue(net_EntityDomainUpdateMs, true);
if (AZ::Interface<AZ::ComponentApplicationRequests>::Get() != nullptr)
{
// Null guard needed for unit tests
AZ::Interface<AZ::ComponentApplicationRequests>::Get()->RegisterEntityAddedEventHandler(m_entityAddedEventHandler);
AZ::Interface<AZ::ComponentApplicationRequests>::Get()->RegisterEntityRemovedEventHandler(m_entityRemovedEventHandler);
}
}
NetworkEntityTracker* NetworkEntityManager::GetNetworkEntityTracker()
@@ -281,30 +273,6 @@ namespace Multiplayer
}
}
void NetworkEntityManager::OnEntityAdded(AZ::Entity* entity)
{
NetBindComponent* netBindComponent = entity->FindComponent<NetBindComponent>();
if (netBindComponent != nullptr)
{
// @pereslav
// Note that this is a total hack.. we should not be listening to this event on a client
// Entities should instead be spawned by the prefabEntityId inside EntityReplicationManager::HandlePropertyChangeMessage()
const bool isClient = AZ::Interface<IMultiplayer>::Get()->GetAgentType() == MultiplayerAgentType::Client;
const NetEntityRole netEntityRole = isClient ? NetEntityRole::Client: NetEntityRole::Authority;
const NetEntityId netEntityId = m_nextEntityId++;
netBindComponent->PreInit(entity, PrefabEntityId(), netEntityId, netEntityRole);
}
}
void NetworkEntityManager::OnEntityRemoved(AZ::Entity* entity)
{
NetBindComponent* netBindComponent = entity->FindComponent<NetBindComponent>();
if (netBindComponent != nullptr)
{
MarkForRemoval(netBindComponent->GetEntityHandle());
}
}
void NetworkEntityManager::RemoveEntities()
{
//RewindableObjectState::ClearRewoundEntities();
@@ -79,8 +79,6 @@ namespace Multiplayer
//! @}
private:
void OnEntityAdded(AZ::Entity* entity);
void OnEntityRemoved(AZ::Entity* entity);
void RemoveEntities();
NetEntityId NextId();
@@ -100,8 +98,6 @@ namespace Multiplayer
AZ::Event<> m_onEntityNotifyChanges;
ControllersActivatedEvent m_controllersActivatedEvent;
ControllersDeactivatedEvent m_controllersDeactivatedEvent;
AZ::EntityAddedEvent::Handler m_entityAddedEventHandler;
AZ::EntityRemovedEvent::Handler m_entityRemovedEventHandler;
HostId m_hostId = InvalidHostId;
NetEntityId m_nextEntityId = NetEntityId{ 0 };