Add NetworkReplicator::HasObject
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user