Add NetworkTransform component

This commit is contained in:
Wojciech Figat
2022-10-31 16:31:06 +01:00
parent 5e81d83648
commit 01a7ae8bd4
7 changed files with 272 additions and 5 deletions

View File

@@ -367,6 +367,20 @@ void NetworkReplicator::AddObject(ScriptingObject* obj, ScriptingObject* parent)
Objects.Add(MoveTemp(item));
}
void NetworkReplicator::RemoveObject(ScriptingObject* obj)
{
if (!obj || NetworkManager::State == NetworkConnectionState::Offline)
return;
ScopeLock lock(ObjectsLock);
const auto it = Objects.Find(obj->GetID());
if (it != Objects.End())
return;
// Remove object from the list
NETWORK_REPLICATOR_LOG(Info, "[NetworkReplicator] Remove object {}, owned by {}", obj->GetID().ToString(), it->Item.ParentId.ToString());
Objects.Remove(it);
}
void NetworkReplicator::SpawnObject(ScriptingObject* obj)
{
if (!obj || NetworkManager::State == NetworkConnectionState::Offline)
@@ -507,10 +521,9 @@ void NetworkInternal::NetworkReplicatorClear()
{
// Cleanup any spawned objects
DeleteNetworkObject(obj);
Objects.Remove(it);
}
}
Objects.Clear();
Objects.SetCapacity(0);
SpawnQueue.Clear();
DespawnQueue.Clear();
IdsRemappingTable.Clear();