Merge pull request #1424 from aws-lumberyard-dev/SPEC7185_RenamingIsNetEntityRoleMethods

Updating IsNetEntityRole Helper Methods for Clarity
main
Gene Walters 5 years ago committed by GitHub
commit 530573abf3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -14679,6 +14679,25 @@ An Entity can be selected by using the pick button, or by dragging an Entity fro
<translation></translation> <translation></translation>
</message> </message>
</context> </context>
<context>
<name>Method: NetBindComponent</name>
<message id="NETBINDCOMPONENT_ISNETENTITYROLEAUTHORITY_TOOLTIP">
<source>NETBINDCOMPONENT_ISNETENTITYROLEAUTHORITY_TOOLTIP</source>
<translation>Returns true if this network entity is an authoritative proxy on a server (full authority); otherwise false.</translation>
</message>
<message id="NETBINDCOMPONENT_ISNETENTITYROLEAUTONOMOUS_TOOLTIP">
<source>NETBINDCOMPONENT_ISNETENTITYROLEAUTONOMOUS_TOOLTIP</source>
<translation>Returns true if this network entity is an autonomous proxy on a client (can execute local prediction) or if this network entity is an authoritative proxy on a server but has autonomous privileges (ie: a host who is also a player); otherwise false.</translation>
</message>
<message id="NETBINDCOMPONENT_ISNETENTITYROLECLIENT_TOOLTIP">
<source>NETBINDCOMPONENT_ISNETENTITYROLECLIENT_TOOLTIP</source>
<translation>Returns true if this network entity is a simulated proxy on a client; otherwise false.</translation>
</message>
<message id="NETBINDCOMPONENT_ISNETENTITYROLESERVER_TOOLTIP">
<source>NETBINDCOMPONENT_ISNETENTITYROLESERVER_TOOLTIP</source>
<translation>Returns true if this network entity is a simulated proxy on a server (ie: a different server may own this entity, but the entity has been replicated to this server; otherwise false.</translation>
</message>
</context>
<context> <context>
<name>Method: Math</name> <name>Method: Math</name>
<message id="MATH_NAME"> <message id="MATH_NAME">

@ -63,10 +63,10 @@ namespace Multiplayer
//! @} //! @}
NetEntityId GetNetEntityId() const; NetEntityId GetNetEntityId() const;
bool IsAuthority() const; bool IsNetEntityRoleAuthority() const;
bool IsAutonomous() const; bool IsNetEntityRoleAutonomous() const;
bool IsServer() const; bool IsNetEntityRoleServer() const;
bool IsClient() const; bool IsNetEntityRoleClient() const;
ConstNetworkEntityHandle GetEntityHandle() const; ConstNetworkEntityHandle GetEntityHandle() const;
NetworkEntityHandle GetEntityHandle(); NetworkEntityHandle GetEntityHandle();
void MarkDirty(); void MarkDirty();

@ -64,10 +64,23 @@ namespace Multiplayer
//! @} //! @}
NetEntityRole GetNetEntityRole() const; NetEntityRole GetNetEntityRole() const;
bool IsAuthority() const;
bool IsAutonomous() const; //! IsNetEntityRoleAuthority
bool IsServer() const; //! @return true if this network entity is an authoritative proxy on a server (full authority); otherwise false.
bool IsClient() const; bool IsNetEntityRoleAuthority() const;
//! IsNetEntityRoleAutonomous
//! @return true if this network entity is an autonomous proxy on a client (can execute local prediction) or if this network entity is an authoritative proxy on a server but has autonomous privileges (ie: a host who is also a player); otherwise false.
bool IsNetEntityRoleAutonomous() const;
//! IsNetEntityRoleServer
//! @return true if this network entity is a simulated proxy on a server (ie: a different server may have authority for this entity, but the entity has been replicated on this server; otherwise false.
bool IsNetEntityRoleServer() const;
//! IsNetEntityRoleClient
//! @return true if this network entity is a simulated proxy on a client; otherwise false.
bool IsNetEntityRoleClient() const;
bool HasController() const; bool HasController() const;
NetEntityId GetNetEntityId() const; NetEntityId GetNetEntityId() const;
const PrefabEntityId& GetPrefabEntityId() const; const PrefabEntityId& GetPrefabEntityId() const;

@ -46,24 +46,24 @@ namespace Multiplayer
return m_netBindComponent ? m_netBindComponent->GetNetEntityId() : InvalidNetEntityId; return m_netBindComponent ? m_netBindComponent->GetNetEntityId() : InvalidNetEntityId;
} }
bool MultiplayerComponent::IsAuthority() const bool MultiplayerComponent::IsNetEntityRoleAuthority() const
{ {
return m_netBindComponent ? m_netBindComponent->IsAuthority() : false; return m_netBindComponent ? m_netBindComponent->IsNetEntityRoleAuthority() : false;
} }
bool MultiplayerComponent::IsAutonomous() const bool MultiplayerComponent::IsNetEntityRoleAutonomous() const
{ {
return m_netBindComponent ? m_netBindComponent->IsAutonomous() : false; return m_netBindComponent ? m_netBindComponent->IsNetEntityRoleAutonomous() : false;
} }
bool MultiplayerComponent::IsServer() const bool MultiplayerComponent::IsNetEntityRoleServer() const
{ {
return m_netBindComponent ? m_netBindComponent->IsServer() : false; return m_netBindComponent ? m_netBindComponent->IsNetEntityRoleServer() : false;
} }
bool MultiplayerComponent::IsClient() const bool MultiplayerComponent::IsNetEntityRoleClient() const
{ {
return m_netBindComponent ? m_netBindComponent->IsClient() : false; return m_netBindComponent ? m_netBindComponent->IsNetEntityRoleClient() : false;
} }
ConstNetworkEntityHandle MultiplayerComponent::GetEntityHandle() const ConstNetworkEntityHandle MultiplayerComponent::GetEntityHandle() const

