Add NetworkReplicator::HasObject

This commit is contained in:
Wojtek Figat
2023-05-16 14:58:47 +02:00
parent 953ae3e9bb
commit 70593177c7
2 changed files with 24 additions and 0 deletions

View File

@@ -874,6 +874,23 @@ void NetworkReplicator::DespawnObject(ScriptingObject* obj)
DeleteNetworkObject(obj);
}
bool NetworkReplicator::HasObject(const ScriptingObject* obj)
{
if (obj)
{
ScopeLock lock(ObjectsLock);
const auto it = Objects.Find(obj->GetID());
if (it != Objects.End())
return true;
for (const SpawnItem& item : SpawnQueue)
{
if (item.Object == obj)
return true;
}
}
return false;
}
uint32 NetworkReplicator::GetObjectOwnerClientId(const ScriptingObject* obj)
{
uint32 id = NetworkManager::ServerClientId;

View File

@@ -99,6 +99,13 @@ public:
/// <param name="obj">The object to despawn on other clients.</param>
API_FUNCTION() static void DespawnObject(ScriptingObject* obj);
/// <summary>
/// Checks if the network object is spawned or added to the network replication system.
/// </summary>
/// <param name="obj">The network object.</param>
/// <returns>True if object exists in networking, otherwise false.</returns>
API_FUNCTION() static bool HasObject(const ScriptingObject* obj);
/// <summary>
/// Gets the Client Id of the network object owner.
/// </summary>