Merged development

Signed-off-by: AMZN-Olex <5432499+AMZN-Olex@users.noreply.github.com>
This commit is contained in:
AMZN-Olex
2021-08-02 20:54:46 -04:00
617 changed files with 11087 additions and 14179 deletions
@@ -36,6 +36,8 @@ namespace Multiplayer
void OnScaleChangedEvent(float scale);
void OnResetCountChangedEvent();
void UpdateTargetHostFrameId();
AZ::Transform m_previousTransform = AZ::Transform::CreateIdentity();
AZ::Transform m_targetTransform = AZ::Transform::CreateIdentity();
@@ -45,6 +47,8 @@ namespace Multiplayer
AZ::Event<uint8_t>::Handler m_resetCountEventHandler;
EntityPreRenderEvent::Handler m_entityPreRenderEventHandler;
Multiplayer::HostFrameId m_targetHostFrameId = HostFrameId(0);
};
class NetworkTransformComponentController
@@ -122,6 +122,11 @@ namespace Multiplayer
//! @return the current server time in milliseconds
virtual AZ::TimeMs GetCurrentHostTimeMs() const = 0;
//! Returns the current blend factor for client side interpolation
//! This value is only relevant on the client and is used to smooth between host frames
//! @return the current blend factor
virtual float GetCurrentBlendFactor() const = 0;
//! Returns the network time instance bound to this multiplayer instance.
//! @return pointer to the network time instance bound to this multiplayer instance
virtual INetworkTime* GetNetworkTime() = 0;
@@ -182,23 +187,27 @@ namespace Multiplayer
class ScopedAlterTime final
{
public:
inline ScopedAlterTime(HostFrameId frameId, AZ::TimeMs timeMs, AzNetworking::ConnectionId connectionId)
inline ScopedAlterTime(HostFrameId frameId, AZ::TimeMs timeMs, float blendFactor, AzNetworking::ConnectionId connectionId)
{
INetworkTime* time = GetNetworkTime();
m_previousHostFrameId = time->GetHostFrameId();
m_previousHostTimeMs = time->GetHostTimeMs();
m_previousRewindConnectionId = time->GetRewindingConnectionId();
time->AlterTime(frameId, timeMs, connectionId);
m_previousBlendFactor = time->GetHostBlendFactor();
time->AlterBlendFactor(blendFactor);
}
inline ~ScopedAlterTime()
{
INetworkTime* time = GetNetworkTime();
time->AlterTime(m_previousHostFrameId, m_previousHostTimeMs, m_previousRewindConnectionId);
time->AlterBlendFactor(m_previousBlendFactor);
}
private:
HostFrameId m_previousHostFrameId = InvalidHostFrameId;
AZ::TimeMs m_previousHostTimeMs = AZ::TimeMs{ 0 };
AzNetworking::ConnectionId m_previousRewindConnectionId = AzNetworking::InvalidConnectionId;
float m_previousBlendFactor = DefaultBlendFactor;
};
inline const char* GetEnumString(MultiplayerAgentType value)
@@ -22,6 +22,9 @@ namespace Multiplayer
//! The default number of rewindable samples for us to store.
static constexpr uint32_t RewindHistorySize = 128;
//! The default blend factor for ScopedAlterTime
static constexpr float DefaultBlendFactor = 1.f;
AZ_TYPE_SAFE_INTEGRAL(HostId, uint32_t);
static constexpr HostId InvalidHostId = static_cast<HostId>(-1);
@@ -45,6 +45,9 @@ namespace Multiplayer
AZ::TimeMs GetHostTimeMs() const;
AZ::TimeMs& ModifyHostTimeMs();
void SetHostBlendFactor(float hostBlendFactor);
float GetHostBlendFactor() const;
void AttachNetBindComponent(NetBindComponent* netBindComponent);
bool Serialize(AzNetworking::ISerializer& serializer);
@@ -73,6 +76,7 @@ namespace Multiplayer
ClientInputId m_inputId = ClientInputId{ 0 };
HostFrameId m_hostFrameId = InvalidHostFrameId;
AZ::TimeMs m_hostTimeMs = AZ::TimeMs{ 0 };
float m_hostBlendFactor = 0.f;
ConstNetworkEntityHandle m_owner;
bool m_wasAttached = false;
};
@@ -43,6 +43,10 @@ namespace Multiplayer
//! @return the hosts current timeMs
virtual AZ::TimeMs GetHostTimeMs() const = 0;
//! Retrieves the hosts current blend factor (may be rewound on the server during backward reconciliation).
//! @return the hosts current blend factor
virtual float GetHostBlendFactor() const = 0;
//! Get the controlling connection that may be currently altering global game time.
//! Note this abstraction is required at a relatively high level to allow for 'don't rewind the shooter' semantics
//! @return the ConnectionId of the connection requesting the rewind operation
@@ -60,6 +64,10 @@ namespace Multiplayer
//! @param rewindConnectionId the rewinding ConnectionId
virtual void AlterTime(HostFrameId frameId, AZ::TimeMs timeMs, AzNetworking::ConnectionId rewindConnectionId) = 0;
//! Alters the current Host blend factor. Used to drive interpolation in rewound states.
//! @param blendFactor the blend factor to use
virtual void AlterBlendFactor(float blendFactor) = 0;
//! Syncs all entities contained within a volume to the current rewind state.
//! @param rewindVolume the volume to rewind entities within (needed for physics entities)
virtual void SyncEntitiesToRewindState(const AZ::Aabb& rewindVolume) = 0;
@@ -60,6 +60,10 @@ namespace Multiplayer
//! @return value in const base type form
const BASE_TYPE& Get() const;
//! Const base type retriever for one host frame behind Get(). Only intended for use in SyncRewind contexts.
//! @return value in const base type form
const BASE_TYPE& GetPrevious() const;
//! Base type retriever.
//! @return value in base type form
BASE_TYPE& Modify();
@@ -66,6 +66,12 @@ namespace Multiplayer
return GetValueForTime(GetCurrentTimeForProperty());
}
template <typename BASE_TYPE, AZStd::size_t REWIND_SIZE>
inline const BASE_TYPE& RewindableObject<BASE_TYPE, REWIND_SIZE>::GetPrevious() const
{
return GetValueForTime(GetCurrentTimeForProperty() - HostFrameId(1));
}
template <typename BASE_TYPE, AZStd::size_t REWIND_SIZE>
inline BASE_TYPE& RewindableObject<BASE_TYPE, REWIND_SIZE>::Modify()
{