/* * 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 #include #include namespace Physics { class CharacterRequests; class CharacterHitDetectionConfiguration; } namespace MultiplayerSample { class AnimatedHitVolumesComponent : public AnimatedHitVolumesComponentBase , 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 m_transform; AZStd::shared_ptr 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(MultiplayerSample::AnimatedHitVolumesComponent, s_animatedHitVolumesComponentConcreteUuid, MultiplayerSample::AnimatedHitVolumesComponentBase); static void Reflect(AZ::ReflectContext* context); AnimatedHitVolumesComponent(); 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 m_animatedHitVolumes; Multiplayer::EntitySyncRewindEvent::Handler m_syncRewindHandler; Multiplayer::EntityPreRenderEvent::Handler m_preRenderHandler; }; }