merging latest development
Signed-off-by: kberg-amzn <karlberg@amazon.com>
This commit is contained in:
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Source/AutoGen/NetworkCharacterComponent.AutoComponent.h>
|
||||
#include <PhysX/CharacterGameplayBus.h>
|
||||
#include <Multiplayer/Components/NetBindComponent.h>
|
||||
|
||||
namespace Physics
|
||||
{
|
||||
class Character;
|
||||
}
|
||||
|
||||
namespace Multiplayer
|
||||
{
|
||||
//! NetworkCharacterComponent
|
||||
//! Provides multiplayer support for game-play player characters.
|
||||
class NetworkCharacterComponent
|
||||
: public NetworkCharacterComponentBase
|
||||
, private PhysX::CharacterGameplayRequestBus::Handler
|
||||
{
|
||||
friend class NetworkCharacterComponentController;
|
||||
|
||||
public:
|
||||
AZ_MULTIPLAYER_COMPONENT(Multiplayer::NetworkCharacterComponent, s_networkCharacterComponentConcreteUuid, Multiplayer::NetworkCharacterComponentBase)
|
||||
|
||||
static void Reflect(AZ::ReflectContext* context);
|
||||
|
||||
NetworkCharacterComponent();
|
||||
|
||||
static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible)
|
||||
{
|
||||
incompatible.push_back(AZ_CRC_CE("NetworkRigidBodyService"));
|
||||
}
|
||||
|
||||
// AZ::Component
|
||||
void OnInit() override {}
|
||||
void OnActivate(Multiplayer::EntityIsMigrating entityIsMigrating) override;
|
||||
void OnDeactivate(Multiplayer::EntityIsMigrating entityIsMigrating) override;
|
||||
|
||||
private:
|
||||
void OnTranslationChangedEvent(const AZ::Vector3& translation);
|
||||
void OnSyncRewind();
|
||||
|
||||
// CharacterGameplayRequestBus
|
||||
bool IsOnGround() const override;
|
||||
float GetGravityMultiplier() const override { return {}; }
|
||||
void SetGravityMultiplier([[maybe_unused]] float gravityMultiplier) override {}
|
||||
AZ::Vector3 GetFallingVelocity() const override { return {}; }
|
||||
void SetFallingVelocity([[maybe_unused]] const AZ::Vector3& fallingVelocity) override {}
|
||||
|
||||
Physics::Character* m_physicsCharacter = nullptr;
|
||||
Multiplayer::EntitySyncRewindEvent::Handler m_syncRewindHandler = Multiplayer::EntitySyncRewindEvent::Handler([this]() { OnSyncRewind(); });
|
||||
AZ::Event<AZ::Vector3>::Handler m_translationEventHandler;
|
||||
};
|
||||
|
||||
//! NetworkCharacterComponentController
|
||||
//! This is the network controller for NetworkCharacterComponent.
|
||||
//! Class provides the ability to move characters in physical space while keeping the network in-sync.
|
||||
class NetworkCharacterComponentController
|
||||
: public NetworkCharacterComponentControllerBase
|
||||
{
|
||||
public:
|
||||
NetworkCharacterComponentController(NetworkCharacterComponent& parent);
|
||||
|
||||
// NetworkCharacterComponentControllerBase
|
||||
void OnActivate(Multiplayer::EntityIsMigrating entityIsMigrating) override;
|
||||
void OnDeactivate(Multiplayer::EntityIsMigrating entityIsMigrating) override;
|
||||
|
||||
//! TryMoveWithVelocity
|
||||
//! Will move this character entity kinematically through physical world while also ensuring the network stays in-sync.
|
||||
//! Velocity will be applied over delta-time to determine the movement amount.
|
||||
//! Returns this entity's world-space position after the move.
|
||||
AZ::Vector3 TryMoveWithVelocity(const AZ::Vector3& velocity, float deltaTime);
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Source/AutoGen/NetworkHitVolumesComponent.AutoComponent.h>
|
||||
#include <Multiplayer/Components/NetBindComponent.h>
|
||||
#include <Integration/ActorComponentBus.h>
|
||||
#include <AzCore/Component/TransformBus.h>
|
||||
|
||||
namespace Physics
|
||||
{
|
||||
class CharacterRequests;
|
||||
class CharacterHitDetectionConfiguration;
|
||||
}
|
||||
|
||||
namespace Multiplayer
|
||||
{
|
||||
class NetworkHitVolumesComponent
|
||||
: public NetworkHitVolumesComponentBase
|
||||
, private EMotionFX::Integration::ActorComponentNotificationBus::Handler
|
||||
{
|
||||
public:
|
||||
struct AnimatedHitVolume final
|
||||
{
|
||||
AnimatedHitVolume
|
||||
(
|
||||
AzNetworking::ConnectionId connectionId,
|
||||
Physics::CharacterRequests* character,
|
||||
const char* hitVolumeName,
|
||||
const Physics::ColliderConfiguration* colliderConfig,
|
||||
const Physics::ShapeConfiguration* shapeConfig,
|
||||
const uint32_t jointIndex
|
||||
);
|
||||
|
||||
~AnimatedHitVolume() = default;
|
||||
|
||||
void UpdateTransform(const AZ::Transform& transform);
|
||||
void SyncToCurrentTransform();
|
||||
|
||||
Multiplayer::RewindableObject<AZ::Transform, Multiplayer::RewindHistorySize> m_transform;
|
||||
AZStd::shared_ptr<Physics::Shape> m_physicsShape;
|
||||
|
||||
// Cached so we don't have to do subsequent lookups by name
|
||||
const Physics::ColliderConfiguration* m_colliderConfig = nullptr;
|
||||
const Physics::ShapeConfiguration* m_shapeConfig = nullptr;
|
||||
AZ::Transform m_colliderOffSetTransform;
|
||||
const AZ::u32 m_jointIndex = 0;
|
||||
};
|
||||
|
||||
AZ_MULTIPLAYER_COMPONENT(Multiplayer::NetworkHitVolumesComponent, s_networkHitVolumesComponentConcreteUuid, Multiplayer::NetworkHitVolumesComponentBase);
|
||||
|
||||
static void Reflect(AZ::ReflectContext* context);
|
||||
|
||||
NetworkHitVolumesComponent();
|
||||
|
||||
void OnInit() override;
|
||||
void OnActivate(Multiplayer::EntityIsMigrating entityIsMigrating) override;
|
||||
void OnDeactivate(Multiplayer::EntityIsMigrating entityIsMigrating) override;
|
||||
|
||||
private:
|
||||
void OnPreRender(float deltaTime, float blendFactor);
|
||||
void OnTransformUpdate(const AZ::Transform& transform);
|
||||
void OnSyncRewind();
|
||||
|
||||
void CreateHitVolumes();
|
||||
void DestroyHitVolumes();
|
||||
|
||||
//! ActorComponentNotificationBus::Handler
|
||||
//! @{
|
||||
void OnActorInstanceCreated(EMotionFX::ActorInstance* actorInstance) override;
|
||||
void OnActorInstanceDestroyed(EMotionFX::ActorInstance* actorInstance) override;
|
||||
//! @}
|
||||
|
||||
Physics::CharacterRequests* m_physicsCharacter = nullptr;
|
||||
EMotionFX::Integration::ActorComponentRequests* m_actorComponent = nullptr;
|
||||
const Physics::CharacterColliderConfiguration* m_hitDetectionConfig = nullptr;
|
||||
|
||||
AZStd::vector<AnimatedHitVolume> m_animatedHitVolumes;
|
||||
|
||||
Multiplayer::EntitySyncRewindEvent::Handler m_syncRewindHandler;
|
||||
Multiplayer::EntityPreRenderEvent::Handler m_preRenderHandler;
|
||||
AZ::TransformChangedEvent::Handler m_transformChangedHandler;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project. For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <Source/AutoGen/NetworkRigidBodyComponent.AutoComponent.h>
|
||||
#include <AzCore/Component/TransformBus.h>
|
||||
#include <Multiplayer/Components/NetBindComponent.h>
|
||||
|
||||
namespace Physics
|
||||
{
|
||||
class RigidBodyRequests;
|
||||
}
|
||||
|
||||
namespace Multiplayer
|
||||
{
|
||||
//! Bus for requests to the network rigid body component.
|
||||
class NetworkRigidBodyRequests : public AZ::ComponentBus
|
||||
{
|
||||
};
|
||||
using NetworkRigidBodyRequestBus = AZ::EBus<NetworkRigidBodyRequests>;
|
||||
|
||||
class NetworkRigidBodyComponent final
|
||||
: public NetworkRigidBodyComponentBase
|
||||
, private NetworkRigidBodyRequestBus::Handler
|
||||
{
|
||||
friend class NetworkRigidBodyComponentController;
|
||||
|
||||
public:
|
||||
AZ_MULTIPLAYER_COMPONENT(
|
||||
Multiplayer::NetworkRigidBodyComponent, s_networkRigidBodyComponentConcreteUuid, Multiplayer::NetworkRigidBodyComponentBase);
|
||||
|
||||
static void Reflect(AZ::ReflectContext* context);
|
||||
static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
|
||||
static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required);
|
||||
static void GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent);
|
||||
|
||||
NetworkRigidBodyComponent();
|
||||
|
||||
void OnInit() override;
|
||||
void OnActivate(Multiplayer::EntityIsMigrating entityIsMigrating) override;
|
||||
void OnDeactivate(Multiplayer::EntityIsMigrating entityIsMigrating) override;
|
||||
|
||||
private:
|
||||
void OnTransformUpdate(const AZ::Transform& worldTm);
|
||||
void OnSyncRewind();
|
||||
|
||||
Multiplayer::EntitySyncRewindEvent::Handler m_syncRewindHandler;
|
||||
AZ::TransformChangedEvent::Handler m_transformChangedHandler;
|
||||
Physics::RigidBodyRequests* m_physicsRigidBodyComponent = nullptr;
|
||||
Multiplayer::RewindableObject<AZ::Transform, Multiplayer::RewindHistorySize> m_transform;
|
||||
};
|
||||
|
||||
class NetworkRigidBodyComponentController
|
||||
: public NetworkRigidBodyComponentControllerBase
|
||||
{
|
||||
public:
|
||||
NetworkRigidBodyComponentController(NetworkRigidBodyComponent& parent);
|
||||
|
||||
void OnActivate(Multiplayer::EntityIsMigrating entityIsMigrating) override;
|
||||
void OnDeactivate(Multiplayer::EntityIsMigrating entityIsMigrating) override;
|
||||
|
||||
void HandleSendApplyImpulse(AzNetworking::IConnection* invokingConnection, const AZ::Vector3& impulse, const AZ::Vector3& worldPoint) override;
|
||||
};
|
||||
} // namespace Multiplayer
|
||||
Reference in New Issue
Block a user