Updating IsNetEntityRole helper methods for more clarity. Also added tooltip scripting and comments for code
This commit is contained in:
@@ -14679,6 +14679,25 @@ An Entity can be selected by using the pick button, or by dragging an Entity fro
|
||||
<translation></translation>
|
||||
</message>
|
||||
</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>
|
||||
<name>Method: Math</name>
|
||||
<message id="MATH_NAME">
|
||||
|
||||
@@ -63,10 +63,10 @@ namespace Multiplayer
|
||||
//! @}
|
||||
|
||||
NetEntityId GetNetEntityId() const;
|
||||
bool IsAuthority() const;
|
||||
bool IsAutonomous() const;
|
||||
bool IsServer() const;
|
||||
bool IsClient() const;
|
||||
bool IsNetEntityRoleAuthority() const;
|
||||
bool IsNetEntityRoleAutonomous() const;
|
||||
bool IsNetEntityRoleServer() const;
|
||||
bool IsNetEntityRoleClient() const;
|
||||
ConstNetworkEntityHandle GetEntityHandle() const;
|
||||
NetworkEntityHandle GetEntityHandle();
|
||||
void MarkDirty();
|
||||
|
||||
@@ -64,10 +64,23 @@ namespace Multiplayer
|
||||
//! @}
|
||||
|
||||
NetEntityRole GetNetEntityRole() const;
|
||||
bool IsAuthority() const;
|
||||
bool IsAutonomous() const;
|
||||
bool IsServer() const;
|
||||
bool IsClient() const;
|
||||
|
||||
//! IsNetEntityRoleAuthority
|
||||
//! @return true if this network entity is an authoritative proxy on a server (full authority); otherwise false.
|
||||
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;
|
||||
NetEntityId GetNetEntityId() const;
|
||||
const PrefabEntityId& GetPrefabEntityId() const;
|
||||
|
||||
@@ -46,24 +46,24 @@ namespace Multiplayer
|
||||
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
|
||||
|
||||
@@ -29,12 +29,12 @@ namespace Multiplayer
|
||||
|
||||
bool MultiplayerController::IsAuthority() const
|
||||
{
|
||||
return GetNetBindComponent() ? GetNetBindComponent()->IsAuthority() : false;
|
||||
return GetNetBindComponent() ? GetNetBindComponent()->IsNetEntityRoleAuthority() : false;
|
||||
}
|
||||
|
||||
bool MultiplayerController::IsAutonomous() const
|
||||
{
|
||||
return GetNetBindComponent() ? GetNetBindComponent()->IsAutonomous() : false;
|
||||
return GetNetBindComponent() ? GetNetBindComponent()->IsNetEntityRoleAutonomous() : false;
|
||||
}
|
||||
|
||||
AZ::Entity* MultiplayerController::GetEntity() const
|
||||
|
||||
@@ -54,69 +54,72 @@ namespace Multiplayer
|
||||
->Attribute(AZ::Script::Attributes::Module, "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);
|
||||
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;
|
||||
}
|
||||
|
||||
NetBindComponent* netBindComponent = entity-> FindComponent<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 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);
|
||||
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;
|
||||
}
|
||||
|
||||
NetBindComponent* netBindComponent = entity->FindComponent<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 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);
|
||||
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;
|
||||
}
|
||||
|
||||
NetBindComponent* netBindComponent = entity->FindComponent<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 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);
|
||||
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;
|
||||
}
|
||||
|
||||
NetBindComponent* netBindComponent = entity->FindComponent<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 netBindComponent->IsServer();
|
||||
return netBindComponent->IsNetEntityRoleServer();
|
||||
})
|
||||
;
|
||||
}
|
||||
@@ -179,23 +182,23 @@ namespace Multiplayer
|
||||
return m_netEntityRole;
|
||||
}
|
||||
|
||||
bool NetBindComponent::IsAuthority() const
|
||||
bool NetBindComponent::IsNetEntityRoleAuthority() const
|
||||
{
|
||||
return (m_netEntityRole == NetEntityRole::Authority);
|
||||
}
|
||||
|
||||
bool NetBindComponent::IsAutonomous() const
|
||||
bool NetBindComponent::IsNetEntityRoleAutonomous() const
|
||||
{
|
||||
return (m_netEntityRole == NetEntityRole::Autonomous)
|
||||
|| (m_netEntityRole == NetEntityRole::Authority) && m_allowAutonomy;
|
||||
}
|
||||
|
||||
bool NetBindComponent::IsServer() const
|
||||
bool NetBindComponent::IsNetEntityRoleServer() const
|
||||
{
|
||||
return (m_netEntityRole == NetEntityRole::Server);
|
||||
}
|
||||
|
||||
bool NetBindComponent::IsClient() const
|
||||
bool NetBindComponent::IsNetEntityRoleClient() const
|
||||
{
|
||||
return (m_netEntityRole == NetEntityRole::Client);
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ namespace Multiplayer
|
||||
{
|
||||
AZ_Assert(entityHandle.GetNetBindComponent(), "No NetBindComponent found on networked entity");
|
||||
[[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_removeEntitiesEvent.Enqueue(AZ::TimeMs{ 0 });
|
||||
|
||||
Reference in New Issue
Block a user