@ -29,12 +29,12 @@ namespace Multiplayer
bool MultiplayerController::IsAuthority() const bool MultiplayerController::IsAuthority() const
{ {
return GetNetBindComponent() ? GetNetBindComponent()->IsAuthority() : false; return GetNetBindComponent() ? GetNetBindComponent()->IsNetEntityRoleAuthority() : false;
} }
bool MultiplayerController::IsAutonomous() const bool MultiplayerController::IsAutonomous() const
{ {
return GetNetBindComponent() ? GetNetBindComponent()->IsAutonomous() : false; return GetNetBindComponent() ? GetNetBindComponent()->IsNetEntityRoleAutonomous() : false;
} }
AZ::Entity* MultiplayerController::GetEntity() const AZ::Entity* MultiplayerController::GetEntity() const

@ -54,69 +54,72 @@ namespace Multiplayer
->Attribute(AZ::Script::Attributes::Module, "multiplayer") ->Attribute(AZ::Script::Attributes::Module, "multiplayer")
->Attribute(AZ::Script::Attributes::Category, "Multiplayer") ->Attribute(AZ::Script::Attributes::Category, "Multiplayer")
->Method("IsAuthority", [](AZ::EntityId id) -> bool { ->Method("IsNetEntityRoleAuthority", [](AZ::EntityId id) -> bool {
AZ::Entity* entity = AZ::Interface<AZ::ComponentApplicationRequests>::Get()->FindEntity(id); AZ::Entity* entity = AZ::Interface<AZ::ComponentApplicationRequests>::Get()->FindEntity(id);
if (!entity) if (!entity)
{ {
AZ_Warning( "NetBindComponent", false, "NetBindComponent IsAuthority failed. The entity with id %s doesn't exist, please provide a valid entity id.", id.ToString().c_str()) AZ_Warning( "NetBindComponent", false, "NetBindComponent IsNetEntityRoleAuthority failed. The entity with id %s doesn't exist, please provide a valid entity id.", id.ToString().c_str())
return false; return false;
} }
NetBindComponent* netBindComponent = entity-> FindComponent<NetBindComponent>(); NetBindComponent* netBindComponent = entity-> FindComponent<NetBindComponent>();
if (!netBindComponent) if (!netBindComponent)
{ {
AZ_Warning( "NetBindComponent", false, "NetBindComponent IsAuthority failed. Entity '%s' (id: %s) is missing a NetBindComponent, make sure this entity contains a component which derives from NetBindComponent.", entity->GetName().c_str(), id.ToString().c_str()) AZ_Warning( "NetBindComponent", false, "NetBindComponent IsNetEntityRoleAuthority failed. Entity '%s' (id: %s) is missing a NetBindComponent, make sure this entity contains a component which derives from NetBindComponent.", entity->GetName().c_str(), id.ToString().c_str())
return false; return false;
} }
return netBindComponent->IsAuthority(); return netBindComponent->IsNetEntityRoleAuthority();
}) })
->Method("IsAutonomous", [](AZ::EntityId id) -> bool {
->Method("IsNetEntityRoleAutonomous", [](AZ::EntityId id) -> bool {
AZ::Entity* entity = AZ::Interface<AZ::ComponentApplicationRequests>::Get()->FindEntity(id); AZ::Entity* entity = AZ::Interface<AZ::ComponentApplicationRequests>::Get()->FindEntity(id);
if (!entity) if (!entity)
{ {
AZ_Warning( "NetBindComponent", false, "NetBindComponent IsAutonomous failed. The entity with id %s doesn't exist, please provide a valid entity id.", id.ToString().c_str()) AZ_Warning( "NetBindComponent", false, "NetBindComponent IsNetEntityRoleAutonomous failed. The entity with id %s doesn't exist, please provide a valid entity id.", id.ToString().c_str())
return false; return false;
} }
NetBindComponent* netBindComponent = entity->FindComponent<NetBindComponent>(); NetBindComponent* netBindComponent = entity->FindComponent<NetBindComponent>();
if (!netBindComponent) if (!netBindComponent)
{ {
AZ_Warning("NetBindComponent", false, "NetBindComponent IsAutonomous failed. Entity '%s' (id: %s) is missing a NetBindComponent, make sure this entity contains a component which derives from NetBindComponent.", entity->GetName().c_str(), id.ToString().c_str()) AZ_Warning("NetBindComponent", false, "NetBindComponent IsNetEntityRoleAutonomous failed. Entity '%s' (id: %s) is missing a NetBindComponent, make sure this entity contains a component which derives from NetBindComponent.", entity->GetName().c_str(), id.ToString().c_str())
return false; return false;
} }
return netBindComponent->IsAutonomous(); return netBindComponent->IsNetEntityRoleAutonomous();
}) })
->Method("IsClient", [](AZ::EntityId id) -> bool {
->Method("IsNetEntityRoleClient", [](AZ::EntityId id) -> bool {
AZ::Entity* entity = AZ::Interface<AZ::ComponentApplicationRequests>::Get()->FindEntity(id); AZ::Entity* entity = AZ::Interface<AZ::ComponentApplicationRequests>::Get()->FindEntity(id);
if (!entity) if (!entity)
{ {
AZ_Warning( "NetBindComponent", false, "NetBindComponent IsClient failed. The entity with id %s doesn't exist, please provide a valid entity id.", id.ToString().c_str()) AZ_Warning( "NetBindComponent", false, "NetBindComponent IsNetEntityRoleClient failed. The entity with id %s doesn't exist, please provide a valid entity id.", id.ToString().c_str())
return false; return false;
} }
NetBindComponent* netBindComponent = entity->FindComponent<NetBindComponent>(); NetBindComponent* netBindComponent = entity->FindComponent<NetBindComponent>();
if (!netBindComponent) if (!netBindComponent)
{ {
AZ_Warning("NetBindComponent", false, "NetBindComponent IsClient failed. Entity '%s' (id: %s) is missing a NetBindComponent, make sure this entity contains a component which derives from NetBindComponent.", entity->GetName().c_str(), id.ToString().c_str()) AZ_Warning("NetBindComponent", false, "NetBindComponent IsNetEntityRoleClient failed. Entity '%s' (id: %s) is missing a NetBindComponent, make sure this entity contains a component which derives from NetBindComponent.", entity->GetName().c_str(), id.ToString().c_str())
return false; return false;
} }
return netBindComponent->IsClient(); return netBindComponent->IsNetEntityRoleClient();
}) })
->Method("IsServer", [](AZ::EntityId id) -> bool {
->Method("IsNetEntityRoleServer", [](AZ::EntityId id) -> bool {
AZ::Entity* entity = AZ::Interface<AZ::ComponentApplicationRequests>::Get()->FindEntity(id); AZ::Entity* entity = AZ::Interface<AZ::ComponentApplicationRequests>::Get()->FindEntity(id);
if (!entity) if (!entity)
{ {
AZ_Warning( "NetBindComponent", false, "NetBindComponent IsServer failed. The entity with id %s doesn't exist, please provide a valid entity id.", id.ToString().c_str()) AZ_Warning( "NetBindComponent", false, "NetBindComponent IsNetEntityRoleServer failed. The entity with id %s doesn't exist, please provide a valid entity id.", id.ToString().c_str())
return false; return false;
} }
NetBindComponent* netBindComponent = entity->FindComponent<NetBindComponent>(); NetBindComponent* netBindComponent = entity->FindComponent<NetBindComponent>();
if (!netBindComponent) if (!netBindComponent)
{ {
AZ_Warning("NetBindComponent", false, "NetBindComponent IsServer failed. Entity '%s' (id: %s) is missing a NetBindComponent, make sure this entity contains a component which derives from NetBindComponent.", entity->GetName().c_str(), id.ToString().c_str()) AZ_Warning("NetBindComponent", false, "NetBindComponent IsNetEntityRoleServer failed. Entity '%s' (id: %s) is missing a NetBindComponent, make sure this entity contains a component which derives from NetBindComponent.", entity->GetName().c_str(), id.ToString().c_str())
return false; return false;
} }
return netBindComponent->IsServer(); return netBindComponent->IsNetEntityRoleServer();
}) })
; ;
} }
@ -179,23 +182,23 @@ namespace Multiplayer
return m_netEntityRole; return m_netEntityRole;
} }
bool NetBindComponent::IsAuthority() const bool NetBindComponent::IsNetEntityRoleAuthority() const
{ {
return (m_netEntityRole == NetEntityRole::Authority); return (m_netEntityRole == NetEntityRole::Authority);
} }
bool NetBindComponent::IsAutonomous() const bool NetBindComponent::IsNetEntityRoleAutonomous() const
{ {
return (m_netEntityRole == NetEntityRole::Autonomous) return (m_netEntityRole == NetEntityRole::Autonomous)
|| (m_netEntityRole == NetEntityRole::Authority) && m_allowAutonomy; || (m_netEntityRole == NetEntityRole::Authority) && m_allowAutonomy;
} }
bool NetBindComponent::IsServer() const bool NetBindComponent::IsNetEntityRoleServer() const
{ {
return (m_netEntityRole == NetEntityRole::Server); return (m_netEntityRole == NetEntityRole::Server);
} }
bool NetBindComponent::IsClient() const bool NetBindComponent::IsNetEntityRoleClient() const
{ {
return (m_netEntityRole == NetEntityRole::Client); return (m_netEntityRole == NetEntityRole::Client);
} }

