Some initial updates for eventual support of locally predicted input processing
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/std/containers/list.h>
|
||||
#include <Source/MultiplayerTypes.h>
|
||||
|
||||
namespace AZ
|
||||
{
|
||||
@@ -17,7 +18,13 @@ namespace {{ Namespace }}
|
||||
{% set ComponentName = Component.attrib['Name'] %}
|
||||
{{ ComponentName }},
|
||||
{% endfor %}
|
||||
Count
|
||||
};
|
||||
static_assert(ComponentTypes::Count < static_cast<ComponentTypes>(Multiplayer::InvalidNetComponentId), "ComponentId overflow");
|
||||
|
||||
//! For reflecting multiplayer components into the serialize, edit, and behaviour contexts.
|
||||
void CreateComponentDescriptors(AZStd::list<AZ::ComponentDescriptor*>& descriptors);
|
||||
|
||||
//! For creating multiplayer component network inputs.
|
||||
void CreateComponentNetworkInput();
|
||||
}
|
||||
|
||||
+2
-2
@@ -16,7 +16,7 @@
|
||||
<Include File="Source/NetworkInput/NetworkInputVector.h"/>
|
||||
<Include File="AzNetworking/DataStructures/ByteBuffer.h"/>
|
||||
|
||||
<NetworkProperty Type="Multiplayer::NetworkInputId" Name="LastInputId" Init="Multiplayer::NetworkInputId{0}" ReplicateFrom="Authority" ReplicateTo="Authority" IsRewindable="false" IsPredictable="false" IsPublic="false" Container="Object" ExposeToEditor="false" GenerateEventBindings="false" />
|
||||
<NetworkProperty Type="Multiplayer::ClientInputId" Name="LastInputId" Init="Multiplayer::ClientInputId{0}" ReplicateFrom="Authority" ReplicateTo="Authority" IsRewindable="false" IsPredictable="false" IsPublic="false" Container="Object" ExposeToEditor="false" GenerateEventBindings="false" />
|
||||
|
||||
<RemoteProcedure Name="SendClientInput" InvokeFrom="Autonomous" HandleOn="Authority" IsPublic="true" IsReliable="false" Description="Client to server move / input RPC">
|
||||
<Param Type="Multiplayer::NetworkInputVector" Name="inputArray" />
|
||||
@@ -25,7 +25,7 @@
|
||||
</RemoteProcedure>
|
||||
|
||||
<RemoteProcedure Name="SendClientInputCorrection" InvokeFrom="Authority" HandleOn="Autonomous" IsPublic="true" IsReliable="false" Description="Autonomous proxy correction RPC">
|
||||
<Param Type="Multiplayer::NetworkInputId" Name="inputId" />
|
||||
<Param Type="Multiplayer::ClientInputId" Name="inputId" />
|
||||
<Param Type="AzNetworking::PacketEncodingBuffer" Name="correction" />
|
||||
</RemoteProcedure>
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace Multiplayer
|
||||
|
||||
void LocalPredictionPlayerInputComponentController::HandleSendClientInputCorrection
|
||||
(
|
||||
[[maybe_unused]] const Multiplayer::NetworkInputId& inputId,
|
||||
[[maybe_unused]] const Multiplayer::ClientInputId& inputId,
|
||||
[[maybe_unused]] const AzNetworking::PacketEncodingBuffer& correction
|
||||
)
|
||||
{
|
||||
|
||||
@@ -42,6 +42,6 @@ namespace Multiplayer
|
||||
|
||||
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;
|
||||
void HandleSendClientInputCorrection(const Multiplayer::ClientInputId& inputId, const AzNetworking::PacketEncodingBuffer& correction) override;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -54,6 +54,5 @@ namespace Multiplayer
|
||||
void OnTransformChangedEvent(const AZ::Transform& worldTm);
|
||||
|
||||
AZ::TransformChangedEvent::Handler m_transformChangedHandler;
|
||||
AZ::ScheduledEvent m_transformChangeEvent;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -33,22 +33,36 @@ namespace Multiplayer
|
||||
return *this;
|
||||
}
|
||||
|
||||
void NetworkInput::SetNetworkInputId(NetworkInputId inputId)
|
||||
void NetworkInput::SetClientInputId(ClientInputId inputId)
|
||||
{
|
||||
m_inputId = inputId;
|
||||
}
|
||||
|
||||
NetworkInputId NetworkInput::GetNetworkInputId() const
|
||||
ClientInputId NetworkInput::GetClientInputId() const
|
||||
{
|
||||
return m_inputId;
|
||||
}
|
||||
|
||||
|
||||
NetworkInputId& NetworkInput::ModifyNetworkInputId()
|
||||
ClientInputId& NetworkInput::ModifyClientInputId()
|
||||
{
|
||||
return m_inputId;
|
||||
}
|
||||
|
||||
void NetworkInput::SetServerTimeMs(AZ::TimeMs serverTimeMs)
|
||||
{
|
||||
m_serverTimeMs = serverTimeMs;
|
||||
}
|
||||
|
||||
AZ::TimeMs NetworkInput::GetServerTimeMs() const
|
||||
{
|
||||
return m_serverTimeMs;
|
||||
}
|
||||
|
||||
AZ::TimeMs& NetworkInput::ModifyServerTimeMs()
|
||||
{
|
||||
return m_serverTimeMs;
|
||||
}
|
||||
|
||||
void NetworkInput::AttachNetBindComponent(NetBindComponent* netBindComponent)
|
||||
{
|
||||
m_wasAttached = true;
|
||||
@@ -62,7 +76,6 @@ namespace Multiplayer
|
||||
|
||||
bool NetworkInput::Serialize(AzNetworking::ISerializer& serializer)
|
||||
{
|
||||
//static_assert(UINT8_MAX >= Multiplayer::ComponentTypes::c_Count, "Expected fewer than 255 components, this code needs to be updated");
|
||||
if (!serializer.Serialize(m_inputId, "InputId"))
|
||||
{
|
||||
return false;
|
||||
@@ -135,8 +148,9 @@ namespace Multiplayer
|
||||
void NetworkInput::CopyInternal(const NetworkInput& rhs)
|
||||
{
|
||||
m_inputId = rhs.m_inputId;
|
||||
m_serverTimeMs = rhs.m_serverTimeMs;
|
||||
m_componentInputs.resize(rhs.m_componentInputs.size());
|
||||
for (int i = 0; i < rhs.m_componentInputs.size(); ++i)
|
||||
for (int32_t i = 0; i < rhs.m_componentInputs.size(); ++i)
|
||||
{
|
||||
if (m_componentInputs[i] == nullptr || m_componentInputs[i]->GetComponentId() != rhs.m_componentInputs[i]->GetComponentId())
|
||||
{
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace Multiplayer
|
||||
// Forwards
|
||||
class NetBindComponent;
|
||||
|
||||
AZ_TYPE_SAFE_INTEGRAL(NetworkInputId, uint16_t);
|
||||
AZ_TYPE_SAFE_INTEGRAL(ClientInputId, uint16_t);
|
||||
|
||||
//! @class NetworkInput
|
||||
//! @brief A single networked client input command.
|
||||
@@ -38,9 +38,13 @@ namespace Multiplayer
|
||||
NetworkInput(const NetworkInput&);
|
||||
NetworkInput& operator= (const NetworkInput&);
|
||||
|
||||
void SetNetworkInputId(NetworkInputId inputId);
|
||||
NetworkInputId GetNetworkInputId() const;
|
||||
NetworkInputId& ModifyNetworkInputId();
|
||||
void SetClientInputId(ClientInputId inputId);
|
||||
ClientInputId GetClientInputId() const;
|
||||
ClientInputId& ModifyClientInputId();
|
||||
|
||||
void SetServerTimeMs(AZ::TimeMs serverTimeMs);
|
||||
AZ::TimeMs GetServerTimeMs() const;
|
||||
AZ::TimeMs& ModifyServerTimeMs();
|
||||
|
||||
void AttachNetBindComponent(NetBindComponent* netBindComponent);
|
||||
|
||||
@@ -67,10 +71,11 @@ namespace Multiplayer
|
||||
void CopyInternal(const NetworkInput& rhs);
|
||||
|
||||
MultiplayerComponentInputVector m_componentInputs;
|
||||
NetworkInputId m_inputId = NetworkInputId{ 0 };
|
||||
ClientInputId m_inputId = ClientInputId{ 0 };
|
||||
AZ::TimeMs m_serverTimeMs = AZ::TimeMs{ 0 };
|
||||
ConstNetworkEntityHandle m_owner;
|
||||
bool m_wasAttached = false;
|
||||
};
|
||||
}
|
||||
|
||||
AZ_TYPE_SAFE_INTEGRAL_SERIALIZEBINDING(Multiplayer::NetworkInputId);
|
||||
AZ_TYPE_SAFE_INTEGRAL_SERIALIZEBINDING(Multiplayer::ClientInputId);
|
||||
|
||||
@@ -48,12 +48,12 @@ namespace Multiplayer
|
||||
return m_inputs[index].m_networkInput;
|
||||
}
|
||||
|
||||
void NetworkInputVector::SetPreviousInputId(NetworkInputId previousInputId)
|
||||
void NetworkInputVector::SetPreviousInputId(ClientInputId previousInputId)
|
||||
{
|
||||
m_previousInputId = previousInputId;
|
||||
}
|
||||
|
||||
NetworkInputId NetworkInputVector::GetPreviousInputId() const
|
||||
ClientInputId NetworkInputVector::GetPreviousInputId() const
|
||||
{
|
||||
return m_previousInputId;
|
||||
}
|
||||
|
||||
@@ -32,8 +32,8 @@ namespace Multiplayer
|
||||
NetworkInput& operator[](uint32_t index);
|
||||
const NetworkInput& operator[](uint32_t index) const;
|
||||
|
||||
void SetPreviousInputId(NetworkInputId previousInputId);
|
||||
NetworkInputId GetPreviousInputId() const;
|
||||
void SetPreviousInputId(ClientInputId previousInputId);
|
||||
ClientInputId GetPreviousInputId() const;
|
||||
|
||||
bool Serialize(AzNetworking::ISerializer& serializer);
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace Multiplayer
|
||||
|
||||
ConstNetworkEntityHandle m_owner;
|
||||
AZStd::fixed_vector<Wrapper, MaxElements> m_inputs;
|
||||
NetworkInputId m_previousInputId;
|
||||
ClientInputId m_previousInputId;
|
||||
};
|
||||
|
||||
//! @class MigrateNetworkInputVector
|
||||
|
||||
Reference in New Issue
Block a user