Updating IsNetEntityRole helper methods for more clarity. Also added tooltip scripting and comments for code
This commit is contained in:
@@ -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