From 5ad23e1822528f49d33e8cf0eb92e77800c45a20 Mon Sep 17 00:00:00 2001 From: SirLynix Date: Thu, 12 Sep 2024 22:33:11 +0200 Subject: [PATCH] wip --- .../Components/ClassInstanceComponent.hpp | 37 +++++++++++++++---- .../Components/ClassInstanceComponent.inl | 29 ++++++++++++--- include/CommonLib/EntityClass.hpp | 2 - include/CommonLib/Protocol/PacketList.hpp | 1 + include/CommonLib/Protocol/Packets.hpp | 9 +++++ .../ServerLib/SessionVisibilityHandler.hpp | 2 + .../ServerLib/SessionVisibilityHandler.inl | 6 +++ .../Systems/NetworkedEntitiesSystem.hpp | 10 ++++- src/ClientLib/ClientSessionHandler.cpp | 5 +-- .../Components/ClassInstanceComponent.cpp | 17 ++++++++- src/CommonLib/EntityClass.cpp | 13 +------ src/CommonLib/Protocol/Packets.cpp | 8 ++++ .../Scripting/EntityScriptingLibrary.cpp | 12 +++--- src/ServerLib/ServerPlanetEnvironment.cpp | 2 +- src/ServerLib/ServerShipEnvironment.cpp | 2 +- src/ServerLib/SessionVisibilityHandler.cpp | 23 +++++++++++- .../Systems/NetworkedEntitiesSystem.cpp | 33 +++++++++-------- 17 files changed, 152 insertions(+), 59 deletions(-) diff --git a/include/CommonLib/Components/ClassInstanceComponent.hpp b/include/CommonLib/Components/ClassInstanceComponent.hpp index 27ceefeb..07de72d2 100644 --- a/include/CommonLib/Components/ClassInstanceComponent.hpp +++ b/include/CommonLib/Components/ClassInstanceComponent.hpp @@ -8,6 +8,8 @@ #define TSOM_COMMONLIB_COMPONENTS_CLASSINSTANCECOMPONENT_HPP #include +#include +#include #include #include @@ -15,18 +17,37 @@ namespace tsom { class EntityClass; - struct TSOM_COMMONLIB_API ClassInstanceComponent + class TSOM_COMMONLIB_API ClassInstanceComponent { - std::vector properties; - const EntityClass* entityClass; + public: + using PropertyUpdateSignal = Nz::Signal; - template auto GetProperty(std::size_t propertyIndex) const; - template auto GetProperty(std::string_view propertyName) const; + ClassInstanceComponent(const EntityClass* entityClass); + ClassInstanceComponent(const ClassInstanceComponent&) = delete; + ClassInstanceComponent(ClassInstanceComponent&&) noexcept = default; + ~ClassInstanceComponent() = default; - Nz::UInt32 GetPropertyIndex(std::string_view propertyName) const; + Nz::UInt32 FindPropertyIndex(std::string_view propertyName) const; - template void UpdateProperty(std::size_t propertyIndex, T&& value); - template void UpdateProperty(std::string_view propertyName, T&& value); + inline const EntityClass* GetClass() const; + inline const EntityProperty& GetProperty(Nz::UInt32 propertyIndex) const; + template auto GetProperty(Nz::UInt32 propertyIndex) const; + template auto GetProperty(std::string_view propertyName) const; + + Nz::UInt32 GetPropertyIndex(std::string_view propertyName) const; + + inline void UpdateProperty(Nz::UInt32 propertyIndex, EntityProperty&& value); + template void UpdateProperty(Nz::UInt32 propertyIndex, T&& value); + template void UpdateProperty(std::string_view propertyName, T&& value); + + ClassInstanceComponent& operator=(const ClassInstanceComponent&) = delete; + ClassInstanceComponent& operator=(ClassInstanceComponent&&) noexcept = default; + + NazaraSignal(OnPropertyUpdate, ClassInstanceComponent* /*classInstance*/, Nz::UInt32 /*propertyIndex*/, const EntityProperty& /*newValue*/); + + private: + std::vector m_properties; + Nz::MovablePtr m_entityClass; }; } diff --git a/include/CommonLib/Components/ClassInstanceComponent.inl b/include/CommonLib/Components/ClassInstanceComponent.inl index c065c2d2..a73b70cb 100644 --- a/include/CommonLib/Components/ClassInstanceComponent.inl +++ b/include/CommonLib/Components/ClassInstanceComponent.inl @@ -6,11 +6,22 @@ namespace tsom { + inline const EntityClass* ClassInstanceComponent::GetClass() const + { + return m_entityClass; + } + + inline const EntityProperty& ClassInstanceComponent::GetProperty(Nz::UInt32 propertyIndex) const + { + assert(propertyIndex < m_properties.size()); + return m_properties[propertyIndex]; + } + template - auto ClassInstanceComponent::GetProperty(std::size_t propertyIndex) const + auto ClassInstanceComponent::GetProperty(Nz::UInt32 propertyIndex) const { - assert(propertyIndex < properties.size()); - return std::get>(properties[propertyIndex]); + assert(propertyIndex < m_properties.size()); + return std::get>(m_properties[propertyIndex].value); } template @@ -19,11 +30,17 @@ namespace tsom return GetProperty(GetPropertyIndex(propertyName)); } + inline void ClassInstanceComponent::UpdateProperty(Nz::UInt32 propertyIndex, EntityProperty&& value) + { + assert(propertyIndex < m_properties.size()); + OnPropertyUpdate(this, propertyIndex, value); + m_properties[propertyIndex] = std::move(value); + } + template - void ClassInstanceComponent::UpdateProperty(std::size_t propertyIndex, T&& value) + void ClassInstanceComponent::UpdateProperty(Nz::UInt32 propertyIndex, T&& value) { - assert(propertyIndex < properties.size()); - std::get>(properties[propertyIndex]) = std::forward(value); + return UpdateProperty(propertyIndex, EntityPropertySingleValue(std::forward(value))); } template diff --git a/include/CommonLib/EntityClass.hpp b/include/CommonLib/EntityClass.hpp index c1297f78..401090b7 100644 --- a/include/CommonLib/EntityClass.hpp +++ b/include/CommonLib/EntityClass.hpp @@ -38,8 +38,6 @@ namespace tsom inline const Property& GetProperty(Nz::UInt32 propertyIndex) const; inline Nz::UInt32 GetPropertyCount() const; - ClassInstanceComponent& SetupEntity(entt::handle entity) const; - EntityClass& operator=(const EntityClass&) = delete; EntityClass& operator=(EntityClass&&) noexcept = default; diff --git a/include/CommonLib/Protocol/PacketList.hpp b/include/CommonLib/Protocol/PacketList.hpp index 1c29edb0..52c3670b 100644 --- a/include/CommonLib/Protocol/PacketList.hpp +++ b/include/CommonLib/Protocol/PacketList.hpp @@ -28,6 +28,7 @@ TSOM_NETWORK_PACKET(EntitiesCreation) TSOM_NETWORK_PACKET(EntitiesDelete) TSOM_NETWORK_PACKET(EntitiesStateUpdate) TSOM_NETWORK_PACKET(EntityEnvironmentUpdate) +TSOM_NETWORK_PACKET(EntityPropertyUpdate) TSOM_NETWORK_PACKET(EnvironmentCreate) TSOM_NETWORK_PACKET(EnvironmentDestroy) TSOM_NETWORK_PACKET(EnvironmentUpdate) diff --git a/include/CommonLib/Protocol/Packets.hpp b/include/CommonLib/Protocol/Packets.hpp index 5d27efd6..69e0386f 100644 --- a/include/CommonLib/Protocol/Packets.hpp +++ b/include/CommonLib/Protocol/Packets.hpp @@ -223,6 +223,14 @@ namespace tsom Helper::EnvironmentId newEnvironmentId; }; + struct EntityPropertyUpdate + { + Nz::UInt16 tickIndex; + Helper::EntityId entity; + CompressedUnsigned propertyIndex; + EntityProperty propertyValue; + }; + struct EnvironmentCreate { Nz::UInt16 tickIndex; @@ -325,6 +333,7 @@ namespace tsom TSOM_COMMONLIB_API void Serialize(PacketSerializer& serializer, EntitiesDelete& data); TSOM_COMMONLIB_API void Serialize(PacketSerializer& serializer, EntitiesStateUpdate& data); TSOM_COMMONLIB_API void Serialize(PacketSerializer& serializer, EntityEnvironmentUpdate& data); + TSOM_COMMONLIB_API void Serialize(PacketSerializer& serializer, EntityPropertyUpdate& data); TSOM_COMMONLIB_API void Serialize(PacketSerializer& serializer, EnvironmentCreate& data); TSOM_COMMONLIB_API void Serialize(PacketSerializer& serializer, EnvironmentDestroy& data); TSOM_COMMONLIB_API void Serialize(PacketSerializer& serializer, EnvironmentUpdate& data); diff --git a/include/ServerLib/SessionVisibilityHandler.hpp b/include/ServerLib/SessionVisibilityHandler.hpp index 24025cc8..bc1a29e5 100644 --- a/include/ServerLib/SessionVisibilityHandler.hpp +++ b/include/ServerLib/SessionVisibilityHandler.hpp @@ -54,6 +54,7 @@ namespace tsom inline void MoveEnvironment(ServerEnvironment& environment, const EnvironmentTransform& transform); inline void UpdateControlledEntity(entt::handle entity, CharacterController* controller); + inline void UpdateEntityProperty(entt::handle entity, Nz::UInt32 propertyIndex); void UpdateEntityEnvironment(ServerEnvironment& newEnvironment, entt::handle oldEntity, entt::handle newEntity); inline void UpdateLastInputIndex(InputIndex inputIndex); inline void UpdateRootEnvironment(ServerEnvironment& environment); @@ -137,6 +138,7 @@ namespace tsom tsl::hopscotch_map m_entityIndices; tsl::hopscotch_map m_createdEntities; + tsl::hopscotch_map m_propertyUpdatedEntities; tsl::hopscotch_map m_chunkNetworkMaps; tsl::hopscotch_map m_environmentIndices; tsl::hopscotch_set m_deletedEntities; diff --git a/include/ServerLib/SessionVisibilityHandler.inl b/include/ServerLib/SessionVisibilityHandler.inl index 3bee2859..fd1385d3 100644 --- a/include/ServerLib/SessionVisibilityHandler.inl +++ b/include/ServerLib/SessionVisibilityHandler.inl @@ -3,6 +3,7 @@ // For conditions of distribution and use, see copyright notice in LICENSE #include +#include "SessionVisibilityHandler.hpp" namespace tsom { @@ -78,6 +79,11 @@ namespace tsom m_movingEntities.erase(m_controlledEntity); } + inline void SessionVisibilityHandler::UpdateEntityProperty(entt::handle entity, Nz::UInt32 propertyIndex) + { + m_propertyUpdatedEntities[entity] |= propertyIndex; + } + inline void SessionVisibilityHandler::UpdateLastInputIndex(InputIndex inputIndex) { m_lastInputIndex = inputIndex; diff --git a/include/ServerLib/Systems/NetworkedEntitiesSystem.hpp b/include/ServerLib/Systems/NetworkedEntitiesSystem.hpp index fdeac7fa..43076542 100644 --- a/include/ServerLib/Systems/NetworkedEntitiesSystem.hpp +++ b/include/ServerLib/Systems/NetworkedEntitiesSystem.hpp @@ -8,11 +8,13 @@ #define TSOM_SERVERLIB_SYSTEMS_NETWORKEDENTITIESSYSTEM_HPP #include +#include #include #include #include #include #include +#include #include namespace tsom @@ -46,8 +48,12 @@ namespace tsom void CreateEntity(SessionVisibilityHandler& visibility, entt::handle entity, const SessionVisibilityHandler::CreateEntityData& createData) const; void OnNetworkedDestroy(entt::registry& registry, entt::entity entity); - tsl::hopscotch_set m_movingEntities; - tsl::hopscotch_set m_networkedEntities; + struct EntityData + { + NazaraSlot(ClassInstanceComponent, OnPropertyUpdate, onPropertyUpdate); + }; + + tsl::hopscotch_map m_networkedEntities; entt::observer m_networkedConstructObserver; entt::scoped_connection m_disabledConstructConnection; entt::scoped_connection m_networkedDestroyConnection; diff --git a/src/ClientLib/ClientSessionHandler.cpp b/src/ClientLib/ClientSessionHandler.cpp index 65df2a83..85b4ca31 100644 --- a/src/ClientLib/ClientSessionHandler.cpp +++ b/src/ClientLib/ClientSessionHandler.cpp @@ -252,14 +252,13 @@ namespace tsom std::string entityClassName = GetSession()->GetStringStore().GetString(entityData.entityClass); if (const EntityClass* entityClass = m_entityRegistry.FindClass(entityClassName)) { - entityClass->SetupEntity(entity); - auto& entityClassData = entity.get(); + auto& entityInstance = entity.emplace(entityClass); std::size_t networkedPropertyIndex = 0; for (Nz::UInt32 i = 0; i < entityClass->GetPropertyCount(); ++i) { if (entityClass->GetProperty(i).isNetworked) - entityClassData.properties[i] = entityData.properties[networkedPropertyIndex++]; + entityInstance.UpdateProperty(i, std::move(entityData.properties[networkedPropertyIndex++])); } entityClass->ActivateEntity(entity); diff --git a/src/CommonLib/Components/ClassInstanceComponent.cpp b/src/CommonLib/Components/ClassInstanceComponent.cpp index 9a54b8a4..a45c3a09 100644 --- a/src/CommonLib/Components/ClassInstanceComponent.cpp +++ b/src/CommonLib/Components/ClassInstanceComponent.cpp @@ -8,9 +8,24 @@ namespace tsom { + ClassInstanceComponent::ClassInstanceComponent(const EntityClass* entityClass) : + m_entityClass(entityClass) + { + std::size_t propertyCount = entityClass->GetPropertyCount(); + + m_properties.reserve(propertyCount); + for (std::size_t i = 0; i < propertyCount; ++i) + m_properties.emplace_back(entityClass->GetProperty(i).defaultValue); + } + + Nz::UInt32 ClassInstanceComponent::FindPropertyIndex(std::string_view propertyName) const + { + return m_entityClass->FindProperty(propertyName); + } + Nz::UInt32 ClassInstanceComponent::GetPropertyIndex(std::string_view propertyName) const { - Nz::UInt32 propertyIndex = entityClass->FindProperty(propertyName); + Nz::UInt32 propertyIndex = FindPropertyIndex(propertyName); if (propertyIndex == EntityClass::InvalidIndex) throw std::runtime_error(fmt::format("invalid property {}", propertyName)); diff --git a/src/CommonLib/EntityClass.cpp b/src/CommonLib/EntityClass.cpp index d7705801..d354401c 100644 --- a/src/CommonLib/EntityClass.cpp +++ b/src/CommonLib/EntityClass.cpp @@ -26,19 +26,8 @@ namespace tsom void EntityClass::ActivateEntity(entt::handle entity) const { - assert(entity.get().entityClass == this); + assert(entity.get().GetClass() == this); if (m_callbacks.onInit) m_callbacks.onInit(entity); } - - ClassInstanceComponent& EntityClass::SetupEntity(entt::handle entity) const - { - auto& entityInstance = entity.emplace(); - entityInstance.entityClass = this; - entityInstance.properties.reserve(m_properties.size()); - for (const auto& property : m_properties) - entityInstance.properties.emplace_back(property.defaultValue); - - return entityInstance; - } } diff --git a/src/CommonLib/Protocol/Packets.cpp b/src/CommonLib/Protocol/Packets.cpp index 41c26fc9..643cb14c 100644 --- a/src/CommonLib/Protocol/Packets.cpp +++ b/src/CommonLib/Protocol/Packets.cpp @@ -275,6 +275,14 @@ namespace tsom serializer &= data.newEnvironmentId; } + TSOM_COMMONLIB_API void Serialize(PacketSerializer& serializer, EntityPropertyUpdate& data) + { + serializer &= data.tickIndex; + serializer &= data.entity; + serializer &= data.propertyIndex; + serializer &= data.propertyValue; + } + void Serialize(PacketSerializer& serializer, EnvironmentCreate& data) { serializer &= data.tickIndex; diff --git a/src/CommonLib/Scripting/EntityScriptingLibrary.cpp b/src/CommonLib/Scripting/EntityScriptingLibrary.cpp index 568da7c0..d2bf8a15 100644 --- a/src/CommonLib/Scripting/EntityScriptingLibrary.cpp +++ b/src/CommonLib/Scripting/EntityScriptingLibrary.cpp @@ -169,25 +169,25 @@ namespace tsom entt::handle entity = AssertScriptEntity(entityTable); auto& classComponent = entity.get(); - Nz::UInt32 propertyIndex = classComponent.entityClass->FindProperty(propertyName); + Nz::UInt32 propertyIndex = classComponent.FindPropertyIndex(propertyName); if (propertyIndex == EntityClass::InvalidIndex) TriggerLuaArgError(L, 2, fmt::format("invalid property {}", propertyName)); sol::state_view state(L); - return TranslatePropertyToLua(state, classComponent.properties[propertyIndex]); + return TranslatePropertyToLua(state, classComponent.GetProperty(propertyIndex)); }); entityMetatable["UpdateProperty"] = LuaFunction([this](sol::this_state L, sol::table entityTable, std::string_view propertyName, sol::object value) { entt::handle entity = AssertScriptEntity(entityTable); - auto& classComponent = entity.get(); - Nz::UInt32 propertyIndex = classComponent.entityClass->FindProperty(propertyName); + auto& classInstance = entity.get(); + Nz::UInt32 propertyIndex = classInstance.FindPropertyIndex(propertyName); if (propertyIndex == EntityClass::InvalidIndex) TriggerLuaArgError(L, 2, fmt::format("invalid property {}", propertyName)); - const auto& property = classComponent.entityClass->GetProperty(propertyIndex); - classComponent.properties[propertyIndex] = TranslatePropertyFromLua(value, property.type, property.isArray); + const auto& property = classInstance.GetClass()->GetProperty(propertyIndex); + classInstance.UpdateProperty(propertyIndex, TranslatePropertyFromLua(value, property.type, property.isArray)); }); } diff --git a/src/ServerLib/ServerPlanetEnvironment.cpp b/src/ServerLib/ServerPlanetEnvironment.cpp index f82964da..9bf4431f 100644 --- a/src/ServerLib/ServerPlanetEnvironment.cpp +++ b/src/ServerLib/ServerPlanetEnvironment.cpp @@ -46,7 +46,7 @@ namespace tsom const EntityClass* planetClass = serverInstance.GetEntityRegistry().FindClass("planet"); - auto& entityInstance = planetClass->SetupEntity(m_planetEntity); + auto& entityInstance = m_planetEntity.emplace(planetClass); entityInstance.UpdateProperty("CellSize", 1.f); entityInstance.UpdateProperty("CornerRadius", 16.f); entityInstance.UpdateProperty("Gravity", 9.81f); diff --git a/src/ServerLib/ServerShipEnvironment.cpp b/src/ServerLib/ServerShipEnvironment.cpp index 9b46a953..eb452810 100644 --- a/src/ServerLib/ServerShipEnvironment.cpp +++ b/src/ServerLib/ServerShipEnvironment.cpp @@ -52,7 +52,7 @@ namespace tsom const EntityClass* shipClass = serverInstance.GetEntityRegistry().FindClass("ship"); - auto& entityInstance = shipClass->SetupEntity(m_shipEntity); + auto& entityInstance = m_shipEntity.emplace(shipClass); entityInstance.UpdateProperty("CellSize", 1.f); shipClass->ActivateEntity(m_shipEntity); diff --git a/src/ServerLib/SessionVisibilityHandler.cpp b/src/ServerLib/SessionVisibilityHandler.cpp index 4f94d7f8..b0ceb2cd 100644 --- a/src/ServerLib/SessionVisibilityHandler.cpp +++ b/src/ServerLib/SessionVisibilityHandler.cpp @@ -135,7 +135,6 @@ namespace tsom // Schedule deletion m_deletedEntities.emplace(entity); } - m_movingEntities.erase(entity); } void SessionVisibilityHandler::DestroyEnvironment(ServerEnvironment& environment) @@ -167,6 +166,12 @@ namespace tsom if (m_movingEntities.erase(oldEntity) > 0) m_movingEntities.insert(newEntity); + if (auto it = m_propertyUpdatedEntities.find(oldEntity); it != m_propertyUpdatedEntities.end()) + { + m_propertyUpdatedEntities[newEntity] = it->second; + m_propertyUpdatedEntities.erase(it); + } + auto it = m_entityIndices.find(oldEntity); EntityId entityIndex = it.value(); m_entityIndices.erase(it); @@ -448,6 +453,18 @@ namespace tsom m_environmentUpdates.clear(); } + if (!m_propertyUpdatedEntities.empty()) + { + for (auto&& [entity, propertyFlags] : m_propertyUpdatedEntities) + { + EntityId entityIndex = Nz::Retrieve(m_entityIndices, entity); + + Packets::EntityPropertyUpdate propertyUpdatePacket; + propertyUpdatePacket.entity = entityIndex; + } + m_propertyUpdatedEntities.clear(); + } + Packets::EntitiesStateUpdate stateUpdate; stateUpdate.tickIndex = tickIndex; stateUpdate.lastInputIndex = m_lastInputIndex; @@ -497,7 +514,6 @@ namespace tsom m_createdEntities.erase(entityData.entity); m_deletedEntities.erase(entityData.entity); - m_movingEntities.erase(entityData.entity); m_entityIndices.erase(entityData.entity); m_freeEntityIds.Set(entityIndex, true); @@ -590,6 +606,9 @@ namespace tsom void SessionVisibilityHandler::HandleEntityDestruction(entt::handle entity) { + m_movingEntities.erase(entity); + m_propertyUpdatedEntities.erase(entity); + // handle chunks owned by this entity if any if (auto it = m_chunkNetworkMaps.find(entity); it != m_chunkNetworkMaps.end()) { diff --git a/src/ServerLib/Systems/NetworkedEntitiesSystem.cpp b/src/ServerLib/Systems/NetworkedEntitiesSystem.cpp index fbebbb0c..54e4c0e4 100644 --- a/src/ServerLib/Systems/NetworkedEntitiesSystem.cpp +++ b/src/ServerLib/Systems/NetworkedEntitiesSystem.cpp @@ -29,8 +29,8 @@ namespace tsom void NetworkedEntitiesSystem::CreateAllEntities(SessionVisibilityHandler& visibility) const { - for (entt::entity entity : m_networkedEntities) - CreateEntity(visibility, entt::handle(m_registry, entity), BuildCreateEntityData(entity)); + for (auto it = m_networkedEntities.begin(); it != m_networkedEntities.end(); ++it) + CreateEntity(visibility, entt::handle(m_registry, it.key()), BuildCreateEntityData(entity)); } void NetworkedEntitiesSystem::ForEachVisibility(const Nz::FunctionRef& functor) @@ -44,7 +44,6 @@ namespace tsom void NetworkedEntitiesSystem::ForgetEntity(entt::entity entity) { m_networkedEntities.erase(entity); - m_movingEntities.erase(entity); } void NetworkedEntitiesSystem::Update(Nz::Time elapsedTime) @@ -52,16 +51,21 @@ namespace tsom m_networkedConstructObserver.each([&](entt::entity entity) { assert(!m_networkedEntities.contains(entity)); - m_networkedEntities.insert(entity); + EntityData& entityData = m_networkedEntities[entity]; + + if (ClassInstanceComponent* entityInstance = m_registry.try_get(entity)) + { + entityData.onPropertyUpdate.Connect(entityInstance->OnPropertyUpdate, [](ClassInstanceComponent*, Nz::UInt32 propertyIndex, const EntityProperty& newValue) + { + + }); + } auto& entityNetwork = m_registry.get(entity); if (!entityNetwork.ShouldSignalCreation()) return; SessionVisibilityHandler::CreateEntityData createData = BuildCreateEntityData(entity); - if (createData.isMoving) - m_movingEntities.insert(entity); - ForEachVisibility([&](SessionVisibilityHandler& visibility) { CreateEntity(visibility, entt::handle(m_registry, entity), createData); @@ -77,22 +81,22 @@ namespace tsom auto& entityNet = m_registry.get(entity); - auto* entityClass = m_registry.try_get(entity); + auto* entityInstance = m_registry.try_get(entity); SessionVisibilityHandler::CreateEntityData createData; - createData.entityClass = (entityClass) ? entityClass->entityClass : nullptr; + createData.entityClass = (entityInstance) ? entityInstance->GetClass() : nullptr; createData.environment = &m_environment; createData.initialPosition = entityNode.GetPosition(); createData.initialRotation = entityNode.GetRotation(); createData.isMoving = isMoving; - if (entityClass) + if (entityInstance) { - createData.entityProperties.reserve(entityClass->properties.size()); - for (std::size_t i = 0; i < entityClass->properties.size(); ++i) + createData.entityProperties.reserve(createData.entityClass->GetPropertyCount()); + for (std::size_t i = 0; i < createData.entityClass->GetPropertyCount(); ++i) { - if (entityClass->entityClass->GetProperty(i).isNetworked) - createData.entityProperties.emplace_back(entityClass->properties[i]); + if (entityInstance->GetClass()->GetProperty(i).isNetworked) + createData.entityProperties.emplace_back(entityInstance->GetProperty(i)); } } @@ -138,7 +142,6 @@ namespace tsom return; m_networkedEntities.erase(entity); - m_movingEntities.erase(entity); ForEachVisibility([&](SessionVisibilityHandler& visibility) {