@ -96,7 +96,7 @@ namespace Multiplayer
{ {
AZ_Assert(entityHandle.GetNetBindComponent(), "No NetBindComponent found on networked entity"); AZ_Assert(entityHandle.GetNetBindComponent(), "No NetBindComponent found on networked entity");
[[maybe_unused]] const bool isClientOnlyEntity = false;// (ServerIdFromEntityId(it->first) == InvalidHostId); [[maybe_unused]] const bool isClientOnlyEntity = false;// (ServerIdFromEntityId(it->first) == InvalidHostId);
AZ_Assert(entityHandle.GetNetBindComponent()->IsAuthority() || isClientOnlyEntity, "Trying to delete a proxy entity, this will lead to issues deserializing entity updates"); AZ_Assert(entityHandle.GetNetBindComponent()->IsNetEntityRoleAuthority() || isClientOnlyEntity, "Trying to delete a proxy entity, this will lead to issues deserializing entity updates");
} }
m_removeList.push_back(entityHandle.GetNetEntityId()); m_removeList.push_back(entityHandle.GetNetEntityId());
m_removeEntitiesEvent.Enqueue(AZ::TimeMs{ 0 }); m_removeEntitiesEvent.Enqueue(AZ::TimeMs{ 0 });

Loading…
Cancel
Save