@@ -66,11 +66,6 @@ namespace Multiplayer
|
||||
}
|
||||
}
|
||||
|
||||
inline double ConvertTimeMsToSeconds(AZ::TimeMs value)
|
||||
{
|
||||
return static_cast<double>(static_cast<AZ::TimeMs>(value)) / 1000.0;
|
||||
}
|
||||
|
||||
void LocalPredictionPlayerInputComponent::LocalPredictionPlayerInputComponent::Reflect(AZ::ReflectContext* context)
|
||||
{
|
||||
AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(context);
|
||||
@@ -162,7 +157,7 @@ namespace Multiplayer
|
||||
}
|
||||
|
||||
const AZ::TimeMs currentTimeMs = AZ::GetElapsedTimeMs();
|
||||
const double clientInputRateSec = ConvertTimeMsToSeconds(cl_InputRateMs);
|
||||
const double clientInputRateSec = AZ::TimeMsToSecondsDouble(cl_InputRateMs);
|
||||
m_lastInputReceivedTimeMs = currentTimeMs;
|
||||
|
||||
// Keep track of last inputs received, also allows us to update frame ids
|
||||
@@ -267,7 +262,7 @@ namespace Multiplayer
|
||||
return;
|
||||
}
|
||||
|
||||
const double clientInputRateSec = ConvertTimeMsToSeconds(cl_InputRateMs);
|
||||
const double clientInputRateSec = AZ::TimeMsToSecondsDouble(cl_InputRateMs);
|
||||
|
||||
// Copy array so we can modify input ids
|
||||
NetworkInputMigrationVector inputArrayCopy = inputArray;
|
||||
@@ -342,7 +337,7 @@ namespace Multiplayer
|
||||
// If this correction is for a move outside our input history window, just start replaying from the oldest move we have available
|
||||
const uint32_t startReplayIndex = (inputHistorySize > historicalDelta) ? (inputHistorySize - historicalDelta) : 0;
|
||||
|
||||
const double clientInputRateSec = ConvertTimeMsToSeconds(cl_InputRateMs);
|
||||
const double clientInputRateSec = AZ::TimeMsToSecondsDouble(cl_InputRateMs);
|
||||
for (uint32_t replayIndex = startReplayIndex; replayIndex < inputHistorySize; ++replayIndex)
|
||||
{
|
||||
// Reprocess the input for this frame
|
||||
@@ -423,9 +418,9 @@ namespace Multiplayer
|
||||
|
||||
void LocalPredictionPlayerInputComponentController::UpdateAutonomous(AZ::TimeMs deltaTimeMs)
|
||||
{
|
||||
const double deltaTime = ConvertTimeMsToSeconds(deltaTimeMs);
|
||||
const double clientInputRateSec = ConvertTimeMsToSeconds(cl_InputRateMs);
|
||||
const double maxRewindHistory = ConvertTimeMsToSeconds(cl_MaxRewindHistoryMs);
|
||||
const double deltaTime = AZ::TimeMsToSecondsDouble(deltaTimeMs);
|
||||
const double clientInputRateSec = AZ::TimeMsToSecondsDouble(cl_InputRateMs);
|
||||
const double maxRewindHistory = AZ::TimeMsToSecondsDouble(cl_MaxRewindHistoryMs);
|
||||
|
||||
#ifndef AZ_RELEASE_BUILD
|
||||
m_moveAccumulator += deltaTime * cl_DebugHackTimeMultiplier;
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace Multiplayer
|
||||
// This can be used to help mitigate client side performance when large numbers of entities are created off the network
|
||||
AZ_CVAR(uint32_t, cl_ClientMaxRemoteEntitiesPendingCreationCount, AZStd::numeric_limits<uint32_t>::max(), nullptr, AZ::ConsoleFunctorFlags::DontReplicate, "Maximum number of entities that we have sent to the client, but have not had a confirmation back from the client");
|
||||
AZ_CVAR(AZ::TimeMs, cl_ClientEntityReplicatorPendingRemovalTimeMs, AZ::TimeMs{ 10000 }, nullptr, AZ::ConsoleFunctorFlags::DontReplicate, "How long should wait prior to removing an entity for the client through a change in the replication window, entity deletes are still immediate");
|
||||
AZ_CVAR(AZ::TimeMs, cl_DefaultNetworkEntityActivationTimeSliceMs, AZ::TimeMs{ 0 }, nullptr, AZ::ConsoleFunctorFlags::DontReplicate, "Max Ms to use to activate entities coming from the network, 0 means instantiate everything");
|
||||
AZ_CVAR(AZ::TimeMs, cl_DefaultNetworkEntityActivationTimeSliceMs, AZ::Time::ZeroTimeMs, nullptr, AZ::ConsoleFunctorFlags::DontReplicate, "Max Ms to use to activate entities coming from the network, 0 means instantiate everything");
|
||||
|
||||
ClientToServerConnectionData::ClientToServerConnectionData
|
||||
(
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace Multiplayer
|
||||
CollectHierarchyRoots();
|
||||
|
||||
AZ::EntitySystemBus::Handler::BusConnect();
|
||||
m_updateDebugOverlay.Enqueue(AZ::TimeMs{ 0 }, true);
|
||||
m_updateDebugOverlay.Enqueue(AZ::Time::ZeroTimeMs, true);
|
||||
}
|
||||
|
||||
MultiplayerDebugHierarchyReporter::~MultiplayerDebugHierarchyReporter()
|
||||
|
||||
@@ -127,7 +127,7 @@ namespace Multiplayer
|
||||
MultiplayerDebugPerEntityReporter::MultiplayerDebugPerEntityReporter()
|
||||
: m_updateDebugOverlay([this]() { UpdateDebugOverlay(); }, AZ::Name("UpdateDebugPerEntityOverlay"))
|
||||
{
|
||||
m_updateDebugOverlay.Enqueue(AZ::TimeMs{ 0 }, true);
|
||||
m_updateDebugOverlay.Enqueue(AZ::Time::ZeroTimeMs, true);
|
||||
|
||||
m_eventHandlers.m_entitySerializeStart = decltype(m_eventHandlers.m_entitySerializeStart)([this](AzNetworking::SerializerMode mode, AZ::EntityId entityId, const char* entityName)
|
||||
{
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace Multiplayer
|
||||
{
|
||||
m_networkEditorInterface = AZ::Interface<INetworking>::Get()->CreateNetworkInterface(
|
||||
AZ::Name(MpEditorInterfaceName), ProtocolType::Tcp, TrustZone::ExternalClientToServer, *this);
|
||||
m_networkEditorInterface->SetTimeoutMs(AZ::TimeMs{ 0 }); // Disable timeouts on this network interface
|
||||
m_networkEditorInterface->SetTimeoutMs(AZ::Time::ZeroTimeMs); // Disable timeouts on this network interface
|
||||
|
||||
// Wait to activate the editor-server until LegacySystemInterfaceCreated so that the logging system is ready
|
||||
// Automated testing listens for these logs
|
||||
|
||||
@@ -6,10 +6,9 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <MultiplayerToolsSystemComponent.h>
|
||||
#include <AzNetworking/Framework/NetworkingSystemComponent.h>
|
||||
#include <Multiplayer/Components/NetBindComponent.h>
|
||||
#include <Multiplayer/Components/NetworkHierarchyChildComponent.h>
|
||||
#include <Multiplayer/Components/NetworkHierarchyRootComponent.h>
|
||||
#include <Source/MultiplayerGem.h>
|
||||
#include <Source/MultiplayerSystemComponent.h>
|
||||
#include <Source/AutoGen/AutoComponentTypes.h>
|
||||
@@ -20,25 +19,32 @@ namespace Multiplayer
|
||||
MultiplayerModule::MultiplayerModule()
|
||||
: AZ::Module()
|
||||
{
|
||||
m_descriptors.insert(m_descriptors.end(), {
|
||||
AzNetworking::NetworkingSystemComponent::CreateDescriptor(),
|
||||
MultiplayerSystemComponent::CreateDescriptor(),
|
||||
NetBindComponent::CreateDescriptor(),
|
||||
NetworkSpawnableHolderComponent::CreateDescriptor(),
|
||||
});
|
||||
m_descriptors.insert(
|
||||
m_descriptors.end(),
|
||||
{
|
||||
AzNetworking::NetworkingSystemComponent::CreateDescriptor(),
|
||||
MultiplayerSystemComponent::CreateDescriptor(),
|
||||
NetBindComponent::CreateDescriptor(),
|
||||
NetworkSpawnableHolderComponent::CreateDescriptor(),
|
||||
#ifdef MULTIPLAYER_EDITOR
|
||||
MultiplayerToolsSystemComponent::CreateDescriptor(),
|
||||
#endif
|
||||
});
|
||||
|
||||
CreateComponentDescriptors(m_descriptors);
|
||||
}
|
||||
|
||||
AZ::ComponentTypeList MultiplayerModule::GetRequiredSystemComponents() const
|
||||
{
|
||||
return AZ::ComponentTypeList
|
||||
{
|
||||
return AZ::ComponentTypeList{
|
||||
azrtti_typeid<AzNetworking::NetworkingSystemComponent>(),
|
||||
azrtti_typeid<MultiplayerSystemComponent>(),
|
||||
#ifdef MULTIPLAYER_EDITOR
|
||||
azrtti_typeid<MultiplayerToolsSystemComponent>(),
|
||||
#endif
|
||||
};
|
||||
}
|
||||
}
|
||||
} // namespace Multiplayer
|
||||
|
||||
#if !defined(MULTIPLAYER_EDITOR)
|
||||
AZ_DECLARE_MODULE_CLASS(Gem_Multiplayer, Multiplayer::MultiplayerModule);
|
||||
|
||||
@@ -176,7 +176,7 @@ namespace Multiplayer
|
||||
AZStd::queue<AZStd::string> m_pendingConnectionTickets;
|
||||
AZStd::unordered_map<uint64_t, NetEntityId> m_playerRejoinData;
|
||||
|
||||
AZ::TimeMs m_lastReplicatedHostTimeMs = AZ::TimeMs{ 0 };
|
||||
AZ::TimeMs m_lastReplicatedHostTimeMs = AZ::Time::ZeroTimeMs;
|
||||
HostFrameId m_lastReplicatedHostFrameId = HostFrameId(0);
|
||||
|
||||
uint64_t m_temporaryUserIdentifier = 0; // Used in the event of a migration or rejoin
|
||||
|
||||
+1
-19
@@ -6,7 +6,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <MultiplayerToolsModule.h>
|
||||
#include <MultiplayerToolsSystemComponent.h>
|
||||
#include <Pipeline/NetworkPrefabProcessor.h>
|
||||
|
||||
#include <AzCore/Serialization/Json/RegistrationContext.h>
|
||||
@@ -39,22 +39,4 @@ namespace Multiplayer
|
||||
{
|
||||
m_didProcessNetPrefabs = didProcessNetPrefabs;
|
||||
}
|
||||
|
||||
MultiplayerToolsModule::MultiplayerToolsModule()
|
||||
: AZ::Module()
|
||||
{
|
||||
m_descriptors.insert(m_descriptors.end(), {
|
||||
MultiplayerToolsSystemComponent::CreateDescriptor(),
|
||||
});
|
||||
}
|
||||
|
||||
AZ::ComponentTypeList MultiplayerToolsModule::GetRequiredSystemComponents() const
|
||||
{
|
||||
return AZ::ComponentTypeList
|
||||
{
|
||||
azrtti_typeid<MultiplayerToolsSystemComponent>(),
|
||||
};
|
||||
}
|
||||
} // namespace Multiplayer
|
||||
|
||||
AZ_DECLARE_MODULE_CLASS(Gem_Multiplayer_Tools, Multiplayer::MultiplayerToolsModule);
|
||||
-14
@@ -37,19 +37,5 @@ namespace Multiplayer
|
||||
|
||||
bool m_didProcessNetPrefabs = false;
|
||||
};
|
||||
|
||||
class MultiplayerToolsModule
|
||||
: public AZ::Module
|
||||
{
|
||||
public:
|
||||
|
||||
AZ_RTTI(MultiplayerToolsModule, "{3F726172-21FC-48FA-8CFA-7D87EBA07E55}", AZ::Module);
|
||||
AZ_CLASS_ALLOCATOR(MultiplayerToolsModule, AZ::SystemAllocator, 0);
|
||||
|
||||
MultiplayerToolsModule();
|
||||
~MultiplayerToolsModule() override = default;
|
||||
|
||||
AZ::ComponentTypeList GetRequiredSystemComponents() const override;
|
||||
};
|
||||
} // namespace Multiplayer
|
||||
|
||||
+3
-3
@@ -54,10 +54,10 @@ namespace Multiplayer
|
||||
m_maxPayloadSize = connection.GetConnectionMtu() - UdpPacketHeaderSerializeSize - ReplicationManagerPacketOverhead;
|
||||
|
||||
// Schedule ClearRemovedReplicators()
|
||||
m_clearRemovedReplicators.Enqueue(AZ::TimeMs{ 0 }, true);
|
||||
m_clearRemovedReplicators.Enqueue(AZ::Time::ZeroTimeMs, true);
|
||||
|
||||
// Start window update events
|
||||
m_updateWindow.Enqueue(AZ::TimeMs{ 0 }, true);
|
||||
m_updateWindow.Enqueue(AZ::Time::ZeroTimeMs, true);
|
||||
|
||||
INetworkEntityManager* networkEntityManager = GetNetworkEntityManager();
|
||||
if (networkEntityManager != nullptr)
|
||||
@@ -97,7 +97,7 @@ namespace Multiplayer
|
||||
notReadyEntities.push_back(entityId);
|
||||
}
|
||||
}
|
||||
if (m_entityActivationTimeSliceMs > AZ::TimeMs{ 0 } && AZ::GetElapsedTimeMs() > endTimeMs)
|
||||
if (m_entityActivationTimeSliceMs > AZ::Time::ZeroTimeMs && AZ::GetElapsedTimeMs() > endTimeMs)
|
||||
{
|
||||
// If we go over our timeslice, break out the loop
|
||||
break;
|
||||
|
||||
@@ -344,7 +344,7 @@ namespace Multiplayer
|
||||
void EntityReplicator::SetPendingRemoval(AZ::TimeMs pendingRemovalTimeMs)
|
||||
{
|
||||
AZ_Assert(m_propertyPublisher, "Only valid if we are publishing updates");
|
||||
if (pendingRemovalTimeMs > AZ::TimeMs{ 0 })
|
||||
if (pendingRemovalTimeMs > AZ::Time::ZeroTimeMs)
|
||||
{
|
||||
if (!IsPendingRemoval())
|
||||
{
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace Multiplayer
|
||||
|
||||
bool PropertySubscriber::IsDeleting() const
|
||||
{
|
||||
return m_markForRemovalTimeMs > AZ::TimeMs{ 0 };
|
||||
return m_markForRemovalTimeMs > AZ::Time::ZeroTimeMs;
|
||||
}
|
||||
|
||||
bool PropertySubscriber::IsDeleted() const
|
||||
|
||||
@@ -40,6 +40,6 @@ namespace Multiplayer
|
||||
|
||||
// The last packet to have been received about this entity
|
||||
AzNetworking::PacketId m_lastReceivedPacketId = AzNetworking::InvalidPacketId;
|
||||
AZ::TimeMs m_markForRemovalTimeMs = AZ::TimeMs{ 0 };
|
||||
AZ::TimeMs m_markForRemovalTimeMs = AZ::Time::ZeroTimeMs;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ namespace Multiplayer
|
||||
AZ_Assert(entityHandle.GetNetBindComponent(), "No NetBindComponent found on networked entity");
|
||||
}
|
||||
m_removeList.push_back(entityHandle.GetNetEntityId());
|
||||
m_removeEntitiesEvent.Enqueue(AZ::TimeMs{ 0 });
|
||||
m_removeEntitiesEvent.Enqueue(AZ::Time::ZeroTimeMs);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace Multiplayer
|
||||
|
||||
HostFrameId m_hostFrameId = HostFrameId{ 0 };
|
||||
HostFrameId m_unalteredFrameId = HostFrameId{ 0 };
|
||||
AZ::TimeMs m_hostTimeMs = AZ::TimeMs{ 0 };
|
||||
AZ::TimeMs m_hostTimeMs = AZ::Time::ZeroTimeMs;
|
||||
float m_hostBlendFactor = DefaultBlendFactor;
|
||||
AzNetworking::ConnectionId m_rewindingConnectionId = AzNetworking::InvalidConnectionId;
|
||||
};
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace Multiplayer
|
||||
;
|
||||
|
||||
serializeContext->Class<NetworkPrefabProcessor, PrefabProcessor>()
|
||||
->Version(3)
|
||||
->Version(4)
|
||||
->Field("SerializationFormat", &NetworkPrefabProcessor::m_serializationFormat)
|
||||
;
|
||||
}
|
||||
@@ -146,6 +146,8 @@ namespace Multiplayer
|
||||
networkSpawnableAsset.Create(networkSpawnable->GetId());
|
||||
networkSpawnableAsset.SetAutoLoadBehavior(AZ::Data::AssetLoadBehavior::PreLoad);
|
||||
|
||||
AZStd::unordered_set<AZ::EntityId> prefabNetEntityIds;
|
||||
|
||||
for (auto* prefabEntity : prefabNetEntities)
|
||||
{
|
||||
Instance* instance = netEntityToInstanceMap[prefabEntity];
|
||||
@@ -158,6 +160,22 @@ namespace Multiplayer
|
||||
netEntity->InvalidateDependencies();
|
||||
netEntity->EvaluateDependencies();
|
||||
|
||||
auto* transformComponent = netEntity->FindComponent<AzFramework::TransformComponent>();
|
||||
if (transformComponent)
|
||||
{
|
||||
AZ::EntityId parentId = transformComponent->GetParentId();
|
||||
if (parentId.IsValid() && !prefabNetEntityIds.contains(parentId))
|
||||
{
|
||||
// Clear parent ID for net entities parented to a non-net entity.
|
||||
// To be addressed by the spawnable aliases system where non-net entities
|
||||
// will be spawned together with the networked ones in which case we'll keep
|
||||
// the cross-spawnable references.
|
||||
transformComponent->SetParent(AZ::EntityId());
|
||||
}
|
||||
}
|
||||
|
||||
prefabNetEntityIds.insert(netEntity->GetId());
|
||||
|
||||
// Insert the entity into the target net spawnable
|
||||
netSpawnableEntities.emplace_back(netEntity);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user