Integrating github/staging through commit ab87ed9

This commit is contained in:
alexpete
2021-04-09 11:27:37 -07:00
parent ae62a97894
commit 1044dc3da1
1582 changed files with 29374 additions and 519051 deletions
@@ -0,0 +1,57 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include <Source/Components/LocalPredictionPlayerInputComponent.h>
#include <AzCore/Serialization/SerializeContext.h>
#include <AzCore/Serialization/EditContext.h>
namespace Multiplayer
{
void LocalPredictionPlayerInputComponent::LocalPredictionPlayerInputComponent::Reflect(AZ::ReflectContext* context)
{
AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(context);
if (serializeContext)
{
serializeContext->Class<LocalPredictionPlayerInputComponent, LocalPredictionPlayerInputComponentBase>()
->Version(1);
}
LocalPredictionPlayerInputComponentBase::Reflect(context);
}
void LocalPredictionPlayerInputComponentController::HandleSendClientInput
(
[[maybe_unused]] const Multiplayer::NetworkInputVector& inputArray,
[[maybe_unused]] const uint32_t& stateHash,
[[maybe_unused]] const AzNetworking::PacketEncodingBuffer& clientState
)
{
;
}
void LocalPredictionPlayerInputComponentController::HandleSendMigrateClientInput
(
[[maybe_unused]] const Multiplayer::MigrateNetworkInputVector& inputArray
)
{
;
}
void LocalPredictionPlayerInputComponentController::HandleSendClientInputCorrection
(
[[maybe_unused]] const Multiplayer::NetworkInputId& inputId,
[[maybe_unused]] const AzNetworking::PacketEncodingBuffer& correction
)
{
;
}
}
@@ -0,0 +1,47 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <Source/AutoGen/LocalPredictionPlayerInputComponent.AutoComponent.h>
namespace Multiplayer
{
class LocalPredictionPlayerInputComponent
: public LocalPredictionPlayerInputComponentBase
{
public:
AZ_MULTIPLAYER_COMPONENT(Multiplayer::LocalPredictionPlayerInputComponent, s_localPredictionPlayerInputComponentConcreteUuid, Multiplayer::LocalPredictionPlayerInputComponentBase);
static void Reflect([[maybe_unused]] AZ::ReflectContext* context);
void OnInit() override {}
void OnActivate([[maybe_unused]] Multiplayer::EntityIsMigrating entityIsMigrating) override {}
void OnDeactivate([[maybe_unused]] Multiplayer::EntityIsMigrating entityIsMigrating) override {}
};
class LocalPredictionPlayerInputComponentController
: public LocalPredictionPlayerInputComponentControllerBase
{
public:
LocalPredictionPlayerInputComponentController(LocalPredictionPlayerInputComponent& parent) : LocalPredictionPlayerInputComponentControllerBase(parent) {}
void OnActivate([[maybe_unused]] Multiplayer::EntityIsMigrating entityIsMigrating) override {}
void OnDeactivate([[maybe_unused]] Multiplayer::EntityIsMigrating entityIsMigrating) override {}
void HandleSendClientInput(const Multiplayer::NetworkInputVector& inputArray, const uint32_t& stateHash, const AzNetworking::PacketEncodingBuffer& clientState) override;
void HandleSendMigrateClientInput(const Multiplayer::MigrateNetworkInputVector& inputArray) override;
void HandleSendClientInputCorrection(const Multiplayer::NetworkInputId& inputId, const AzNetworking::PacketEncodingBuffer& correction) override;
};
}
@@ -16,9 +16,9 @@
namespace Multiplayer
{
void MultiplayerComponent::Reflect(AZ::ReflectContext* reflection)
void MultiplayerComponent::Reflect(AZ::ReflectContext* context)
{
AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(reflection);
AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(context);
if (serializeContext)
{
serializeContext->Class<MultiplayerComponent, AZ::Component>()
@@ -17,10 +17,11 @@
#include <AzNetworking/DataStructures/FixedSizeBitsetView.h>
#include <Source/NetworkEntity/NetworkEntityHandle.h>
#include <Source/MultiplayerTypes.h>
#include <Include/IMultiplayer.h>
//! Macro to declare bindings for a multiplayer component inheriting from MultiplayerComponent
#define AZ_MULTIPLAYER_COMPONENT(ComponentClass, Guid, Base) \
AZ_RTTI(ComponentClass, Guid, AZ::Component) \
AZ_RTTI(ComponentClass, Guid, Base) \
AZ_COMPONENT_INTRUSIVE_DESCRIPTOR_TYPE(ComponentClass) \
AZ_COMPONENT_BASE(ComponentClass, Guid, Base)
@@ -38,7 +39,7 @@ namespace Multiplayer
AZ_CLASS_ALLOCATOR(MultiplayerComponent, AZ::SystemAllocator, 0);
AZ_RTTI(MultiplayerComponent, "{B7F5B743-CCD3-4981-8F1A-FC2B95CE22D7}", AZ::Component);
static void Reflect(AZ::ReflectContext* reflection);
static void Reflect(AZ::ReflectContext* context);
static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required);
MultiplayerComponent() = default;
@@ -70,10 +71,10 @@ namespace Multiplayer
virtual bool HandleRpcMessage(NetEntityRole netEntityRole, NetworkEntityRpcMessage& rpcMessage) = 0;
virtual bool SerializeStateDeltaMessage(ReplicationRecord& replicationRecord, AzNetworking::ISerializer& serializer) = 0;
virtual void NotifyStateDeltaChanges(ReplicationRecord& replicationRecord) = 0;
protected:
virtual bool HasController() const = 0;
virtual MultiplayerController* GetController() = 0;
protected:
virtual void ConstructController() = 0;
virtual void DestructController() = 0;
virtual void ActivateController(EntityIsMigrating entityIsMigrating) = 0;
@@ -113,27 +114,30 @@ namespace Multiplayer
{
if (bitset.GetBit(bitIndex))
{
//uint32_t prevUpdateSize = serializer.GetSize();
const uint32_t prevUpdateSize = serializer.GetSize();
serializer.ClearTrackedChangesFlag();
serializer.Serialize(value, name);
if (modifyRecord && !serializer.GetTrackedChangesFlag())
{
bitset.SetBit(bitIndex, false);
}
//uint32_t postUpdateSize = serializer.GetSize();
const uint32_t postUpdateSize = serializer.GetSize();
// Network Property metrics
// uint32_t updateSize = (postUpdateSize - prevUpdateSize);
// if (updateSize > 0)
// {
// if (serializer.GetSerializerMode() == AzNetworking::SerializerMode::WriteToObject)
// {
// GetPacketHandlerMetricsInstance().LogRecvNetworkPropertyUpdates(componentType, name, updateSize);
// }
// else
// {
// GetPacketHandlerMetricsInstance().LogSentNetworkPropertyUpdates(componentType, name, updateSize);
// }
// }
const uint32_t updateSize = (postUpdateSize - prevUpdateSize);
if (updateSize > 0)
{
MultiplayerStats& stats = AZ::Interface<IMultiplayer>::Get()->GetStats();
if (serializer.GetSerializerMode() == AzNetworking::SerializerMode::WriteToObject)
{
stats.m_propertyUpdatesRecv++;
stats.m_propertyUpdatesRecvBytes += updateSize;
}
else
{
stats.m_propertyUpdatesSent++;
stats.m_propertyUpdatesSentBytes += updateSize;
}
}
}
}
}
@@ -37,13 +37,13 @@ namespace Multiplayer
AZ::EditContext* editContext = serializeContext->GetEditContext();
if (editContext)
{
editContext->Class<NetBindComponent>("NetBindComponent", "Required Component for binding an entity to the network")
editContext->Class<NetBindComponent>(
"Network Binding", "The Network Binding component marks an entity as able to be replicated across the network")
->ClassElement(AZ::Edit::ClassElements::EditorData, "")
->Attribute(AZ::Edit::Attributes::Category, "Multiplayer")
->Attribute(AZ::Edit::Attributes::Icon, "Editor/Icons/Components/NetBind.png")
->Attribute(AZ::Edit::Attributes::ViewportIcon, "Editor/Icons/Components/Viewport/NetBind.png")
->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC_CE("Game"))
;
->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC_CE("Game"));
}
}
}
@@ -69,7 +69,7 @@ namespace Multiplayer
void NetBindComponent::Init()
{
m_netEntityHandle = GetNetworkEntityManager()->AddEntityToEntityMap(m_netEntityId, GetEntity());
;
}
void NetBindComponent::Activate()
@@ -92,7 +92,7 @@ namespace Multiplayer
void NetBindComponent::Deactivate()
{
AZ_Assert(m_needsToBeStopped == false, "Entity appears to have been deleted with using the EntityManagerBase. Use MarkForRemoval to correctly clean up an entity");
AZ_Assert(m_needsToBeStopped == false, "Entity appears to have been improperly deleted. Use MarkForRemoval to correctly clean up a networked entity.");
m_handleLocalServerRpcMessageEventHandle.Disconnect();
if (NetworkRoleHasController(m_netEntityRole))
{
@@ -139,7 +139,8 @@ namespace Multiplayer
MultiplayerComponentInputVector NetBindComponent::AllocateComponentInputs()
{
MultiplayerComponentInputVector componentInputs;
for (MultiplayerComponent* multiplayerComponent : m_multiplayerInputComponentVector)
const size_t multiplayerComponentSize = m_multiplayerInputComponentVector.size();
for (size_t i = 0; i < multiplayerComponentSize; ++i)
{
// TODO: ComponentInput factory, needs multiplayer component architecture and autogen
AZStd::unique_ptr<IMultiplayerComponentInput> componentInput = nullptr; // ComponentInputFactory(multiplayerComponent->GetComponentId());
@@ -350,9 +351,10 @@ namespace Multiplayer
{
AZ_Assert(entity != nullptr, "AZ::Entity is null");
m_prefabEntityId = prefabEntityId;
m_netEntityId = netEntityId;
m_netEntityRole = netEntityRole;
m_prefabEntityId = prefabEntityId;
m_netEntityHandle = GetNetworkEntityManager()->AddEntityToEntityMap(m_netEntityId, entity);
for (AZ::Component* component : entity->GetComponents())
{
@@ -11,6 +11,8 @@
*/
#include <Source/Components/NetworkTransformComponent.h>
#include <AzCore/Serialization/SerializeContext.h>
#include <AzCore/Serialization/EditContext.h>
namespace Multiplayer
{
@@ -22,5 +24,7 @@ namespace Multiplayer
serializeContext->Class<NetworkTransformComponent, NetworkTransformComponentBase>()
->Version(1);
}
NetworkTransformComponentBase::Reflect(context);
}
}